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

Use flake.nix by default if it exists #721

Open
belak opened this issue Jul 6, 2023 · 7 comments · May be fixed by #741 or #874
Open

Use flake.nix by default if it exists #721

belak opened this issue Jul 6, 2023 · 7 comments · May be fixed by #741 or #874

Comments

@belak
Copy link

belak commented Jul 6, 2023

Both nixos-rebuild switch and home-manager switch seem to allow using a flake without passing any arguments if a flake.nix file exists in their respective directories - /etc/nixos and ~/.config/home-manager respectively. They both seem to follow symlinks, using the actual directory containing flake.nix rather than simply those default directories.

My proposal is that darwin-rebuild should use a similar behavior - if flake.nix exists in a specific default location (though I'm not sure what that location would be), it would use that without any additional arguments being passed.

@LnL7
Copy link
Owner

LnL7 commented Jul 9, 2023

The default location for non flake configuration is ~/.config/darwin so that would be a good place.

@Enzime
Copy link
Collaborator

Enzime commented Jul 9, 2023

I was thinking that because nix-darwin fulfills a similar role to NixOS (manages the system primarily), it should live in /etc, how about /etc/nix-darwin?

@what-the-functor
Copy link

what-the-functor commented Jul 11, 2023

Although /etc/nix-darwin is symmetric with NixOS, Nix Darwin users whom don't also use NixOS will be accustomed to~/.config/darwin (perhaps $XDG_CONFIG_HOME/darwin).
I suggest that it defaults to $XDG_CONFIG_HOME/darwin, and is configurable to /etc/nix-darwin for those whom want symmetry with NixOS.

edit: it's XDG_CONFIG_HOME, not XDG_HOME

@what-the-functor
Copy link

Furthermore, anything in /etc could be removed on future updates of macOS.

@emilazy
Copy link
Collaborator

emilazy commented Jul 11, 2023

The current non-flakes default is actually ~/.nixpkgs/darwin-configuration.nix which is clearly unacceptable IMO (trampling on Nixpkgs' namespace, not XDG-compliant). The only mention of ~/.config/darwin is an example in the README, as far as I can tell. So we ought to change the default anyway, and I think we should avoid adding new things that depend on $HOME for #96 type reasons.

macOS has never trampled on non-system-software /etc files to my knowledge, and it'd be a huge breaking change were they ever to do so. Nix already uses /etc/nix, so /etc/nix-darwin is as safe as Nix itself.

(That said I personally keep my flake in $HOME on both platforms, I just pass --flake ~/... explicitly. A flakes-native way of specifying the default path might be nice, but is probably overkill in terms of this issue.)

@bouk
Copy link

bouk commented Feb 18, 2024

I've created a PR that uses ~/.config/darwin: #874

@michaelvanstraten
Copy link

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants