summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2020-09-10 23:24:26 -0500
committerGitHub <noreply@github.com>2020-09-10 23:24:26 -0500
commit86d8c55470a0100e98b7c453c1cac16bc560e6f0 (patch)
tree5b993e0cc3e13e6f5e6d831f9ab7ef40607a2044 /lib
parent95eabdfd5f6197c83e9e5f53ddb65dbbea3c13fd (diff)
parent61517de024cc9e61c18f2434656c18067a2d68a4 (diff)
Merge branch 'staging' into ios-13
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix2
-rw-r--r--lib/generators.nix6
-rw-r--r--lib/licenses.nix48
-rw-r--r--lib/modules.nix165
-rw-r--r--lib/sources.nix10
-rw-r--r--lib/strings.nix33
-rw-r--r--lib/systems/architectures.nix77
-rw-r--r--lib/systems/default.nix5
-rw-r--r--lib/systems/doubles.nix5
-rw-r--r--lib/systems/examples.nix13
-rw-r--r--lib/systems/inspect.nix3
-rw-r--r--lib/systems/parse.nix3
-rw-r--r--lib/tests/misc.nix10
-rwxr-xr-xlib/tests/modules.sh23
-rw-r--r--lib/tests/modules/define-option-dependently.nix2
-rw-r--r--lib/tests/modules/define-value-string-properties.nix12
-rw-r--r--lib/tests/modules/freeform-attrsOf.nix3
-rw-r--r--lib/tests/modules/freeform-lazyAttrsOf.nix3
-rw-r--r--lib/tests/modules/freeform-nested.nix7
-rw-r--r--lib/tests/modules/freeform-str-dep-unstr.nix8
-rw-r--r--lib/tests/modules/freeform-unstr-dep-str.nix8
-rw-r--r--lib/tests/release.nix1
-rw-r--r--lib/tests/systems.nix11
-rw-r--r--lib/trivial.nix51
-rw-r--r--lib/types.nix123
25 files changed, 447 insertions, 185 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 7387e9d9f1ff..43b9ab5930c4 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -67,7 +67,7 @@ let
inherit (trivial) id const pipe concat or and bitAnd bitOr bitXor
bitNot boolToString mergeAttrs flip mapNullable inNixShell min max
importJSON warn info showWarnings nixpkgsVersion version mod compare
- splitByAndCompare functionArgs setFunctionArgs isFunction;
+ splitByAndCompare functionArgs setFunctionArgs isFunction toHexString toBaseDigits;
inherit (fixedPoints) fix fix' converge extends composeExtensions
makeExtensible makeExtensibleWithCustomName;
inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
diff --git a/lib/generators.nix b/lib/generators.nix
index efe6ea6031d3..abd237eb7d37 100644
--- a/lib/generators.nix
+++ b/lib/generators.nix
@@ -48,8 +48,10 @@ rec {
else if isAttrs v then err "attrsets" v
# functions can’t be printed of course
else if isFunction v then err "functions" v
- # let’s not talk about floats. There is no sensible `toString` for them.
- else if isFloat v then err "floats" v
+ # Floats currently can't be converted to precise strings,
+ # condition warning on nix version once this isn't a problem anymore
+ # See https://github.com/NixOS/nix/pull/3480
+ else if isFloat v then libStr.floatToString v
else err "this value is" (toString v);
diff --git a/lib/licenses.nix b/lib/licenses.nix
index ed4d80fffac6..ee11966b0d53 100644
--- a/lib/licenses.nix
+++ b/lib/licenses.nix
@@ -28,7 +28,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = "Academic Free License v3.0";
};
- agpl3 = spdx {
+ agpl3Only = spdx {
spdxId = "AGPL-3.0-only";
fullName = "GNU Affero General Public License v3.0 only";
};
@@ -85,6 +85,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = ''Beerware License'';
};
+ blueOak100 = spdx {
+ spdxId = "BlueOak-1.0.0";
+ fullName = "Blue Oak Model License 1.0.0";
+ };
+
bsd0 = spdx {
spdxId = "0BSD";
fullName = "BSD Zero Clause License";
@@ -110,6 +115,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = ''BSD 4-clause "Original" or "Old" License'';
};
+ bsdProtection = spdx {
+ spdxId = "BSD-Protection";
+ fullName = "BSD Protection License";
+ };
+
bsl11 = {
fullName = "Business Source License 1.1";
url = "https://mariadb.com/bsl11";
@@ -281,12 +291,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = "European Union Public License 1.2";
};
- fdl11 = spdx {
+ fdl11Only = spdx {
spdxId = "GFDL-1.1-only";
fullName = "GNU Free Documentation License v1.1 only";
};
- fdl12 = spdx {
+ fdl12Only = spdx {
spdxId = "GFDL-1.2-only";
fullName = "GNU Free Documentation License v1.2 only";
};
@@ -296,7 +306,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = "GNU Free Documentation License v1.2 or later";
};
- fdl13 = spdx {
+ fdl13Only = spdx {
spdxId = "GFDL-1.3-only";
fullName = "GNU Free Documentation License v1.3 only";
};
@@ -327,7 +337,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
free = false;
};
- gpl1 = spdx {
+ gpl1Only = spdx {
spdxId = "GPL-1.0-only";
fullName = "GNU General Public License v1.0 only";
};
@@ -337,7 +347,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = "GNU General Public License v1.0 or later";
};
- gpl2 = spdx {
+ gpl2Only = spdx {
spdxId = "GPL-2.0-only";
fullName = "GNU General Public License v2.0 only";
};
@@ -362,7 +372,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = "GNU General Public License v2.0 or later";
};
- gpl3 = spdx {
+ gpl3Only = spdx {
spdxId = "GPL-3.0-only";
fullName = "GNU General Public License v3.0 only";
};
@@ -426,6 +436,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
};
# Proprietary binaries; free to redistribute without modification.
+ databricks = {
+ fullName = "Databricks Proprietary License";
+ url = "https://pypi.org/project/databricks-connect";
+ free = false;
+ };
+
issl = {
fullName = "Intel Simplified Software License";
url = "https://software.intel.com/en-us/license/intel-simplified-software-license";
@@ -437,7 +453,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = "JasPer License";
};
- lgpl2 = spdx {
+ lgpl2Only = spdx {
spdxId = "LGPL-2.0-only";
fullName = "GNU Library General Public License v2 only";
};
@@ -447,7 +463,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = "GNU Library General Public License v2 or later";
};
- lgpl21 = spdx {
+ lgpl21Only = spdx {
spdxId = "LGPL-2.1-only";
fullName = "GNU Lesser General Public License v2.1 only";
};
@@ -457,7 +473,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = "GNU Lesser General Public License v2.1 or later";
};
- lgpl3 = spdx {
+ lgpl3Only = spdx {
spdxId = "LGPL-3.0-only";
fullName = "GNU Lesser General Public License v3.0 only";
};
@@ -782,4 +798,16 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
spdxId = "ZPL-2.1";
fullName = "Zope Public License 2.1";
};
+} // {
+ # TODO: remove legacy aliases
+ agpl3 = lib.licenses.agpl3Only;
+ fdl11 = lib.licenses.fdl11Only;
+ fdl12 = lib.licenses.fdl12Only;
+ fdl13 = lib.licenses.fdl13Only;
+ gpl1 = lib.licenses.gpl1Only;
+ gpl2 = lib.licenses.gpl2Only;
+ gpl3 = lib.licenses.gpl3Only;
+ lgpl2 = lib.licenses.lgpl2Only;
+ lgpl21 = lib.licenses.lgpl21Only;
+ lgpl3 = lib.licenses.lgpl3Only;
}
diff --git a/lib/modules.nix b/lib/modules.nix
index c18fec66c705..decb96ffe111 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -58,6 +58,23 @@ rec {
default = check;
description = "Whether to check whether all option definitions have matching declarations.";
};
+
+ _module.freeformType = mkOption {
+ # Disallow merging for now, but could be implemented nicely with a `types.optionType`
+ type = types.nullOr (types.uniq types.attrs);
+ internal = true;
+ default = null;
+ description = ''
+ If set, merge all definitions that don't have an associated option
+ together using this type. The result then gets combined with the
+ values of all declared options to produce the final <literal>
+ config</literal> value.
+
+ If this is <literal>null</literal>, definitions without an option
+ will throw an error unless <option>_module.check</option> is
+ turned off.
+ '';
+ };
};
config = {
@@ -65,35 +82,55 @@ rec {
};
};
- collected = collectModules
- (specialArgs.modulesPath or "")
- (modules ++ [ internalModule ])
- ({ inherit config options lib; } // specialArgs);
-
- options = mergeModules prefix (reverseList collected);
-
- # Traverse options and extract the option values into the final
- # config set. At the same time, check whether all option
- # definitions have matching declarations.
- # !!! _module.check's value can't depend on any other config values
- # without an infinite recursion. One way around this is to make the
- # 'config' passed around to the modules be unconditionally unchecked,
- # and only do the check in 'result'.
- config = yieldConfig prefix options;
- yieldConfig = prefix: set:
- let res = removeAttrs (mapAttrs (n: v:
- if isOption v then v.value
- else yieldConfig (prefix ++ [n]) v) set) ["_definedNames"];
- in
- if options._module.check.value && set ? _definedNames then
- foldl' (res: m:
- foldl' (res: name:
- if set ? ${name} then res else throw "The option `${showOption (prefix ++ [name])}' defined in `${m.file}' does not exist.")
- res m.names)
- res set._definedNames
- else
- res;
- result = {
+ merged =
+ let collected = collectModules
+ (specialArgs.modulesPath or "")
+ (modules ++ [ internalModule ])
+ ({ inherit lib options config; } // specialArgs);
+ in mergeModules prefix (reverseList collected);
+
+ options = merged.matchedOptions;
+
+ config =
+ let
+
+ # For definitions that have an associated option
+ declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
+
+ # If freeformType is set, this is for definitions that don't have an associated option
+ freeformConfig =
+ let
+ defs = map (def: {
+ file = def.file;
+ value = setAttrByPath def.prefix def.value;
+ }) merged.unmatchedDefns;
+ in if defs == [] then {}
+ else declaredConfig._module.freeformType.merge prefix defs;
+
+ in if declaredConfig._module.freeformType == null then declaredConfig
+ # Because all definitions that had an associated option ended in
+ # declaredConfig, freeformConfig can only contain the non-option
+ # paths, meaning recursiveUpdate will never override any value
+ else recursiveUpdate freeformConfig declaredConfig;
+
+ checkUnmatched =
+ if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
+ let
+ firstDef = head merged.unmatchedDefns;
+ baseMsg = "The option `${showOption (prefix ++ firstDef.prefix)}' defined in `${firstDef.file}' does not exist.";
+ in
+ if attrNames options == [ "_module" ]
+ then throw ''
+ ${baseMsg}
+
+ However there are no options defined in `${showOption prefix}'. Are you sure you've
+ declared your options properly? This can happen if you e.g. declared your options in `types.submodule'
+ under `config' rather than `options'.
+ ''
+ else throw baseMsg
+ else null;
+
+ result = builtins.seq checkUnmatched {
inherit options;
config = removeAttrs config [ "_module" ];
inherit (config) _module;
@@ -174,12 +211,16 @@ rec {
/* Massage a module into canonical form, that is, a set consisting
of ‘options’, ‘config’ and ‘imports’ attributes. */
unifyModuleSyntax = file: key: m:
- let addMeta = config: if m ? meta
- then mkMerge [ config { meta = m.meta; } ]
- else config;
+ let
+ addMeta = config: if m ? meta
+ then mkMerge [ config { meta = m.meta; } ]
+ else config;
+ addFreeformType = config: if m ? freeformType
+ then mkMerge [ config { _module.freeformType = m.freeformType; } ]
+ else config;
in
if m ? config || m ? options then
- let badAttrs = removeAttrs m ["_file" "key" "disabledModules" "imports" "options" "config" "meta"]; in
+ let badAttrs = removeAttrs m ["_file" "key" "disabledModules" "imports" "options" "config" "meta" "freeformType"]; in
if badAttrs != {} then
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: ${toString (attrNames badAttrs)}) into the explicit `config' attribute."
else
@@ -188,7 +229,7 @@ rec {
disabledModules = m.disabledModules or [];
imports = m.imports or [];
options = m.options or {};
- config = addMeta (m.config or {});
+ config = addFreeformType (addMeta (m.config or {}));
}
else
{ _file = m._file or file;
@@ -196,7 +237,7 @@ rec {
disabledModules = m.disabledModules or [];
imports = m.require or [] ++ m.imports or [];
options = {};
- config = addMeta (removeAttrs m ["_file" "key" "disabledModules" "require" "imports"]);
+ config = addFreeformType (addMeta (removeAttrs m ["_file" "key" "disabledModules" "require" "imports" "freeformType"]));
};
applyIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then
@@ -233,7 +274,23 @@ rec {
declarations in all modules, combining them into a single set.
At the same time, for each option declaration, it will merge the
corresponding option definitions in all machines, returning them
- in the ‘value’ attribute of each option. */
+ in the ‘value’ attribute of each option.
+
+ This returns a set like
+ {
+ # A recursive set of options along with their final values
+ matchedOptions = {
+ foo = { _type = "option"; value = "option value of foo"; ... };
+ bar.baz = { _type = "option"; value = "option value of bar.baz"; ... };
+ ...
+ };
+ # A list of definitions that weren't matched by any option
+ unmatchedDefns = [
+ { file = "file.nix"; prefix = [ "qux" ]; value = "qux"; }
+ ...
+ ];
+ }
+ */
mergeModules = prefix: modules:
mergeModules' prefix modules
(concatMap (m: map (config: { file = m._file; inherit config; }) (pushDownProperties m.config)) modules);
@@ -280,9 +337,9 @@ rec {
defnsByName' = byName "config" (module: value:
[{ inherit (module) file; inherit value; }]
) configs;
- in
- (flip mapAttrs declsByName (name: decls:
- # We're descending into attribute ‘name’.
+
+ resultsByName = flip mapAttrs declsByName (name: decls:
+ # We're descending into attribute ‘name’.
let
loc = prefix ++ [name];
defns = defnsByName.${name} or [];
@@ -291,7 +348,10 @@ rec {
in
if nrOptions == length decls then
let opt = fixupOptionType loc (mergeOptionDecls loc decls);
- in evalOptionValue loc opt defns'
+ in {
+ matchedOptions = evalOptionValue loc opt defns';
+ unmatchedDefns = [];
+ }
else if nrOptions != 0 then
let
firstOption = findFirst (m: isOption m.options) "" decls;
@@ -299,9 +359,27 @@ rec {
in
throw "The option `${showOption loc}' in `${firstOption._file}' is a prefix of options in `${firstNonOption._file}'."
else
- mergeModules' loc decls defns
- ))
- // { _definedNames = map (m: { inherit (m) file; names = attrNames m.config; }) configs; };
+ mergeModules' loc decls defns);
+
+ matchedOptions = mapAttrs (n: v: v.matchedOptions) resultsByName;
+
+ # an attrset 'name' => list of unmatched definitions for 'name'
+ unmatchedDefnsByName =
+ # Propagate all unmatched definitions from nested option sets
+ mapAttrs (n: v: v.unmatchedDefns) resultsByName
+ # Plus the definitions for the current prefix that don't have a matching option
+ // removeAttrs defnsByName' (attrNames matchedOptions);
+ in {
+ inherit matchedOptions;
+
+ # Transforms unmatchedDefnsByName into a list of definitions
+ unmatchedDefns = concatLists (mapAttrsToList (name: defs:
+ map (def: def // {
+ # Set this so we know when the definition first left unmatched territory
+ prefix = [name] ++ (def.prefix or []);
+ }) defs
+ ) unmatchedDefnsByName);
+ };
/* Merge multiple option declarations into a single declaration. In
general, there should be only one declaration of each option.
@@ -535,7 +613,6 @@ rec {
if tp.name == "option set" || tp.name == "submodule" then
throw "The option ${showOption loc} uses submodules without a wrapping type, in ${showFiles opt.declarations}."
else if optionSetIn "attrsOf" then types.attrsOf (types.submodule options)
- else if optionSetIn "loaOf" then types.loaOf (types.submodule options)
else if optionSetIn "listOf" then types.listOf (types.submodule options)
else if optionSetIn "nullOr" then types.nullOr (types.submodule options)
else tp;
diff --git a/lib/sources.nix b/lib/sources.nix
index ed9bce485300..776fcc32052b 100644
--- a/lib/sources.nix
+++ b/lib/sources.nix
@@ -145,10 +145,14 @@ rec {
# packed-refs file, so we have to grep through it:
then
let fileContent = readFile packedRefsName;
- matchRef = match (".*\n([^\n ]*) " + file + "\n.*") fileContent;
- in if matchRef == null
+ matchRef = builtins.match "([a-z0-9]+) ${file}";
+ isRef = s: builtins.isString s && (matchRef s) != null;
+ # there is a bug in libstdc++ leading to stackoverflow for long strings:
+ # https://github.com/NixOS/nix/issues/2147#issuecomment-659868795
+ refs = builtins.filter isRef (builtins.split "\n" fileContent);
+ in if refs == []
then throw ("Could not find " + file + " in " + packedRefsName)
- else lib.head matchRef
+ else lib.head (matchRef (lib.head refs))
else throw ("Not a .git directory: " + path);
in readCommitFromFile "HEAD";
diff --git a/lib/strings.nix b/lib/strings.nix
index 74e3eaa0722d..9fa9f023561e 100644
--- a/lib/strings.nix
+++ b/lib/strings.nix
@@ -612,6 +612,22 @@ rec {
*/
fixedWidthNumber = width: n: fixedWidthString width "0" (toString n);
+ /* Convert a float to a string, but emit a warning when precision is lost
+ during the conversion
+
+ Example:
+ floatToString 0.000001
+ => "0.000001"
+ floatToString 0.0000001
+ => trace: warning: Imprecise conversion from float to string 0.000000
+ "0.000000"
+ */
+ floatToString = float: let
+ result = toString float;
+ precise = float == builtins.fromJSON result;
+ in if precise then result
+ else lib.warn "Imprecise conversion from float to string ${result}" result;
+
/* Check whether a value can be coerced to a string */
isCoercibleToString = x:
builtins.elem (builtins.typeOf x) [ "path" "string" "null" "int" "float" "bool" ] ||
@@ -673,14 +689,15 @@ rec {
"/prefix/nix-profiles-library-paths.patch"
"/prefix/compose-search-path.patch" ]
*/
- readPathsFromFile = rootPath: file:
- let
- lines = lib.splitString "\n" (builtins.readFile file);
- removeComments = lib.filter (line: line != "" && !(lib.hasPrefix "#" line));
- relativePaths = removeComments lines;
- absolutePaths = builtins.map (path: rootPath + "/${path}") relativePaths;
- in
- absolutePaths;
+ readPathsFromFile = lib.warn "lib.readPathsFromFile is deprecated, use a list instead"
+ (rootPath: file:
+ let
+ lines = lib.splitString "\n" (builtins.readFile file);
+ removeComments = lib.filter (line: line != "" && !(lib.hasPrefix "#" line));
+ relativePaths = removeComments lines;
+ absolutePaths = builtins.map (path: rootPath + "/${path}") relativePaths;
+ in
+ absolutePaths);
/* Read the contents of a file removing the trailing \n
diff --git a/lib/systems/architectures.nix b/lib/systems/architectures.nix
new file mode 100644
index 000000000000..9d1c29fd9f0b
--- /dev/null
+++ b/lib/systems/architectures.nix
@@ -0,0 +1,77 @@
+{ lib }:
+
+rec {
+ # platform.gcc.arch to its features (as in /proc/cpuinfo)
+ features = {
+ default = [ ];
+ # x86_64 Intel
+ westmere = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" ];
+ sandybridge = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" ];
+ ivybridge = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" ];
+ haswell = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "fma" ];
+ broadwell = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "fma" ];
+ skylake = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "fma" ];
+ skylake-avx512 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" "avx2" "avx512" "fma" ];
+ # x86_64 AMD
+ btver1 = [ "sse3" "ssse3" "sse4_1" "sse4_2" ];
+ btver2 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" ];
+ bdver1 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "fma" "fma4" ];
+ bdver2 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "fma" "fma4" ];
+ bdver3 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "fma" "fma4" ];
+ bdver4 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "avx2" "fma" "fma4" ];
+ znver1 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "avx2" "fma" ];
+ znver2 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "avx2" "fma" ];
+ # other
+ armv5te = [ ];
+ armv6 = [ ];
+ armv7-a = [ ];
+ armv8-a = [ ];
+ mips32 = [ ];
+ loongson2f = [ ];
+ };
+
+ # a superior CPU has all the features of an inferior and is able to build and test code for it
+ inferiors = {
+ # x86_64 Intel
+ default = [ ];
+ westmere = [ ];
+ sandybridge = [ "westmere" ] ++ inferiors.westmere;
+ ivybridge = [ "sandybridge" ] ++ inferiors.sandybridge;
+ haswell = [ "ivybridge" ] ++ inferiors.ivybridge;
+ broadwell = [ "haswell" ] ++ inferiors.haswell;
+ skylake = [ "broadwell" ] ++ inferiors.broadwell;
+ skylake-avx512 = [ "skylake" ] ++ inferiors.skylake;
+ # x86_64 AMD
+ btver1 = [ ];
+ btver2 = [ ]; # TODO: fill this (need testing)
+ bdver1 = [ ]; # TODO: fill this (need testing)
+ bdver2 = [ ]; # TODO: fill this (need testing)
+ bdver3 = [ ]; # TODO: fill this (need testing)
+ bdver4 = [ ]; # TODO: fill this (need testing)
+ znver1 = [ ]; # TODO: fill this (need testing)
+ znver2 = [ ]; # TODO: fill this (need testing)
+ # other
+ armv5te = [ ];
+ armv6 = [ ];
+ armv7-a = [ ];
+ armv8-a = [ ];
+ mips32 = [ ];
+ loongson2f = [ ];
+ };
+
+ predicates = let
+ featureSupport = feature: x: builtins.elem feature features.${x};
+ in {
+ sse3Support = featureSupport "sse3";
+ ssse3Support = featureSupport "ssse3";
+ sse4_1Support = featureSupport "sse4_1";
+ sse4_2Support = featureSupport "sse4_2";
+ sse4_aSupport = featureSupport "sse4a";
+ avxSupport = featureSupport "avx";
+ avx2Support = featureSupport "avx2";
+ avx512Support = featureSupport "avx512";
+ aesSupport = featureSupport "aes";
+ fmaSupport = featureSupport "fma";
+ fma4Support = featureSupport "fma4";
+ };
+}
diff --git a/lib/systems/default.nix b/lib/systems/default.nix
index 210674cc6399..9939743157e7 100644
--- a/lib/systems/default.nix
+++ b/lib/systems/default.nix
@@ -7,6 +7,7 @@ rec {
inspect = import ./inspect.nix { inherit lib; };
platforms = import ./platforms.nix { inherit lib; };
examples = import ./examples.nix { inherit lib; };
+ architectures = import ./architectures.nix { inherit lib; };
# Elaborate a `localSystem` or `crossSystem` so that it contains everything
# necessary.
@@ -32,6 +33,7 @@ rec {
/**/ if final.isDarwin then "libSystem"
else if final.isMinGW then "msvcrt"
else if final.isWasi then "wasilibc"
+ else if final.isRedox then "relibc"
else if final.isMusl then "musl"
else if final.isUClibc then "uclibc"
else if final.isAndroid then "bionic"
@@ -65,6 +67,7 @@ rec {
freebsd = "FreeBSD";
openbsd = "OpenBSD";
wasi = "Wasi";
+ redox = "Redox";
genode = "Genode";
}.${final.parsed.kernel.name} or null;
@@ -74,6 +77,7 @@ rec {
# uname -r
release = null;
};
+ isStatic = final.isWasm || final.isRedox;
kernelArch =
if final.isAarch32 then "arm"
@@ -123,6 +127,7 @@ rec {
else throw "Don't know how to run ${final.config} executables.";
} // mapAttrs (n: v: v final.parsed) inspect.predicates
+ // mapAttrs (n: v: v final.platform.gcc.arch or "default") architectures.predicates
// args;
in assert final.useAndroidPrebuilt -> final.isAndroid;
assert lib.foldl
diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix
index a839b3d3d573..fb7d722e737e 100644
--- a/lib/systems/doubles.nix
+++ b/lib/systems/doubles.nix
@@ -22,6 +22,8 @@ let
"wasm64-wasi" "wasm32-wasi"
+ "x86_64-redox"
+
"powerpc64le-linux"
"riscv32-linux" "riscv64-linux"
@@ -36,7 +38,7 @@ let
"js-ghcjs"
- "aarch64-genode" "x86_64-genode"
+ "aarch64-genode" "i686-genode" "x86_64-genode"
];
allParsed = map parse.mkSystemFromString all;
@@ -69,6 +71,7 @@ in {
openbsd = filterDoubles predicates.isOpenBSD;
unix = filterDoubles predicates.isUnix;
wasi = filterDoubles predicates.isWasi;
+ redox = filterDoubles predicates.isRedox;
windows = filterDoubles predicates.isWindows;
genode = filterDoubles predicates.isGenode;
diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix
index 3b32130f388a..5b90fdca5244 100644
--- a/lib/systems/examples.nix
+++ b/lib/systems/examples.nix
@@ -46,7 +46,7 @@ rec {
armv7a-android-prebuilt = {
config = "armv7a-unknown-linux-androideabi";
- sdkVer = "24";
+ sdkVer = "29";
ndkVer = "18b";
platform = platforms.armv7a-android;
useAndroidPrebuilt = true;
@@ -54,7 +54,7 @@ rec {
aarch64-android-prebuilt = {
config = "aarch64-unknown-linux-android";
- sdkVer = "24";
+ sdkVer = "29";
ndkVer = "18b";
platform = platforms.aarch64-multiplatform;
useAndroidPrebuilt = true;
@@ -164,6 +164,15 @@ rec {
};
#
+ # Redox
+ #
+
+ x86_64-unknown-redox = {
+ config = "x86_64-unknown-redox";
+ libc = "relibc";
+ };
+
+ #
# Darwin
#
diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix
index 90a1fb6d80c2..8fa630572509 100644
--- a/lib/systems/inspect.nix
+++ b/lib/systems/inspect.nix
@@ -33,7 +33,7 @@ rec {
isBSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
isDarwin = { kernel = { families = { inherit (kernelFamilies) darwin; }; }; };
- isUnix = [ isBSD isDarwin isLinux isSunOS isCygwin ];
+ isUnix = [ isBSD isDarwin isLinux isSunOS isCygwin isRedox ];
isMacOS = { kernel = kernels.macos; };
isiOS = { kernel = kernels.ios; };
@@ -46,6 +46,7 @@ rec {
isCygwin = { kernel = kernels.windows; abi = abis.cygnus; };
isMinGW = { kernel = kernels.windows; abi = abis.gnu; };
isWasi = { kernel = kernels.wasi; };
+ isRedox = { kernel = kernels.redox; };
isGhcjs = { kernel = kernels.ghcjs; };
isGenode = { kernel = kernels.genode; };
isNone = { kernel = kernels.none; };
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix
index 648e7c270240..6bd44a007466 100644
--- a/lib/systems/parse.nix
+++ b/lib/systems/parse.nix
@@ -277,6 +277,7 @@ rec {
openbsd = { execFormat = elf; families = { inherit bsd; }; };
solaris = { execFormat = elf; families = { }; };
wasi = { execFormat = wasm; families = { }; };
+ redox = { execFormat = elf; families = { }; };
windows = { execFormat = pe; families = { }; };
ghcjs = { execFormat = unknown; families = { }; };
genode = { execFormat = elf; families = { }; };
@@ -390,6 +391,8 @@ rec {
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows"; }
else if (elemAt l 2 == "wasi")
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "wasi"; }
+ else if (elemAt l 2 == "redox")
+ then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "redox"; }
else if hasPrefix "netbsd" (elemAt l 2)
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; }
else if (elem (