-
-
Notifications
You must be signed in to change notification settings - Fork 467
Changing the configuration.nix location
By default nix-darwin looks for ~/.nixpkgs/darwin-configuration.nix
but that might be inconvenient if it's in a git repository that's in a different location. Using a symlink is one solution, but that's one more thing to configure outside of nix-darwin.
The environment.darwinConfig
can be used for this instead, however this still requires running darwin-rebuild with extra arguments the first time. If you have a command to bootstrap your dotfiles it can be added there.
This changes environment variables; don't forget to reload or start a new shell.
{ config, pkgs, ... }:
{
# Use a custom configuration.nix location.
# $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
# ...
}
The activation checks will verify if the configuration file exists. If you get an error message like this it means darwin-rebuild found a config file but the environment.darwinConfig
option doesn't point to an existing file.
building the system configuration...
error: file 'darwin-config' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:1
error: Changed <darwin-config> but target does not exist, aborting activation
Create $HOME/.nixpkgs/darwin-configuration.nix or set environment.darwinConfig:
environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
And rebuild using (only required once)
$ darwin-rebuild switch -I "darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix"