From 0d8c53a0ad23d684e475eb3add87d46aa7adadb0 Mon Sep 17 00:00:00 2001 From: aszlig Date: Tue, 1 Dec 2015 15:24:13 +0100 Subject: common: Add option for global nixpkgs config. This should make creating ~/.nixpkgs/config.nix obsolete and we can solely decide whether we actually want these overrides by modifying NIX_PATH alone. The option isn't enabled by default, because this doesn't work if for example /etc/nixos/configuration.nix is not readable by the user using nix-env or importing by other means. Signed-off-by: aszlig --- modules/profiles/common.nix | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'modules/profiles/common.nix') diff --git a/modules/profiles/common.nix b/modules/profiles/common.nix index c941d636..0be2be96 100644 --- a/modules/profiles/common.nix +++ b/modules/profiles/common.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, pkgs, lib, ... }: with lib; @@ -15,6 +15,17 @@ with lib; ''; }; + enableGlobalNixpkgsConfig = mkOption { + type = types.bool; + default = false; + description = '' + Enabling this links nixos-config to be used by + nixpkgs-config, which essentially means that + attributes defined in are also in effect + for user environments. + ''; + }; + channelName = mkOption { type = types.str; default = "vuizvui"; @@ -46,13 +57,21 @@ with lib; ]; nix.nixPath = let + nixpkgs = import ../../nixpkgs-path.nix; rootChannelsPath = "/nix/var/nix/profiles/per-user/root/channels"; channelPath = "${rootChannelsPath}/${config.vuizvui.channelName}"; - in mkIf config.vuizvui.modifyNixPath (mkOverride 90 [ - "vuizvui=${channelPath}" - "nixpkgs=${channelPath}/nixpkgs" - "nixos-config=/etc/nixos/configuration.nix" - rootChannelsPath - ]); + nixosConfig = "/etc/nixos/configuration.nix"; + nixpkgsConfig = "nixpkgs-config=${pkgs.writeText "nixpkgs-config.nix" '' + (import ${nixpkgs}/nixos/lib/eval-config.nix { + modules = [ ${nixosConfig} ]; + }).config.nixpkgs.config + ''}"; + nixPath = [ + "vuizvui=${channelPath}" + "nixpkgs=${channelPath}/nixpkgs" + "nixos-config=${nixosConfig}" + rootChannelsPath + ] ++ optional config.vuizvui.enableGlobalNixpkgsConfig nixpkgsConfig; + in mkIf config.vuizvui.modifyNixPath (mkOverride 90 nixPath); }; } -- cgit 1.4.1