diff options
author | Shea Levy <shea@shealevy.com> | 2013-01-13 11:15:01 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2013-01-13 11:15:01 -0500 |
commit | 553e1b16f006d4b17dc0990a5efc693d06ea2805 (patch) | |
tree | ee297518c00b2d6023c744f8c1b5bc2aa20f3c66 | |
parent | 4dc4d1012352a97b440ce68681c9cb9643010a60 (diff) |
replace-dependency: Eelco has ruled, lowerCamelCase > dash-case :(
-rw-r--r-- | pkgs/build-support/replace-dependency.nix | 36 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 4 |
2 files changed, 20 insertions, 20 deletions
diff --git a/pkgs/build-support/replace-dependency.nix b/pkgs/build-support/replace-dependency.nix index 016845dd75484..098637b4f9b9d 100644 --- a/pkgs/build-support/replace-dependency.nix +++ b/pkgs/build-support/replace-dependency.nix @@ -8,16 +8,16 @@ # should be used. The old dependency and new dependency MUST have the same-length # name, and ideally should have close-to-identical directory layout. # -# Example: safe-firefox = replace-dependency { +# Example: safeFirefox = replaceDependency { # drv = firefox; -# old-dependency = glibc; -# new-dependency = overrideDerivation glibc (attrs: { +# oldDependency = glibc; +# newDependency = overrideDerivation glibc (attrs: { # patches = attrs.patches ++ [ ./fix-glibc-hole.patch ]; # }); # }; # This will rebuild glibc with your security patch, then copy over firefox # (and all of its dependencies) without rebuilding further. -{ drv, old-dependency, new-dependency }: +{ drv, oldDependency, newDependency }: with lib; @@ -45,17 +45,17 @@ let discard = builtins.unsafeDiscardStringContext; - old-storepath = builtins.storePath (discard (toString old-dependency)); + oldStorepath = builtins.storePath (discard (toString oldDependency)); - references-of = drv: getAttr (discard (toString drv)) references; + referencesOf = drv: getAttr (discard (toString drv)) references; - depends-on-old = drv: elem old-storepath (references-of drv) || - any depends-on-old (references-of drv); + dependsOnOld = drv: elem oldStorepath (referencesOf drv) || + any dependsOnOld (referencesOf drv); - drv-name = drv: + drvName = drv: discard (substring 33 (stringLength (builtins.baseNameOf drv)) (builtins.baseNameOf drv)); - rewrite-hashes = drv: hashes: runCommand (drv-name drv) { nixStore = "${nix}/bin/nix-store"; } '' + rewriteHashes = drv: hashes: runCommand (drvName drv) { nixStore = "${nix}/bin/nix-store"; } '' $nixStore --dump ${drv} | sed 's|${baseNameOf drv}|'$(basename $out)'|g' | sed -e ${ concatStringsSep " -e " (mapAttrsToList (name: value: "'s|${baseNameOf name}|${baseNameOf value}|g'" @@ -63,17 +63,17 @@ let } | $nixStore --restore $out ''; - rewritten-deps = listToAttrs [ {name = discard (toString old-dependency); value = new-dependency;} ]; + rewrittenDeps = listToAttrs [ {name = discard (toString oldDependency); value = newDependency;} ]; - rewritten-derivations = drv: - if depends-on-old drv + rewrittenDerivations = drv: + if dependsOnOld drv then listToAttrs [ { name = discard (toString drv); - value = rewrite-hashes drv (rewritten-deps // (fold (drv: acc: - (rewritten-derivations drv) // acc - ) {} (references-of drv))); + value = rewriteHashes drv (rewrittenDeps // (fold (drv: acc: + (rewrittenDerivations drv) // acc + ) {} (referencesOf drv))); } ] else {}; -in assert (stringLength (drv-name (toString old-dependency)) == stringLength (drv-name (toString new-dependency))); -getAttr (discard (toString drv)) (rewritten-derivations drv) +in assert (stringLength (drvName (toString oldDependency)) == stringLength (drvName (toString newDependency))); +getAttr (discard (toString drv)) (rewrittenDerivations drv) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6d8d385fd0220..44c92f09142cc 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -344,9 +344,9 @@ let inherit stdenv; }; - "replace-dependency" = if builtins ? langVersion then import ../build-support/replace-dependency.nix { + replaceDependency = import ../build-support/replace-dependency.nix { inherit runCommand nix lib; - } else args: throw "You must be using at least nix-1.2 to use replace-dependency"; + }; nukeReferences = callPackage ../build-support/nuke-references/default.nix { }; |