about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nix-env/nix-env.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 77b7881711e4..1a4d8ee5877d 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -482,8 +482,10 @@ static void installDerivations(Globals & globals,
          i != installedElems.end(); ++i)
     {
         DrvName drvName(i->name);
+        MetaInfo meta = i->queryMetaInfo(globals.state);
         if (!globals.preserveInstalled &&
-            newNames.find(drvName.name) != newNames.end())
+            newNames.find(drvName.name) != newNames.end() &&
+            meta["keep"] == "true")
             printMsg(lvlInfo,
                 format("replacing old `%1%'") % i->name);
         else
@@ -543,6 +545,9 @@ static void upgradeDerivations(Globals & globals,
     {
         DrvName drvName(i->name);
 
+        MetaInfo meta = i->queryMetaInfo(globals.state);
+        if (meta["keep"] == "true") continue;
+
         /* Find the derivation in the input Nix expression with the
            same name and satisfying the version constraints specified
            by upgradeType.  If there are multiple matches, take the