You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've heard from both @nuttycom and @cocreature that nixpkgs' documentation doesn't describe how to ensure reproducible derivations by pinning the version of nixpkgs.
My knowledge is that this is probably the best way to pin:
@ocharlesfetchFromGitHub uses IFD, which then doesn't display all packages to be built upfront. So you first need to build pkgs.fetchFromGithub using the current NIX_PATH and then you can import further on with the new set.
fetchTarball is a builtin, but it has a drawback that you can't use it with Hydra and need to pass it as an input (what why I usually accept pkgs input that is fetchTarball by default.
So that would have been the fetchNixpkgs@LnL7 had proposed (#26802), but that's IFD as @domenkozar pointed out. The proper solution is to use fetchTarball from Nix 1.12 which uses a hash (NixOS/nix#1382).
@domenkozar I don't entirely understand your comment. Yes, it uses IFD and that results in multiple phases, but beyond that I haven't seen any problems. It's not like a command has to be ran multiple times. What is the main problem?
I use that pattern all the time at work. I even proposed something to make it a bit smoother, but it didn't really go anywhere: #22058
I also don't use fetchTarball since I want to be able to lock the version and treat it as a fixed-output derivation that I can cache somewhere, and no released version of Nix has that functionality for fetchTarball yet.
Edit: to elaborate, I want to be able to cache the exact nixpkgs tarball with a known output hash because many of my machines can't hit github.com, so fetchTarball's attempts to hit the internet directly won't work.
@ocharles if Nix needs to download anything before evaluating pkgs.fetchFromGithub it won't print the full build plan, etc. It's the best we have now until in Nix 11.12 is released where builtins.fetchTarball accepts a hash so it doesn't redownload the tarball, but all of that happens at evaluation time eagerly.
Just tried @puffnfresh 's implementation today, seems to work. Only issue was an ergonomic one, I wasn't sure how to get the sha256 so I used nix-prefetch-git as suggested here to fetch the revision and get the hash, and then copy/pasted the output. A bit tedious, not sure if there's a better way.
@adelbertc For GitHub, nix-prefetch-url --unpack https://github.com/<owner>/<repo>/archive/<rev>.tar.gz >> file.nix, not sure if there's a better way.
But I if instead I was using https://github.com/nixos/nixpkgs/archive/ca2ba44cab47767c8127d1c8633e2b581644eb8f.tar.gz, then how to get this used in the nix.nixPath"nixpkgs=??"?
Activity
vyp commentedon Aug 7, 2017
Would you know how that compares to setting
nix.nixPath?domenkozar commentedon Aug 7, 2017
http://nix-cookbook.readthedocs.io/en/latest/faq.html#how-to-pin-nixpkgs-to-a-specific-commit-branch
ocharles commentedon Aug 7, 2017
I think the solution in the issue description is the best way. I don't see any need to use
fetchTarball.vyp commentedon Aug 7, 2017
For reference, and if it helps anyone, my source for setting
nix.nixPathand managing it with git method, is: http://anderspapitto.com/posts/2015-11-01-nixos-with-local-nixpkgs-checkout.htmlExcept that has a typo on the line (the fourth
"):Should be something like the following instead:
And also I think it should be
git fetch --allinstead of justgit fetcheach time (so that all remotes are fetched).puffnfresh commentedon Aug 7, 2017
I think ideally there'd be a
fetchNixpkgsfunction.domenkozar commentedon Aug 7, 2017
@ocharles
fetchFromGitHubuses IFD, which then doesn't display all packages to be built upfront. So you first need to buildpkgs.fetchFromGithubusing the current NIX_PATH and then you can import further on with the new set.fetchTarballis a builtin, but it has a drawback that you can't use it with Hydra and need to pass it as an input (what why I usually acceptpkgsinput that isfetchTarballby default.FRidh commentedon Aug 7, 2017
So that would have been the
fetchNixpkgs@LnL7 had proposed (#26802), but that's IFD as @domenkozar pointed out. The proper solution is to usefetchTarballfrom Nix 1.12 which uses a hash (NixOS/nix#1382).ocharles commentedon Aug 7, 2017
@domenkozar I don't entirely understand your comment. Yes, it uses IFD and that results in multiple phases, but beyond that I haven't seen any problems. It's not like a command has to be ran multiple times. What is the main problem?
copumpkin commentedon Aug 7, 2017
I use that pattern all the time at work. I even proposed something to make it a bit smoother, but it didn't really go anywhere: #22058
I also don't use
fetchTarballsince I want to be able to lock the version and treat it as a fixed-output derivation that I can cache somewhere, and no released version of Nix has that functionality forfetchTarballyet.Edit: to elaborate, I want to be able to cache the exact nixpkgs tarball with a known output hash because many of my machines can't hit github.com, so
fetchTarball's attempts to hit the internet directly won't work.domenkozar commentedon Aug 8, 2017
@ocharles if Nix needs to download anything before evaluating
pkgs.fetchFromGithubit won't print the full build plan, etc. It's the best we have now until in Nix 11.12 is released wherebuiltins.fetchTarballaccepts a hash so it doesn't redownload the tarball, but all of that happens at evaluation time eagerly.adelbertc commentedon Aug 10, 2017
Just tried @puffnfresh 's implementation today, seems to work. Only issue was an ergonomic one, I wasn't sure how to get the sha256 so I used
nix-prefetch-gitas suggested here to fetch the revision and get the hash, and then copy/pasted the output. A bit tedious, not sure if there's a better way.vyp commentedon Aug 10, 2017
@adelbertc For GitHub,
nix-prefetch-url --unpack https://github.com/<owner>/<repo>/archive/<rev>.tar.gz >> file.nix, not sure if there's a better way.domenkozar commentedon Aug 16, 2017
Relevant: #21732
domenkozar commentedon Dec 30, 2017
It's been done in https://nixos.wiki/wiki/How_to_fetch_Nixpkgs_with_an_empty_NIX_PATH
puffnfresh commentedon Dec 30, 2017
I think that's fair enough, although it still seems to be an IFD under 1.11
CMCDragonkai commentedon Nov 26, 2018
Can the documentation be updated to show you to pin the same nixpkgs to both the
configuration.nixand thenix.nixPath = [ "nixpkgs=??" ];.I currently have something like:
But I if instead I was using
https://github.com/nixos/nixpkgs/archive/ca2ba44cab47767c8127d1c8633e2b581644eb8f.tar.gz, then how to get this used in thenix.nixPath"nixpkgs=??"?