summary refs log tree commit diff
path: root/lib/systems/parse.nix
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2017-05-06 13:27:15 +0200
committerVladimír Čunát <vcunat@gmail.com>2017-05-06 13:28:07 +0200
commitb70924bd80918d153a5e2023afd7647ae7b24a12 (patch)
tree77213af020644bbcf909b66ab708f3d74cfa11b1 /lib/systems/parse.nix
parent37a48c91996cde06adebcd4988b89f6e5e7c79dd (diff)
downloadnixlib-b70924bd80918d153a5e2023afd7647ae7b24a12.tar
nixlib-b70924bd80918d153a5e2023afd7647ae7b24a12.tar.gz
nixlib-b70924bd80918d153a5e2023afd7647ae7b24a12.tar.bz2
nixlib-b70924bd80918d153a5e2023afd7647ae7b24a12.tar.lz
nixlib-b70924bd80918d153a5e2023afd7647ae7b24a12.tar.xz
nixlib-b70924bd80918d153a5e2023afd7647ae7b24a12.tar.zst
nixlib-b70924bd80918d153a5e2023afd7647ae7b24a12.zip
Revert "Merge pull request #25275 from Ericson2314/platform-normalize"
This reverts commit 2282a5774cd80567644a44d31585bf965a55f9ec, reversing
changes made to 14adea91566019549f33392d4710d9babd0108d7.

The lib tests are bloking nixpkgs-unstable, and I don't like debugging
it soon enough.
Diffstat (limited to 'lib/systems/parse.nix')
-rw-r--r--lib/systems/parse.nix58
1 files changed, 26 insertions, 32 deletions
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix
index 8f65a69b17ab..26744322e9e4 100644
--- a/lib/systems/parse.nix
+++ b/lib/systems/parse.nix
@@ -1,9 +1,5 @@
-# Define the list of system with their properties.
-#
-# See https://clang.llvm.org/docs/CrossCompilation.html and
-# http://llvm.org/docs/doxygen/html/Triple_8cpp_source.html especially
-# Triple::normalize. Parsing should essentially act as a more conservative
-# version of that last function.
+# Define the list of system with their properties.  Only systems tested for
+# Nixpkgs are listed below
 
 with import ../lists.nix;
 with import ../types.nix;
@@ -13,7 +9,7 @@ let
   lib = import ../default.nix;
   setTypesAssert = type: pred:
     mapAttrs (name: value:
-      assert pred value;
+      #assert pred value;
       setType type ({ inherit name; } // value));
   setTypes = type: setTypesAssert type (_: true);
 
@@ -27,6 +23,7 @@ rec {
     littleEndian = {};
   };
 
+
   isCpuType = isType "cpu-type";
   cpuTypes = with significantBytes; setTypesAssert "cpu-type"
     (x: elem x.bits [8 16 32 64 128]
@@ -50,7 +47,6 @@ rec {
   vendors = setTypes "vendor" {
     apple = {};
     pc = {};
-
     unknown = {};
   };
 
@@ -60,7 +56,6 @@ rec {
     elf = {};
     macho = {};
     pe = {};
-
     unknown = {};
   };
 
@@ -68,12 +63,15 @@ rec {
   kernelFamilies = setTypes "kernel-family" {
     bsd = {};
     unix = {};
+    windows-nt = {};
+    dos = {};
   };
 
   isKernel = x: isType "kernel" x;
   kernels = with execFormats; with kernelFamilies; setTypesAssert "kernel"
     (x: isExecFormat x.execFormat && all isKernelFamily (attrValues x.families))
   {
+    cygwin  = { execFormat = pe;      families = { inherit /*unix*/ windows-nt; }; };
     darwin  = { execFormat = macho;   families = { inherit unix; }; };
     freebsd = { execFormat = elf;     families = { inherit unix bsd; }; };
     linux   = { execFormat = elf;     families = { inherit unix; }; };
@@ -81,21 +79,18 @@ rec {
     none    = { execFormat = unknown; families = { inherit unix; }; };
     openbsd = { execFormat = elf;     families = { inherit unix bsd; }; };
     solaris = { execFormat = elf;     families = { inherit unix; }; };
-    windows = { execFormat = pe;      families = { }; };
-  } // { # aliases
-    win32 = kernels.windows;
+    win32   = { execFormat = pe;      families = { inherit dos; }; };
   };
 
+
   isAbi = isType "abi";
   abis = setTypes "abi" {
-    cygnus = {};
     gnu = {};
     msvc = {};
     eabi = {};
     androideabi = {};
     gnueabi = {};
     gnueabihf = {};
-
     unknown = {};
   };
 
@@ -114,25 +109,19 @@ rec {
   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; };
+  isWindows = s: matchAttrs { kernel = { families = { inherit (kernelFamilies) windows-nt; }; }; } s
+              || matchAttrs { kernel = { families = { inherit (kernelFamilies) dos; }; }; } s;
 
 
   mkSkeletonFromList = l: {
-    "2" = # We only do 2-part hacks for things Nix already supports
-      if elemAt l 1 == "cygwin"
-        then { cpu = elemAt l 0;                      kernel = "windows"; abi = "cygnus";    }
-      else   { cpu = elemAt l 0;                      kernel = elemAt l 1;                   };
+    "2" =    { cpu = elemAt l 0;                      kernel = elemAt l 1;                   };
+    "4" =    { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
     "3" = # Awkwards hacks, beware!
       if elemAt l 1 == "apple"
         then { cpu = elemAt l 0; vendor = "apple";    kernel = elemAt l 2;                   }
       else if (elemAt l 1 == "linux") || (elemAt l 2 == "gnu")
         then { cpu = elemAt l 0;                      kernel = elemAt l 1; abi = elemAt l 2; }
-      else if (elemAt l 2 == "mingw32") # autotools breaks on -gnu for window
-        then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows";  abi = "gnu"; }
       else throw "Target specification with 3 components is ambiguous";
-    "4" =    { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
   }.${toString (length l)}
     or (throw "system string has invalid number of hyphen-separated components");
 
@@ -145,10 +134,18 @@ rec {
                          , # Also inferred below
                            abi    ? assert false; null
                          } @ args: let
-    getCpu    = name: cpuTypes.${name} or (throw "Unknown CPU type: ${name}");
-    getVendor = name:  vendors.${name} or (throw "Unknown vendor: ${name}");
-    getKernel = name:  kernels.${name} or (throw "Unknown kernel: ${name}");
-    getAbi    = name:     abis.${name} or (throw "Unknown ABI: ${name}");
+    getCpu = name:
+      attrByPath [name] (throw "Unknown CPU type: ${name}")
+        cpuTypes;
+    getVendor = name:
+      attrByPath [name] (throw "Unknown vendor: ${name}")
+        vendors;
+    getKernel = name:
+      attrByPath [name] (throw "Unknown kernel: ${name}")
+        kernels;
+    getAbi = name:
+      attrByPath [name] (throw "Unknown ABI: ${name}")
+        abis;
 
     system = rec {
       cpu = getCpu args.cpu;
@@ -169,10 +166,7 @@ rec {
 
   mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s));
 
-  doubleFromSystem = { cpu, vendor, kernel, abi, ... }:
-    if vendor == kernels.windows && abi == abis.cygnus
-    then "${cpu.name}-cygwin"
-    else "${cpu.name}-${kernel.name}";
+  doubleFromSystem = { cpu, vendor, kernel, abi, ... }: "${cpu.name}-${kernel.name}";
 
   tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let
     optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}";