LnL7 / nix-darwin

nix modules for darwin
MIT License
2.44k stars 408 forks source link

Unable to install on top of a fresh Lix install #995

Closed ian-h-chamberlain closed 2 days ago

ian-h-chamberlain commented 4 days ago

I was looking to get started with nix-darwin, and tried to do a clean-slate install after uninstalling everything Nix from my Mac and then reinstalling with Lix, but ran into this (I think something similar to #880):

$ nix run nix-darwin -- switch --flake .
building the system configuration...
error: Unexpected files in /etc, aborting activation
The following files have unrecognized content and would be overwritten:

  /etc/nix/nix.conf

Please check there is nothing critical in these files, rename them by adding .before-nix-darwin to the end, and then try again.

I don't want to delete that file as it seems like it would be important:

# Generated by https://install.lix.systems/.
# See `/nix/nix-installer --version` for the version details.

build-users-group = nixbld
experimental-features = nix-command flakes
bash-prompt-prefix = (nix:$name)\040
max-jobs = auto
substituters = https://cache.nixos.org https://cache.lix.systems
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=
extra-nix-path = nixpkgs=flake:nixpkgs

The installer:

$ /nix/nix-installer --version
lix-installer 0.17.1
$ sha256sum /etc/nix/nix.conf
24797ac05542ff8b52910efc77870faa5f9e3275097227ea4e50c430a5f72916  /etc/nix/nix.conf

Is this just a matter of adding another "known hash" like #881 ? I think there might also exist a variant of the nix.conf that would not use experimental-features = nix-command flakes, since Lix asks whether it should enable flakes at installation time. I'm not sure if the output is totally deterministic, it seems like it could vary a bit: https://git.lix.systems/lix-project/lix-installer#installation-differences

Meanwhile, is there any workaround to get past this and install anyway (like providing my own hash or explicitly ignoring the file, or something like https://github.com/LnL7/nix-darwin/wiki/Running-a-locally-patched-version-of-nix-darwin)? Is this something that would need to be fixed by Lix upstream somehow and I should file an issue there?

Thanks in advance! I was hoping these two could work together, as I preferred using Lix on Linux but seems like getting started might be a little trickier than I thought 😆

emilazy commented 4 days ago

It should be okay to move the file as long as you don’t restart the Nix daemon before activating your system configuration (and in that case you can just put it back). We don’t have an explicit override mechanism right now, but doing the move manually is matching exactly what the installer would do anyway.

The proper resolution should be as simple as adding the known hashes (and preferably copies of the files into doc/known-files), like you said. Would you be up for making a pull request?

ian-h-chamberlain commented 2 days ago

Sure, let me figure out what permutations are possible and try to submit a PR! Meanwhile I'll also see if installation works just by moving the file and go from there.