summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorvolth <volth@webmaster.ms>2018-12-18 17:13:27 +0000
committerGitHub <noreply@github.com>2018-12-18 17:13:27 +0000
commitfed7914539d6afaae6bb6f18197d060a74944173 (patch)
tree7923f6246d22e9a93365debb4b9d3bea6b6349ec /lib
parentbb9557eb7ca623ac9c12bae1fe4f95c9e290d27d (diff)
parent1148ce1b601fd0e64088458014cecd08bc2b8e1e (diff)
downloadnixpkgs-fed7914539d6afaae6bb6f18197d060a74944173.tar
nixpkgs-fed7914539d6afaae6bb6f18197d060a74944173.tar.gz
nixpkgs-fed7914539d6afaae6bb6f18197d060a74944173.tar.bz2
nixpkgs-fed7914539d6afaae6bb6f18197d060a74944173.tar.lz
nixpkgs-fed7914539d6afaae6bb6f18197d060a74944173.tar.xz
nixpkgs-fed7914539d6afaae6bb6f18197d060a74944173.tar.zst
nixpkgs-fed7914539d6afaae6bb6f18197d060a74944173.zip
Merge branch 'staging' into make-perl-pathd
Diffstat (limited to 'lib')
-rw-r--r--lib/attrsets.nix9
-rw-r--r--lib/default.nix4
-rw-r--r--lib/fixed-points.nix10
-rw-r--r--lib/licenses.nix6
-rw-r--r--lib/systems/default.nix2
5 files changed, 28 insertions, 3 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix
index 2a1b866dbc5..d374d229f59 100644
--- a/lib/attrsets.nix
+++ b/lib/attrsets.nix
@@ -94,6 +94,15 @@ rec {
   attrValues = builtins.attrValues or (attrs: attrVals (attrNames attrs) attrs);
 
 
+  /* Given a set of attribute names, return the set of the corresponding
+     attributes from the given set.
+
+     Example:
+       getAttrs [ "a" "b" ] { a = 1; b = 2; c = 3; }
+       => { a = 1; b = 2; }
+  */
+  getAttrs = names: attrs: genAttrs names (name: attrs.${name});
+
   /* Collect each attribute named `attr' from a list of attribute
      sets.  Sets that don't contain the named attribute are ignored.
 
diff --git a/lib/default.nix b/lib/default.nix
index aff36d0e5c2..ee10ec1448b 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -61,10 +61,10 @@ let
       boolToString mergeAttrs flip mapNullable inNixShell min max
       importJSON warn info nixpkgsVersion version mod compare
       splitByAndCompare functionArgs setFunctionArgs isFunction;
-    inherit (fixedPoints) fix fix' extends composeExtensions
+    inherit (fixedPoints) fix fix' converge extends composeExtensions
       makeExtensible makeExtensibleWithCustomName;
     inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
-      getAttrFromPath attrVals attrValues catAttrs filterAttrs
+      getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
       filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
       mapAttrs' mapAttrsToList mapAttrsRecursive mapAttrsRecursiveCond
       genAttrs isDerivation toDerivation optionalAttrs
diff --git a/lib/fixed-points.nix b/lib/fixed-points.nix
index 7169c46fcbb..2f818c88de5 100644
--- a/lib/fixed-points.nix
+++ b/lib/fixed-points.nix
@@ -24,6 +24,16 @@ rec {
   # for a concrete example.
   fix' = f: let x = f x // { __unfix__ = f; }; in x;
 
+  # Return the fixpoint that `f` converges to when called recursively, starting
+  # with the input `x`.
+  #
+  #     nix-repl> converge (x: x / 2) 16
+  #     0
+  converge = f: x:
+    if (f x) == x
+    then x
+    else converge f (f x);
+
   # Modify the contents of an explicitly recursive attribute set in a way that
   # honors `self`-references. This is accomplished with a function
   #
diff --git a/lib/licenses.nix b/lib/licenses.nix
index ed91b5adedb..5ef60b51063 100644
--- a/lib/licenses.nix
+++ b/lib/licenses.nix
@@ -505,6 +505,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
     free = false;
   };
 
+  nasa13 = spdx {
+    spdxId = "NASA-1.3";
+    fullName = "NASA Open Source Agreement 1.3";
+    free = false;
+  };
+
   ncsa = spdx {
     spdxId = "NCSA";
     fullName  = "University of Illinois/NCSA Open Source License";
diff --git a/lib/systems/default.nix b/lib/systems/default.nix
index 25df5e17406..9b25052ab88 100644
--- a/lib/systems/default.nix
+++ b/lib/systems/default.nix
@@ -98,7 +98,7 @@ rec {
       in
         if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name &&
            (final.parsed.cpu.name == pkgs.stdenv.hostPlatform.parsed.cpu.name ||
-            (final.platform.isi686 && pkgs.stdenv.hostPlatform.isx86_64))
+            (final.isi686 && pkgs.stdenv.hostPlatform.isx86_64))
         then pkgs.runtimeShell
         else if final.isWindows
         then "${wine}/bin/${wine-name}"