nix-darwin
nix-darwin copied to clipboard
Use flake.nix by default if it exists
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.
The default location for non flake configuration is ~/.config/darwin
so that would be a good place.
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
?
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
Furthermore, anything in /etc
could be removed on future updates of macOS.
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 https://github.com/LnL7/nix-darwin/issues/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.)
I've created a PR that uses ~/.config/darwin: https://github.com/LnL7/nix-darwin/pull/874
Any updates on this?