nix-darwin
nix-darwin copied to clipboard
Set default flake directory as `/etc/nix-darwin`
Backported from https://github.com/NixOS/nixpkgs/blob/9995a5d59c59fde96f4ad7d811a8ed832357440f/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh#L349-L353
Fixes #721
If we do this, should we also switch the non-flakes default (I guess that might be backwards-incompatible?) and update the README?
@emilazy my preference would not be to do any breaking changes while we don't have release channels, and this PR only affects behaviour for users who have a flake present in /etc/nix-darwin which should be no one currently. With regard to the documentation, I'm thinking of updating it separately as the instructions there still work but it'll take some rework to incorporate explaining putting your config in /etc/nix-darwin vs $HOME (and how to symlink /etc/nix-darwin).
Okay, sure; I'm in favour. Could maybe make the instructions clearer around https://github.com/LnL7/nix-darwin/issues/740 when adjusting the docs too.
I'm not sure that introducing inconsistent locations is a good idea. For changing this in general with compatibility in mind, we could add detection for the global location and fallback to a per-user config so both cases work.
With NIX_PATH it is relatively easy for a user to specify their own default location, does something equivalent exist for nixos with the flake location?
I think there's already inconsistency since the installer etc. use ~/.nixpkgs/darwin-configuration.nix but the flake docs talk about ~/.config/darwin, and it's been like that for a long time now. Maybe we could introduce this and change the docs for flakes, and then handle moving non-flakes configurations over and the attendant backwards compatibility concerns afterwards, since this wouldn't be introducing any new inconsistency?
does something equivalent exist for nixos with the flake location
Unfortunately I don't think so. Though maybe one has been added since I last checked. I can think of multiple ways to do it but I don't know which are any good. I always just manually specified the location. Some people sudo ln -s ~/flake /etc/nixos, which seems reasonable.
I've updated this PR to search /etc/nix-darwin first then fallback to ~/.config/nix-darwin (current directory mentioned in the README) and ~/.nixpkgs which is hardcoded in a lot of locations in the codebase.
I think we should migrate to /etc/nix-darwin in a different PR and properly deprecate the old paths and update the docs.
This PR is now ready to merge as it is no longer opinionated about the default flake directory.