about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-06-11 22:12:00 +0200
committeraszlig <aszlig@redmoonstudios.org>2015-06-11 22:12:00 +0200
commitd2ff1a90527671143bdca3218cfb37d0b15a6da8 (patch)
tree9a273f04ccd875e7e84f8ac3b9f5e7dc6f48ec8b /modules
parentdd75ac4355c185b6e4db33651aadc4c3669ad2c7 (diff)
profiles/common: Modify NIX_PATH for the channel.
That way we no longer need to rewrite anything from <nixpkgs> 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 <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules')
-rw-r--r--modules/profiles/common.nix51
1 files changed, 44 insertions, 7 deletions
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 &lt;nixpkgs&gt; points
+        to the path within the Nix channel instead of the
+        <literal>nixpkgs</literal> or <literal>nixos</literal> channel from the
+        root user.
+      '';
+    };
+
+    channelName = mkOption {
+      type = types.str;
+      default = "vuizvui";
+      description = ''
+        The channel name which is used to refer to <literal>vuizvui</literal>.
+      '';
+    };
+  };
+
+  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
+      ];
+    });
   };
 }