Open expipiplus1 opened 8 years ago
You can also pass -I /my/specific/version
parameter. But I agree it should be documented as it's very common use case.
I wrote a bit about this in http://nix-cookbook.readthedocs.io/en/latest/faq.html#how-to-pin-nixpkgs-to-a-specific-commit-branch
Do any of these options let you specify a sha256 hash for nixpkgs?
https://github.com/NixOS/nixpkgs/pull/30399 seems to be the best solution so far
@domenkozar How does one use something like https://github.com/input-output-hk/iohk-ops/blob/develop/fetch-nixpkgs.nix or https://nixos.wiki/wiki/How_to_fetch_Nixpkgs_with_an_empty_NIX_PATH with NixOps? As far as I can tell, NixOps needs NIX_PATH and there is no way to pass it an expression to evaluate.
i think nixops set-args -I nixpkgs=fetch-nixpkgs.nix
would work, as long as that fetch file returns a path, but that requires some imperative setup for each new deployment
@cleverca22 I just tried that, but set-args
seems to ignore the -I
flag. The command you suggested did not change the state file at all. If I provide a dummy argument like --arg foo 10
, it sets that attribute in the state file, but it still does not add a nixPath
attribute.
I created a test deployment from scratch using https://github.com/input-output-hk/iohk-ops/blob/develop/fetch-nixpkgs.nix:
nixops create -d production.example.org "<machines/example.org.org.nix>" "<machines/production.example.org.nix>" -I "nixpkgs=fetch-nixpkgs.nix" -s test.nixops
That does set nixPath
in the state file, but NixOps still complains that it can't find the Nix search path when I try to deploy:
error: file ‘nixpkgs/nixos/lib/testing.nix’ was not found in the Nix search path (add it using $NIX_PATH or -I), at /nix/store/cyq3cbka33lyp3kwx6cwdn46xi9z2iv7-nixops-1.6pre0_abcdef/share/nix/nixops/eval-machine-info.nix:9:13
ah yeah, the trick i gave only works for import <nixpkgs>
but it wont work for <nixpkgs/nixos/lib/testing.nix>
I already have a script wrapper around NixOps to import/export deployment state as JSON, to make certain kinds of errors less likely, etc.; so I've effectively achieved the same thing in the script by using the path that nix-build --no-out-link fetch-nixpkgs.nix
prints to stdout as part of the NIX_PATH
environment variable passed to nixops
.
🎉
It would be nice if this were possible natively, though!
nixops .. -I nixpkgs=$(nix-build --no-out-link fetch-nixpkgs.nix)
should work, but I haven't tested that :)
@domenkozar Ahh yes, of course! That is almost exactly what I'm doing in my wrapper script, in fact, just with more intermediate steps.
Is it correct that the best way to use a specific version of nixpkgs for a deployment is to only call
nixops
withNIX_PATH=nixpkgs=/my/specific/version
It would be nice to be able to specify nixpkgs in the network configuration.