about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-04-27T23·48+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-04-27T23·48+0000
commit89c1d2b202dccbf91c40586ac33efee515f7e93d (patch)
tree4db7330ddf5d3473e97421f645577ce89f3389d5
parenta46db5d013a5c3ab5b041824bfb935e5c042886c (diff)
* Package flag "keep" that prevents a package from being removed from
  a user environment by an install or upgrade action.  This is
  particularly useful if you have a version installed that you don't
  want to upgrade (e.g., because the newer versions are broken).
  Example:

    $ nix-env -u zapping --dry-run
    (dry run; not doing anything)
    upgrading `zapping-0.9.6' to `zapping-0.10cvs6'

    $ nix-env --set-flag keep true zapping

    $ nix-env -u zapping --dry-run
    (dry run; not doing anything)

  However, "-e" will still uninstall the package.  (Maybe we should
  require the keep flag to be explicitly set to false before it can be
  uninstalled.)

-rw-r--r--doc/manual/release-notes.xml4
-rw-r--r--src/nix-env/nix-env.cc7
2 files changed, 8 insertions, 3 deletions
diff --git a/doc/manual/release-notes.xml b/doc/manual/release-notes.xml
index 161643e52d4e..3b4525129de3 100644
--- a/doc/manual/release-notes.xml
+++ b/doc/manual/release-notes.xml
@@ -72,8 +72,8 @@
 
   <listitem><para>TODO: <command>nix-env</command>
   <option>--set-flag</option>.  Specific flags:
-  <literal>active</literal>,
-  <literal>priority</literal>.</para></listitem>
+  <literal>active</literal>, <literal>priority</literal>,
+  <literal>keep</literal>.</para></listitem>
   
 
   <listitem><para><command>nix-env -q</command> now has a flag
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