summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorLuca Bruno <lethalman88@gmail.com>2014-06-05 18:43:26 +0200
committerLuca Bruno <lethalman88@gmail.com>2014-06-06 21:17:31 +0200
commit66ddb1c3229e5e85b0596bca6a4d730b3247cd76 (patch)
tree8dccf26e84ab9f1c91f2ceeb3d7df7f1debb04c2 /nixos
parent12f06b3cc3f57a18cb285fd2274292faa6eb038d (diff)
downloadnixlib-66ddb1c3229e5e85b0596bca6a4d730b3247cd76.tar
nixlib-66ddb1c3229e5e85b0596bca6a4d730b3247cd76.tar.gz
nixlib-66ddb1c3229e5e85b0596bca6a4d730b3247cd76.tar.bz2
nixlib-66ddb1c3229e5e85b0596bca6a4d730b3247cd76.tar.lz
nixlib-66ddb1c3229e5e85b0596bca6a4d730b3247cd76.tar.xz
nixlib-66ddb1c3229e5e85b0596bca6a4d730b3247cd76.tar.zst
nixlib-66ddb1c3229e5e85b0596bca6a4d730b3247cd76.zip
Add system.replaceRuntimeDependencies to quickly replace system dependencies
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/system/activation/top-level.nix33
1 files changed, 32 insertions, 1 deletions
diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix
index b739ef693ce9..62999dceee39 100644
--- a/nixos/modules/system/activation/top-level.nix
+++ b/nixos/modules/system/activation/top-level.nix
@@ -95,7 +95,7 @@ let
   # kernel, systemd units, init scripts, etc.) as well as a script
   # `switch-to-configuration' that activates the configuration and
   # makes it bootable.
-  system = showWarnings (
+  baseSystem = showWarnings (
     if [] == failed then pkgs.stdenv.mkDerivation {
       name = "nixos-${config.system.nixosVersion}";
       preferLocalBuild = true;
@@ -118,6 +118,10 @@ let
       perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/lib/perl5/site_perl";
   } else throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failed)}");
 
+  # Replace runtime dependencies
+  system = fold ({ oldDependency, newDependency }: drv:
+      pkgs.replaceDependency { inherit oldDependency newDependency drv; }
+    ) baseSystem config.system.replaceRuntimeDependencies;
 
 in
 
@@ -184,6 +188,33 @@ in
       '';
     };
 
+    system.replaceRuntimeDependencies = mkOption {
+      default = [];
+      example = lib.literalExample "[ ({ original = pkgs.openssl; replacement = pkgs.callPackage /path/to/openssl { ... }; }) ]";
+      type = types.listOf (types.submodule (
+        { options, ... }: {
+          options.original = mkOption {
+            type = types.package;
+            description = "The original package to override.";
+          };
+
+          options.replacement = mkOption {
+            type = types.package;
+            description = "The replacement package.";
+          };
+        })
+      );
+      apply = map ({ original, replacement, ... }: {
+        oldDependency = original;
+        newDependency = replacement;
+      });
+      description = ''
+        List of packages to override without doing a full rebuild.
+        The original derivation and replacement derivation must have the same
+        name length, and ideally should have close-to-identical directory layout.
+      '';
+    };
+
   };