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
Running nixos-rebuild switch
twice can produce different results due to dependence on current system state
#65803
Comments
Setting things up in such a way that building your system config relies on the environment (NIX_PATH, nix-channel, etc) is certainly going to be fragile. This is hopefully one of the problems that flakes have set out to solve? I believe the usual advice is to pin nixpkgs, which can be a pain to maintain but as far as I know is the best way to make things reasonably reproducible. I suppose there's a balance here to weigh against overloading new users with unfamiliar concepts, being able to guide them to certain techniques while still offering more familiar workflows like nix-channel, nix-env, /etc config files, etc. without the cost of losing some of the advantages of nix? A large part of it is just improved tooling, like replacing nix-channel with something that's both easy to use and doesn't make a mess of things - either by making declarative configuration easier or having imperative tools that modify your declarations/config rather than directly affecting the environment. (I don't even like the idea of keeping the config on the same system in /etc, my own approach to pinning is to use git to pin nixpkgs as a submodule, so that it can be tied to config changes and (also note: I'm sidestepping the topic of nix.conf because that topic's a bit more nuanced, though the hope is that any changes a typical user makes to that file won't meaningfully affect the output of any derivations) |
Yes, you are right, The core reason is that If you want true reproducibility, you should manage all impurities on your own. Luckily, the ones I've listed above are all of them: NIX_PATH ( BTW, what you have described is already implemented for I'll change issue type to "question" then. People tried to fix the issue previously but failed #30399 PS. You can also make |
When installing NixOS on a device for the first time. I usually switch from the nix channel to a local git checkout of nixpkgs. For me at least, this is the best option because:
So with the current state of affairs, I have to run
Do you know if it's possible to use pinning to import a local nixpkgs checkout, thus effectively ignoring
I think this is basically what I'm trying to do: I'm pointing nixPath at a local checkout so that I can 'manage' it, but as you say, it's a setup problem which happens while transitioning into the managed state.
Slightly offtopic: I originally wanted to tag this as a question, but it wouldn't let me. |
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:
|
See also: #8160 |
Describe the bug
Quoting from the NixOS homepage
The problem is that the system/environment in which
nixos-rebuild
is run can have a huge effect on the result. This is especially noticeable when setting Nix configuration options such as thenixPath
. The firstnixos-rebuild
will use the existing/etc/nix/nix.conf
. If the build + switch results in changes to/etc/nix/nix.conf
, then the nextnixos-rebuild
will potentially produce a completely different result.I am wondering whether:
/etc/nix/nix.conf
, then using them in subsequent stages instead of the current generation's.To Reproduce
As an example, on a fresh system set to use a channel:
/etc/nixos/configuration.nix
to setnix.nixPath
to include something likenixpkgs=/path/to/local/nixpkgs
nixos-rebuild
: It will rebuild everything using the channelnixos-rebuild
again: It will rebuild everything using the local nixpkgs in/path/to/local/nixpkgs
Note that I am aware that you can override various nix options on the command line or by setting environment variables. What I am interested in, is whether we can get closer to the idea of a simple "define the system" -> "realise the system".
Expected behavior
It would be nice to be able to define your system configuration, run nixos-rebuild once, and be fairly sure that the result was what you defined.
The text was updated successfully, but these errors were encountered: