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

Generated nix.conf is not deterministic #562

Closed
emilazy opened this issue Jul 11, 2023 · 3 comments · Fixed by #710
Closed

Generated nix.conf is not deterministic #562

emilazy opened this issue Jul 11, 2023 · 3 comments · Fixed by #710
Assignees
Labels
bug Something isn't working

Comments

@emilazy
Copy link

emilazy commented Jul 11, 2023

When testing the installer in clean macOS VMs, @Enzime and I obtained nix.conf files with the exact same settings, but in different orders. I assume this is due to iterating through a randomized hash map in the unspecified internal order or similar.

I realize that the user can supply settings that can affect the resulting configuration, but it would be really helpful for us (nix-darwin) if the default nix.conf file had a consistent and predictable hash. Plus, isn't unnecessary unreproducibility just not very Nix? :)

(It'd be even better if the file did not contain the full nix-installer version but just an integer that only increments on changes that might materially affect the output nix.conf file, but I can understand why you would not want to do this.)

@emilazy
Copy link
Author

emilazy commented Jul 11, 2023

I should note also that the order is not completely irrelevant:

A configuration setting usually overrides any previous value. However, you can prefix the name of the setting by extra- to append to the previous value.
https://nixos.org/manual/nix/stable/command-ref/conf-file.html

but I don't know if this is relevant to nix-installer.

@Hoverbear Hoverbear added the bug Something isn't working label Jul 12, 2023
@Hoverbear
Copy link
Contributor

This is unfortunately a consequence of our nix.conf merging behavior. It's most certainly a place we could improve. We should probably be preserving the ordering/format where possible.

@emilazy
Copy link
Author

emilazy commented Jul 12, 2023

FWIW, only the order of the file on a clean install really matters for us, since it's just a matter of having a consistent hash. Anyone doing customization pre-install hopefully knows what they're doing already and can add the hash or manually move the file away. So just removing the nondeterminism from the added options would be adequate for us, even though it might be worth considering ordering in general due to the odd behaviour of the extra-* options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants