summary refs log tree commit diff
path: root/lib/systems
diff options
context:
space:
mode:
authorMatthew Bauer <matthew.bauer@obsidian.systems>2018-07-24 21:02:46 -0400
committerMatthew Bauer <mjbauer95@gmail.com>2018-07-28 19:54:09 -0400
commita22797d356f5c47428a9b7c74ee9334a24101fa8 (patch)
tree673d3b64ae0055647de3429d547f89221b834384 /lib/systems
parent96ce1e03a4a3a395b2874fb1e3bbfe3358ded4bb (diff)
downloadnixlib-a22797d356f5c47428a9b7c74ee9334a24101fa8.tar
nixlib-a22797d356f5c47428a9b7c74ee9334a24101fa8.tar.gz
nixlib-a22797d356f5c47428a9b7c74ee9334a24101fa8.tar.bz2
nixlib-a22797d356f5c47428a9b7c74ee9334a24101fa8.tar.lz
nixlib-a22797d356f5c47428a9b7c74ee9334a24101fa8.tar.xz
nixlib-a22797d356f5c47428a9b7c74ee9334a24101fa8.tar.zst
nixlib-a22797d356f5c47428a9b7c74ee9334a24101fa8.zip
systems: fix netbsd triple parsing
binutils expects x86_64-unknown-netbsd<version> (only 3 parts!). Any other combo seems to fail.

Also handle darwin versions similarly.

/cc @Ericson2314
Diffstat (limited to 'lib/systems')
-rw-r--r--lib/systems/parse.nix10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix
index 47841a9eba5c..b07396a9dfd7 100644
--- a/lib/systems/parse.nix
+++ b/lib/systems/parse.nix
@@ -18,6 +18,7 @@
 with lib.lists;
 with lib.types;
 with lib.attrsets;
+with lib.strings;
 with (import ./inspect.nix { inherit lib; }).predicates;
 
 let
@@ -179,9 +180,6 @@ rec {
   } // { # aliases
     # 'darwin' is the kernel for all of them. We choose macOS by default.
     darwin = kernels.macos;
-    # TODO(@Ericson2314): Handle these Darwin version suffixes more generally.
-    darwin10 = kernels.macos;
-    darwin14 = kernels.macos;
     watchos = kernels.ios;
     tvos = kernels.ios;
     win32 = kernels.windows;
@@ -269,6 +267,8 @@ rec {
         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 if hasPrefix "netbsd" (elemAt l 2)
+        then { cpu = elemAt l 0; vendor = elemAt l 1;    kernel = elemAt l 2;                }
       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)}
@@ -295,7 +295,9 @@ rec {
         else if isDarwin  parsed then vendors.apple
         else if isWindows parsed then vendors.pc
         else                     vendors.unknown;
-      kernel = getKernel args.kernel;
+      kernel = if hasPrefix "darwin" args.kernel      then getKernel "darwin"
+               else if hasPrefix "netbsd" args.kernel then getKernel "netbsd"
+               else                                   getKernel args.kernel;
       abi =
         /**/ if args ? abi       then getAbi args.abi
         else if isLinux   parsed then