From f473b21c9fbb6b9af0400442448e44514d44a452 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sun, 26 Aug 2018 14:09:01 +0200 Subject: [PATCH] environment: add darwinConfig option to set darwin-config in NIX_PATH This simplifies using a non default configuration.nix without requiring a symlink or redefining NIX_PATH. The nix.nixPath option only defines a default which means defining a value will drop all of the defaults. This is because correct merge behaviour isn't very clear for named entries. --- modules/environment/default.nix | 13 +++++++++++++ modules/nix/default.nix | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/environment/default.nix b/modules/environment/default.nix index 3ab07564..6d77cd63 100644 --- a/modules/environment/default.nix +++ b/modules/environment/default.nix @@ -63,6 +63,19 @@ in { description = "List of directories to be symlinked in /run/current-system/sw."; }; + environment.darwinConfig = mkOption { + type = types.either types.path types.str; + default = "$HOME/.nixpkgs/darwin-configuration.nix"; + description = '' + The path of the darwin configuration.nix used to configure the system, + this updates the default darwin-config entry in NIX_PATH. Since this + changes an environment variable it will only apply to new shells. + + NOTE: Changing this requires running darwin-rebuild switch -I darwin-config=/path/to/configuration.nix + the first time to make darwin-rebuild aware of the custom location. + ''; + }; + environment.loginShell = mkOption { type = types.str; default = "$SHELL"; diff --git a/modules/nix/default.nix b/modules/nix/default.nix index 082649dd..79ae41ab 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -314,7 +314,7 @@ in type = types.listOf types.str; default = [ # Include default path . - "darwin-config=$HOME/.nixpkgs/darwin-configuration.nix" + "darwin-config=${config.environment.darwinConfig}" "/nix/var/nix/profiles/per-user/root/channels" "$HOME/.nix-defexpr/channels" ];