diff options
author | John Ericson <Ericson2314@Yahoo.com> | 2017-05-21 13:39:23 -0400 |
---|---|---|
committer | John Ericson <Ericson2314@Yahoo.com> | 2017-05-22 00:25:02 -0400 |
commit | 2e7ec6fb702be66389405d48693b322565b27c69 (patch) | |
tree | 8fe252b2e58b2c7640f6c76d67707e5dc0bd9926 /lib/systems/parse.nix | |
parent | da8b2f1412c77ef50c90587d4b0f3a66e11892d6 (diff) | |
download | nixpkgs-2e7ec6fb702be66389405d48693b322565b27c69.tar nixpkgs-2e7ec6fb702be66389405d48693b322565b27c69.tar.gz nixpkgs-2e7ec6fb702be66389405d48693b322565b27c69.tar.bz2 nixpkgs-2e7ec6fb702be66389405d48693b322565b27c69.tar.lz nixpkgs-2e7ec6fb702be66389405d48693b322565b27c69.tar.xz nixpkgs-2e7ec6fb702be66389405d48693b322565b27c69.tar.zst nixpkgs-2e7ec6fb702be66389405d48693b322565b27c69.zip |
lib: Make platform predicates more ergonomic to use
`hostPlatform.isDarwin` instead of `lib.system.parse.isDarwin hostPlatform.parsed`
Diffstat (limited to 'lib/systems/parse.nix')
-rw-r--r-- | lib/systems/parse.nix | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index b9758f44fc1..b94caeb5758 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -8,6 +8,7 @@ with import ../lists.nix; with import ../types.nix; with import ../attrsets.nix; +with (import ./inspect.nix).predicates; let lib = import ../default.nix; @@ -109,19 +110,6 @@ rec { inherit cpu vendor kernel abi; }; - is64Bit = matchAttrs { cpu = { bits = 64; }; }; - is32Bit = matchAttrs { cpu = { bits = 32; }; }; - isi686 = matchAttrs { cpu = cpuTypes.i686; }; - isx86_64 = matchAttrs { cpu = cpuTypes.x86_64; }; - - isDarwin = matchAttrs { kernel = kernels.darwin; }; - isLinux = matchAttrs { kernel = kernels.linux; }; - isUnix = matchAttrs { kernel = { families = { inherit (kernelFamilies) unix; }; }; }; - isWindows = matchAttrs { kernel = kernels.windows; }; - isCygwin = matchAttrs { kernel = kernels.windows; abi = abis.cygnus; }; - isMinGW = matchAttrs { kernel = kernels.windows; abi = abis.gnu; }; - - mkSkeletonFromList = l: { "2" = # We only do 2-part hacks for things Nix already supports if elemAt l 1 == "cygwin" @@ -153,22 +141,22 @@ rec { getKernel = name: kernels.${name} or (throw "Unknown kernel: ${name}"); getAbi = name: abis.${name} or (throw "Unknown ABI: ${name}"); - system = rec { + parsed = rec { cpu = getCpu args.cpu; vendor = /**/ if args ? vendor then getVendor args.vendor - else if isDarwin system then vendors.apple - else if isWindows system then vendors.pc + else if isDarwin parsed then vendors.apple + else if isWindows parsed then vendors.pc else vendors.unknown; kernel = getKernel args.kernel; abi = /**/ if args ? abi then getAbi args.abi - else if isLinux system then abis.gnu - else if isWindows system then abis.gnu + else if isLinux parsed then abis.gnu + else if isWindows parsed then abis.gnu else abis.unknown; }; - in mkSystem system; + in mkSystem parsed; mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s)); |