Nice one @danieldk, looks like "{$crate2nix.src}/tools.nix"
is working as of the latest nixos-unstable
Before integrating this into a standalone tool, I first wanted to try using "${crate2nix.src}/tools.nix"
to build a single crate. Here’s the small .nix
expression I’m using to do so:
{
callPackage,
fetchFromGitHub,
crate2nix,
}:
let
crateTools = callPackage "${crate2nix.src}/tools.nix" { };
generatedCargoNix = crateTools.generatedCargoNix {
name = "nannou";
src = builtins.toPath (builtins.getEnv "PWD");
};
cargoNix = callPackage generatedCargoNix { };
in cargoNix.workspaceMembers.nannou.build
However, when I attempt to build the expression with:
nix-build -E "with import <nixos> {}; callPackage ./nannou.nix {}"
I run into the following error:
error: unsupported argument 'submodules' to 'fetchGit', at /nix/store/qhgj6xjj44y53bw81slscp5w1xlddw59-source/tools.nix:235:15
In case you’re interested, here’s the full trace of the error:
Full Trace
error: while evaluating 'callPackageWith' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/lib/customisation.nix:117:35, called from (string):1:25:
while evaluating 'makeOverridable' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/lib/customisation.nix:67:24, called from /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/lib/customisation.nix:121:8:
while evaluating anonymous function at /home/mindtree/programming/rust/nannou/nannou.nix:1:1, called from /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/lib/customisation.nix:69:16:
while evaluating 'callPackageWith' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/lib/customisation.nix:117:35, called from /home/mindtree/programming/rust/nannou/nannou.nix:12:14:
while evaluating 'makeOverridable' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/lib/customisation.nix:67:24, called from /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/lib/customisation.nix:121:8:
while evaluating the attribute 'buildPhase' of the derivation 'nannou-crate2nix' at /nix/store/qhgj6xjj44y53bw81slscp5w1xlddw59-source/tools.nix:39:7:
while evaluating the attribute 'text' of the derivation 'vendor-config' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/pkgs/build-support/trivial-builders.nix:76:7:
while evaluating the attribute 'buildCommand' of the derivation 'deps' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/pkgs/build-support/trivial-builders.nix:76:7:
while evaluating 'concatMapStrings' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/lib/strings.nix:53:25, called from /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/pkgs/build-support/trivial-builders.nix:366:9:
while evaluating anonymous function at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/pkgs/build-support/trivial-builders.nix:366:31, called from undefined position:
while evaluating 'escapeShellArg' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/lib/strings.nix:318:20, called from /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/pkgs/build-support/trivial-builders.nix:367:33:
while evaluating the attribute 'name' at /nix/store/qhgj6xjj44y53bw81slscp5w1xlddw59-source/tools.nix:277:21:
while evaluating the attribute 'buildCommand' of the derivation 'hotglsl-0.1.0' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/pkgs/build-support/trivial-builders.nix:76:7:
while evaluating the attribute 'outputHash' of the derivation 'hotglsl-0.1.0' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/pkgs/build-support/fetchgit/default.nix:54:10:
while evaluating the attribute '"hotglsl 0.1.0 (git+https://github.com/nannou-org/hotglsl?branch=master#0066deaf2d428ffe73e697c7ec7f2e5af74571e4)"' at /nix/store/qhgj6xjj44y53bw81slscp5w1xlddw59-source/tools.nix:245:13:
while evaluating the attribute 'buildCommand' of the derivation 'hash-of-hotglsl' at /nix/store/03pwhxb4wgf8pj91aq5kz090rs8p7h19-nixos-21.05pre281538.9e377a6ce42/nixos/pkgs/build-support/trivial-builders.nix:76:7:
unsupported argument 'submodules' to 'fetchGit', at /nix/store/qhgj6xjj44y53bw81slscp5w1xlddw59-source/tools.nix:235:15
It looks like support for submodules in fetchGit
was only added last year in this PR:
https://github.com/NixOS/nix/pull/3166
This leads me to suspect that in order to use the crate2nix/tools
, the unstable version of nix is required. Does that sound right?
If so, I might put this tool on the backburner for a while. While I’m excited about Nix 3, flakes, etc, I think using nixos-unstable
is already pushing my mental instability budget