Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix: make derivation and update shell #1003

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

markoburcul
Copy link
Contributor

Create a structure for nix files. Add the derivation file which is using system Nim to compile Codex. Move shell definition to a specific file.

Referenced issue: #940

Create a structure for nix files. Add the derivation file which is using
system Nim to compile Codex. Move shell definition to a specific file.

Referenced issue: #940

Signed-off-by: markoburcul <[email protected]>
@markoburcul markoburcul marked this pull request as ready for review November 27, 2024 15:16
Copy link

@jakubgs jakubgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff.

Comment on lines +3 to +9
let
tools = pkgs.callPackage ./tools.nix {};
source = ../codex.nimble;

version = tools.findKeyValue "version = \"([0-9]+\.[0-9]+\.[0-9]+)\"" source;
in
"${version}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version variable is pointless, and so it interpolating it after the let/in block.

Suggested change
let
tools = pkgs.callPackage ./tools.nix {};
source = ../codex.nimble;
version = tools.findKeyValue "version = \"([0-9]+\.[0-9]+\.[0-9]+)\"" source;
in
"${version}"
let
tools = pkgs.callPackage ./tools.nix {};
in
tools.findKeyValue "version = \"([0-9]+\.[0-9]+\.[0-9]+)\"" ../codex.nimble;

Honestly, this is so short you could just put this directly in nix/default.nix.

@@ -3,33 +3,36 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
circom-compat.url = "github:codex-storage/circom-compat-ffi";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't reference it by relative path? Might be possible:

Comment on lines +24 to +25
inherit stableSystems;
inherit circomCompatPkg;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inherit stableSystems;
inherit circomCompatPkg;
inherit stableSystems circomCompatPkg;

nativeBuildInputs = let
# Fix for Nim compiler calling 'git rev-parse' and 'lsb_release'.
fakeGit = writeScriptBin "git" "echo ${version}";
fakeLsbRelease = writeScriptBin "lsb_release" "echo nix";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using this instead of lsb-release package?

Comment on lines +34 to 36
devShells = forAllSystems (system: {
default = pkgsFor.${system}.callPackage ./nix/shell.nix { };
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just use the package itself to get necessary tools, and add others using buildInputes:

Suggested change
devShells = forAllSystems (system: {
default = pkgsFor.${system}.callPackage ./nix/shell.nix { };
});
devShells = forAllSystems (system: let
pkgs = pkgsFor.${system};
in {
default = pkgs.mkShell {
inputsFrom = [
packages.${system}.codex
circom-compat.packages.${system}.default
];
buildInputs = with pkgs; [ git nodejs_18 ];
};
});

Are we even using this llvmPackages.openmp thing? I don't see it in the build. Built fine without it on my host.

"x86_64-linux" "aarch64-linux"
"x86_64-darwin" "aarch64-darwin"
],
circomCompatPkg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a default fallback here too:

Suggested change
circomCompatPkg
circomCompatPkg ? (
builtins.getFlake "github:codex-storage/circom-compat-ffi"
).packages.${builtins.currentSystem}.default

Comment on lines +41 to +42
curl
bash
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bash is a part of stdenv, and curl makes no sense.

Comment on lines +44 to +45
openssl
gmp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we already adding this in buildInputs?

inherit (pkgs) stdenv lib writeScriptBin callPackage;

revision = lib.substring 0 8 (src.rev or "dirty");
in pkgs.stdenv.mkDerivation rec {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be enforcing GCC11?

Suggested change
in pkgs.stdenv.mkDerivation rec {
in pkgs.gcc11Stdenv.mkDerivation rec {

fakeCargo = writeScriptBin "cargo" "echo ${version}";
in
with pkgs; [
gcc11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done using gcc11Stdenv.mkDerivation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants