diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-09-11 15:24:55 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2019-09-16 22:14:45 +0000 |
commit | 89c4dccbd5f33f71808d4b1baafe619696af1162 (patch) | |
tree | fb1b8d3a2f171164a05d404ab2340cfb1a9d3e21 /nixpkgs/lib | |
parent | 8920a0e4d962a919238bab69ddc607d7f3396f70 (diff) | |
parent | e19054ab3cd5b7cc9a01d0efc71c8fe310541065 (diff) | |
download | nixlib-89c4dccbd5f33f71808d4b1baafe619696af1162.tar nixlib-89c4dccbd5f33f71808d4b1baafe619696af1162.tar.gz nixlib-89c4dccbd5f33f71808d4b1baafe619696af1162.tar.bz2 nixlib-89c4dccbd5f33f71808d4b1baafe619696af1162.tar.lz nixlib-89c4dccbd5f33f71808d4b1baafe619696af1162.tar.xz nixlib-89c4dccbd5f33f71808d4b1baafe619696af1162.tar.zst nixlib-89c4dccbd5f33f71808d4b1baafe619696af1162.zip |
Merge commit 'e19054ab3cd5b7cc9a01d0efc71c8fe310541065'
Diffstat (limited to 'nixpkgs/lib')
-rw-r--r-- | nixpkgs/lib/customisation.nix | 2 | ||||
-rw-r--r-- | nixpkgs/lib/deprecated.nix | 2 | ||||
-rw-r--r-- | nixpkgs/lib/kernel.nix | 2 | ||||
-rw-r--r-- | nixpkgs/lib/licenses.nix | 2 | ||||
-rw-r--r-- | nixpkgs/lib/lists.nix | 6 | ||||
-rw-r--r-- | nixpkgs/lib/sources.nix | 37 | ||||
-rw-r--r-- | nixpkgs/lib/systems/default.nix | 22 | ||||
-rw-r--r-- | nixpkgs/lib/systems/doubles.nix | 2 | ||||
-rw-r--r-- | nixpkgs/lib/systems/examples.nix | 18 | ||||
-rw-r--r-- | nixpkgs/lib/systems/parse.nix | 2 | ||||
-rw-r--r-- | nixpkgs/lib/systems/platforms.nix | 22 | ||||
-rw-r--r-- | nixpkgs/lib/types.nix | 8 | ||||
-rw-r--r-- | nixpkgs/lib/versions.nix | 2 |
13 files changed, 78 insertions, 49 deletions
diff --git a/nixpkgs/lib/customisation.nix b/nixpkgs/lib/customisation.nix index 1f5eb0d11e8b..3be36fcd719b 100644 --- a/nixpkgs/lib/customisation.nix +++ b/nixpkgs/lib/customisation.nix @@ -47,7 +47,7 @@ rec { /* `makeOverridable` takes a function from attribute set to attribute set and - injects `override` attibute which can be used to override arguments of + injects `override` attribute which can be used to override arguments of the function. nix-repl> x = {a, b}: { result = a + b; } diff --git a/nixpkgs/lib/deprecated.nix b/nixpkgs/lib/deprecated.nix index 15de50456612..155d6f0c3611 100644 --- a/nixpkgs/lib/deprecated.nix +++ b/nixpkgs/lib/deprecated.nix @@ -24,7 +24,7 @@ rec { let arg = (merger init (defaultMergeArg init x)); # now add the function with composed args already applied to the final attrs base = (setAttrMerge "passthru" {} (f arg) - ( z: z // rec { + ( z: z // { function = foldArgs merger f arg; args = (lib.attrByPath ["passthru" "args"] {} z) // x; } )); diff --git a/nixpkgs/lib/kernel.nix b/nixpkgs/lib/kernel.nix index 5923011774b1..36ea30838289 100644 --- a/nixpkgs/lib/kernel.nix +++ b/nixpkgs/lib/kernel.nix @@ -1,7 +1,7 @@ { lib, version }: with lib; -rec { +{ # Common patterns/legacy whenAtLeast = ver: mkIf (versionAtLeast version ver); whenOlder = ver: mkIf (versionOlder version ver); diff --git a/nixpkgs/lib/licenses.nix b/nixpkgs/lib/licenses.nix index c964060d2a5c..83e1ec7748d5 100644 --- a/nixpkgs/lib/licenses.nix +++ b/nixpkgs/lib/licenses.nix @@ -7,7 +7,7 @@ let in -lib.mapAttrs (n: v: v // { shortName = n; }) rec { +lib.mapAttrs (n: v: v // { shortName = n; }) { /* License identifiers from spdx.org where possible. * If you cannot find your license here, then look for a similar license or * add it to this list. The URL mentioned above is a good source for inspiration. diff --git a/nixpkgs/lib/lists.nix b/nixpkgs/lib/lists.nix index e4fcf959b60c..f9f30412770a 100644 --- a/nixpkgs/lib/lists.nix +++ b/nixpkgs/lib/lists.nix @@ -88,7 +88,7 @@ rec { /* Strict version of `foldl`. The difference is that evaluation is forced upon access. Usually used - with small whole results (in contract with lazily-generated list or large + with small whole results (in contrast with lazily-generated list or large lists where only a part is consumed.) Type: foldl' :: (b -> a -> b) -> b -> [a] -> b @@ -459,11 +459,11 @@ rec { if length list < 2 then # finish { result = list; } - else if dfsthis ? "cycle" + else if dfsthis ? cycle then # there's a cycle, starting from the current vertex, return it { cycle = reverseList ([ dfsthis.cycle ] ++ dfsthis.visited); inherit (dfsthis) loops; } - else if toporest ? "cycle" + else if toporest ? cycle then # there's a cycle somewhere else in the graph, return it toporest # Slow, but short. Can be made a bit faster with an explicit stack. diff --git a/nixpkgs/lib/sources.nix b/nixpkgs/lib/sources.nix index c4680087b245..51bcf5559e32 100644 --- a/nixpkgs/lib/sources.nix +++ b/nixpkgs/lib/sources.nix @@ -36,18 +36,47 @@ rec { # allowing you to chain multiple calls together without any # intermediate copies being put in the nix store. # - # lib.cleanSourceWith f (lib.cleanSourceWith g ./.) # Succeeds! - # builtins.filterSource f (builtins.filterSource g ./.) # Fails! - cleanSourceWith = { filter, src }: + # lib.cleanSourceWith { + # filter = f; + # src = lib.cleanSourceWith { + # filter = g; + # src = ./.; + # }; + # } + # # Succeeds! + # + # builtins.filterSource f (builtins.filterSource g ./.) + # # Fails! + # + # Parameters: + # + # src: A path or cleanSourceWith result to filter and/or rename. + # + # filter: A function (path -> type -> bool) + # Optional with default value: constant true (include everything) + # The function will be combined with the && operator such + # that src.filter is called lazily. + # For implementing a filter, see + # https://nixos.org/nix/manual/#builtin-filterSource + # + # name: Optional name to use as part of the store path. + # This defaults `src.name` or otherwise `baseNameOf src`. + # We recommend setting `name` whenever `src` is syntactically `./.`. + # Otherwise, you depend on `./.`'s name in the parent directory, + # which can cause inconsistent names, defeating caching. + # + cleanSourceWith = { filter ? _path: _type: true, src, name ? null }: let isFiltered = src ? _isLibCleanSourceWith; origSrc = if isFiltered then src.origSrc else src; filter' = if isFiltered then name: type: filter name type && src.filter name type else filter; + name' = if name != null then name else if isFiltered then src.name else baseNameOf src; in { inherit origSrc; filter = filter'; - outPath = builtins.filterSource filter' origSrc; + outPath = builtins.path { filter = filter'; path = origSrc; name = name'; }; _isLibCleanSourceWith = true; + name = name'; }; # Filter sources by a list of regular expressions. diff --git a/nixpkgs/lib/systems/default.nix b/nixpkgs/lib/systems/default.nix index 8aa413f53817..0c0cdf1f11b1 100644 --- a/nixpkgs/lib/systems/default.nix +++ b/nixpkgs/lib/systems/default.nix @@ -58,13 +58,13 @@ rec { uname = { # uname -s system = { - "linux" = "Linux"; - "windows" = "Windows"; - "darwin" = "Darwin"; - "netbsd" = "NetBSD"; - "freebsd" = "FreeBSD"; - "openbsd" = "OpenBSD"; - "wasi" = "Wasi"; + linux = "Linux"; + windows = "Windows"; + darwin = "Darwin"; + netbsd = "NetBSD"; + freebsd = "FreeBSD"; + openbsd = "OpenBSD"; + wasi = "Wasi"; }.${final.parsed.kernel.name} or null; # uname -p @@ -86,10 +86,10 @@ rec { else if final.isx86_64 then "x86_64" else if final.isx86 then "i386" else { - "powerpc" = "ppc"; - "powerpcle" = "ppc"; - "powerpc64" = "ppc64"; - "powerpc64le" = "ppc64le"; + powerpc = "ppc"; + powerpcle = "ppc"; + powerpc64 = "ppc64"; + powerpc64le = "ppc64le"; }.${final.parsed.cpu.name} or final.parsed.cpu.name; emulator = pkgs: let diff --git a/nixpkgs/lib/systems/doubles.nix b/nixpkgs/lib/systems/doubles.nix index 823f6a915d6e..8e02fcb5de0c 100644 --- a/nixpkgs/lib/systems/doubles.nix +++ b/nixpkgs/lib/systems/doubles.nix @@ -33,7 +33,7 @@ let filterDoubles = f: map parse.doubleFromSystem (lists.filter f allParsed); -in rec { +in { inherit all; none = []; diff --git a/nixpkgs/lib/systems/examples.nix b/nixpkgs/lib/systems/examples.nix index 4861fe634a02..511ae1979485 100644 --- a/nixpkgs/lib/systems/examples.nix +++ b/nixpkgs/lib/systems/examples.nix @@ -24,27 +24,27 @@ rec { platform = platforms.powernv; }; - sheevaplug = rec { + sheevaplug = { config = "armv5tel-unknown-linux-gnueabi"; platform = platforms.sheevaplug; }; - raspberryPi = rec { + raspberryPi = { config = "armv6l-unknown-linux-gnueabihf"; platform = platforms.raspberrypi; }; - armv7l-hf-multiplatform = rec { + armv7l-hf-multiplatform = { config = "armv7l-unknown-linux-gnueabihf"; platform = platforms.armv7l-hf-multiplatform; }; - aarch64-multiplatform = rec { + aarch64-multiplatform = { config = "aarch64-unknown-linux-gnu"; platform = platforms.aarch64-multiplatform; }; - armv7a-android-prebuilt = rec { + armv7a-android-prebuilt = { config = "armv7a-unknown-linux-androideabi"; sdkVer = "24"; ndkVer = "18b"; @@ -52,7 +52,7 @@ rec { useAndroidPrebuilt = true; }; - aarch64-android-prebuilt = rec { + aarch64-android-prebuilt = { config = "aarch64-unknown-linux-android"; sdkVer = "24"; ndkVer = "18b"; @@ -65,17 +65,17 @@ rec { inherit (platform.gcc) fpu; }; - pogoplug4 = rec { + pogoplug4 = { config = "armv5tel-unknown-linux-gnueabi"; platform = platforms.pogoplug4; }; - ben-nanonote = rec { + ben-nanonote = { config = "mipsel-unknown-linux-uclibc"; platform = platforms.ben_nanonote; }; - fuloongminipc = rec { + fuloongminipc = { config = "mipsel-unknown-linux-gnu"; platform = platforms.fuloong2f_n32; }; diff --git a/nixpkgs/lib/systems/parse.nix b/nixpkgs/lib/systems/parse.nix index 0c42689a9b13..5e12df32ffdd 100644 --- a/nixpkgs/lib/systems/parse.nix +++ b/nixpkgs/lib/systems/parse.nix @@ -408,7 +408,7 @@ rec { getKernel = name: kernels.${name} or (throw "Unknown kernel: ${name}"); getAbi = name: abis.${name} or (throw "Unknown ABI: ${name}"); - parsed = rec { + parsed = { cpu = getCpu args.cpu; vendor = /**/ if args ? vendor then getVendor args.vendor diff --git a/nixpkgs/lib/systems/platforms.nix b/nixpkgs/lib/systems/platforms.nix index a2b43c970a41..ab3cf1d54301 100644 --- a/nixpkgs/lib/systems/platforms.nix +++ b/nixpkgs/lib/systems/platforms.nix @@ -456,16 +456,16 @@ rec { }; selectBySystem = system: { - "i486-linux" = pc32; - "i586-linux" = pc32; - "i686-linux" = pc32; - "x86_64-linux" = pc64; - "armv5tel-linux" = sheevaplug; - "armv6l-linux" = raspberrypi; - "armv7a-linux" = armv7l-hf-multiplatform; - "armv7l-linux" = armv7l-hf-multiplatform; - "aarch64-linux" = aarch64-multiplatform; - "mipsel-linux" = fuloong2f_n32; - "powerpc64le-linux" = powernv; + i486-linux = pc32; + i586-linux = pc32; + i686-linux = pc32; + x86_64-linux = pc64; + armv5tel-linux = sheevaplug; + armv6l-linux = raspberrypi; + armv7a-linux = armv7l-hf-multiplatform; + armv7l-linux = armv7l-hf-multiplatform; + aarch64-linux = aarch64-multiplatform; + mipsel-linux = fuloong2f_n32; + powerpc64le-linux = powernv; }.${system} or pcBase; } diff --git a/nixpkgs/lib/types.nix b/nixpkgs/lib/types.nix index bcb5de0c379b..5e9a28ac4f0a 100644 --- a/nixpkgs/lib/types.nix +++ b/nixpkgs/lib/types.nix @@ -42,7 +42,7 @@ rec { # Default type functor defaultFunctor = name: { inherit name; - type = types."${name}" or null; + type = types.${name} or null; wrapped = null; payload = null; binOp = a: b: null; @@ -107,7 +107,7 @@ rec { merge = mergeEqualOption; }; - int = mkOptionType rec { + int = mkOptionType { name = "int"; description = "signed integer"; check = isInt; @@ -136,7 +136,7 @@ rec { sign = bit: range: ign (0 - (range / 2)) (range / 2 - 1) "signedInt${toString bit}" "${toString bit} bit signed integer"; - in rec { + in { /* An int with a fixed range. * * Example: @@ -172,7 +172,7 @@ rec { # Alias of u16 for a port number port = ints.u16; - float = mkOptionType rec { + float = mkOptionType { name = "float"; description = "floating point number"; check = isFloat; diff --git a/nixpkgs/lib/versions.nix b/nixpkgs/lib/versions.nix index 8f7f98ff5e1e..2c05445b3dd0 100644 --- a/nixpkgs/lib/versions.nix +++ b/nixpkgs/lib/versions.nix @@ -7,7 +7,7 @@ let in -rec { +{ /* Get the major version string from a string. |