From d2ff1a90527671143bdca3218cfb37d0b15a6da8 Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 11 Jun 2015 22:12:00 +0200 Subject: profiles/common: Modify NIX_PATH for the channel. That way we no longer need to rewrite anything from anymore, because we only need to build one generation of the system and have the right system-wide NIX_PATH for vuizvui. For now however, let's test this properly before we can drop the rewrite of nixos-rebuild and friends. Signed-off-by: aszlig --- modules/profiles/common.nix | 51 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) (limited to 'modules/profiles/common.nix') diff --git a/modules/profiles/common.nix b/modules/profiles/common.nix index 9b04fb97..c9f67e7d 100644 --- a/modules/profiles/common.nix +++ b/modules/profiles/common.nix @@ -1,11 +1,48 @@ -{ config, ... }: +{ config, lib, ... }: + +with lib; { - nixpkgs.config.packageOverrides = pkgs: { - inherit (import ../../pkgs { - # We need to make sure to incorporate other package overrides, - # otherwise we are unable to override packages in vuizvui.*. - pkgs = pkgs // config.nixpkgs.config.packageOverrides pkgs; - }) vuizvui; + options.vuizvui = { + modifyNixPath = mkOption { + type = types.bool; + default = true; + description = '' + Whether to modify NIX_PATH for vuizvui, so that <nixpkgs> points + to the path within the Nix channel instead of the + nixpkgs or nixos channel from the + root user. + ''; + }; + + channelName = mkOption { + type = types.str; + default = "vuizvui"; + description = '' + The channel name which is used to refer to vuizvui. + ''; + }; + }; + + config = { + nixpkgs.config.packageOverrides = pkgs: { + inherit (import ../../pkgs { + # We need to make sure to incorporate other package overrides, + # otherwise we are unable to override packages in vuizvui.*. + pkgs = pkgs // config.nixpkgs.config.packageOverrides pkgs; + }) vuizvui; + }; + + environment.sessionVariables = let + rootChannelsPath = "/nix/var/nix/profiles/per-user/root/channels"; + channelPath = "${rootChannelsPath}/${config.vuizvui.channelName}"; + in mkIf config.vuizvui.modifyNixPath (mkOverride 90 { + NIX_PATH = [ + "vuizvui=${channelPath}" + "nixpkgs=${channelPath}/nixpkgs" + "nixos-config=/etc/nixos/configuration.nix" + rootChannelsPath + ]; + }); }; } -- cgit 1.4.1