summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/licenses.nix27
-rw-r--r--lib/lists.nix2
-rw-r--r--lib/minver.nix2
-rw-r--r--lib/modules.nix132
-rw-r--r--lib/options.nix9
-rw-r--r--lib/systems/default.nix16
-rw-r--r--lib/systems/doubles.nix18
-rw-r--r--lib/systems/examples.nix15
-rw-r--r--lib/systems/inspect.nix11
-rw-r--r--lib/systems/parse.nix13
-rw-r--r--lib/systems/platforms.nix4
-rwxr-xr-xlib/tests/modules.sh1
-rw-r--r--lib/tests/modules/disable-define-enable-string-path.nix5
-rw-r--r--lib/tests/systems.nix2
-rw-r--r--lib/types.nix6
15 files changed, 157 insertions, 106 deletions
diff --git a/lib/licenses.nix b/lib/licenses.nix
index 873ad1b7bbda..6eeba6588be1 100644
--- a/lib/licenses.nix
+++ b/lib/licenses.nix
@@ -148,6 +148,11 @@ in mkLicense lset) ({
fullName = ''BSD 4-clause "Original" or "Old" License'';
};
+ bsdOriginalShortened = {
+ spdxId = "BSD-4-Clause-Shortened";
+ fullName = "BSD 4 Clause Shortened";
+ };
+
bsdOriginalUC = {
spdxId = "BSD-4-Clause-UC";
fullName = "BSD 4-Clause University of California-Specific";
@@ -520,6 +525,13 @@ in mkLicense lset) ({
free = false;
};
+ databricks-dbx = {
+ fullName = "DataBricks eXtensions aka dbx License";
+ url = "https://github.com/databrickslabs/dbx/blob/743b579a4ac44531f764c6e522dbe5a81a7dc0e4/LICENSE";
+ free = false;
+ redistributable = false;
+ };
+
issl = {
fullName = "Intel Simplified Software License";
url = "https://software.intel.com/en-us/license/intel-simplified-software-license";
@@ -686,6 +698,11 @@ in mkLicense lset) ({
fullName = "SIL Open Font License 1.1";
};
+ oml = {
+ spdxId = "OML";
+ fullName = "Open Market License";
+ };
+
openldap = {
spdxId = "OLDAP-2.8";
fullName = "Open LDAP Public License v2.8";
@@ -817,6 +834,11 @@ in mkLicense lset) ({
fullName = "TCL/TK License";
};
+ ucd = {
+ fullName = "Unicode Character Database License";
+ url = "https://fedoraproject.org/wiki/Licensing:UCD";
+ };
+
ufl = {
fullName = "Ubuntu Font License 1.0";
url = "https://ubuntu.com/legal/font-licence";
@@ -871,6 +893,11 @@ in mkLicense lset) ({
free = false;
};
+ vol-sl = {
+ fullName = "Volatility Software License, Version 1.0";
+ url = "https://www.volatilityfoundation.org/license/vsl-v1.0";
+ };
+
vsl10 = {
spdxId = "VSL-1.0";
fullName = "Vovida Software License v1.0";
diff --git a/lib/lists.nix b/lib/lists.nix
index 36056e18065e..602b13cf69cf 100644
--- a/lib/lists.nix
+++ b/lib/lists.nix
@@ -36,7 +36,7 @@ rec {
forEach = xs: f: map f xs;
/* “right fold” a binary function `op` between successive elements of
- `list` with `nul' as the starting value, i.e.,
+ `list` with `nul` as the starting value, i.e.,
`foldr op nul [x_1 x_2 ... x_n] == op x_1 (op x_2 ... (op x_n nul))`.
Type: foldr :: (a -> b -> b) -> b -> [a] -> b
diff --git a/lib/minver.nix b/lib/minver.nix
index 86391bcd69e0..507d45bba4dc 100644
--- a/lib/minver.nix
+++ b/lib/minver.nix
@@ -1,2 +1,2 @@
# Expose the minimum required version for evaluating Nixpkgs
-"2.2"
+"2.3"
diff --git a/lib/modules.nix b/lib/modules.nix
index 1e48f5440798..d3a7fac82c4a 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -163,84 +163,50 @@ rec {
# TODO: Change the type of this option to a submodule with a
# freeformType, so that individual arguments can be documented
# separately
- description = ''
+ description = lib.mdDoc ''
Additional arguments passed to each module in addition to ones
- like <literal>lib</literal>, <literal>config</literal>,
- and <literal>pkgs</literal>, <literal>modulesPath</literal>.
- </para>
- <para>
+ like `lib`, `config`,
+ and `pkgs`, `modulesPath`.
+
This option is also available to all submodules. Submodules do not
inherit args from their parent module, nor do they provide args to
their parent module or sibling submodules. The sole exception to
- this is the argument <literal>name</literal> which is provided by
+ this is the argument `name` which is provided by
parent modules to a submodule and contains the attribute name
the submodule is bound to, or a unique generated name if it is
not bound to an attribute.
- </para>
- <para>
+
Some arguments are already passed by default, of which the
- following <emphasis>cannot</emphasis> be changed with this option:
- <itemizedlist>
- <listitem>
- <para>
- <varname>lib</varname>: The nixpkgs library.
- </para>
- </listitem>
- <listitem>
- <para>
- <varname>config</varname>: The results of all options after merging the values from all modules together.
- </para>
- </listitem>
- <listitem>
- <para>
- <varname>options</varname>: The options declared in all modules.
- </para>
- </listitem>
- <listitem>
- <para>
- <varname>specialArgs</varname>: The <literal>specialArgs</literal> argument passed to <literal>evalModules</literal>.
- </para>
- </listitem>
- <listitem>
- <para>
- All attributes of <varname>specialArgs</varname>
- </para>
- <para>
- Whereas option values can generally depend on other option values
- thanks to laziness, this does not apply to <literal>imports</literal>, which
- must be computed statically before anything else.
- </para>
- <para>
- For this reason, callers of the module system can provide <literal>specialArgs</literal>
- which are available during import resolution.
- </para>
- <para>
- For NixOS, <literal>specialArgs</literal> includes
- <varname>modulesPath</varname>, which allows you to import
- extra modules from the nixpkgs package tree without having to
- somehow make the module aware of the location of the
- <literal>nixpkgs</literal> or NixOS directories.
- <programlisting>
- { modulesPath, ... }: {
- imports = [
- (modulesPath + "/profiles/minimal.nix")
- ];
- }
- </programlisting>
- </para>
- </listitem>
- </itemizedlist>
- </para>
- <para>
+ following *cannot* be changed with this option:
+ - {var}`lib`: The nixpkgs library.
+ - {var}`config`: The results of all options after merging the values from all modules together.
+ - {var}`options`: The options declared in all modules.
+ - {var}`specialArgs`: The `specialArgs` argument passed to `evalModules`.
+ - All attributes of {var}`specialArgs`
+
+ Whereas option values can generally depend on other option values
+ thanks to laziness, this does not apply to `imports`, which
+ must be computed statically before anything else.
+
+ For this reason, callers of the module system can provide `specialArgs`
+ which are available during import resolution.
+
+ For NixOS, `specialArgs` includes
+ {var}`modulesPath`, which allows you to import
+ extra modules from the nixpkgs package tree without having to
+ somehow make the module aware of the location of the
+ `nixpkgs` or NixOS directories.
+ ```
+ { modulesPath, ... }: {
+ imports = [
+ (modulesPath + "/profiles/minimal.nix")
+ ];
+ }
+ ```
+
For NixOS, the default value for this option includes at least this argument:
- <itemizedlist>
- <listitem>
- <para>
- <varname>pkgs</varname>: The nixpkgs package set according to
- the <option>nixpkgs.pkgs</option> option.
- </para>
- </listitem>
- </itemizedlist>
+ - {var}`pkgs`: The nixpkgs package set according to
+ the {option}`nixpkgs.pkgs` option.
'';
};
@@ -248,24 +214,33 @@ rec {
type = types.bool;
internal = true;
default = true;
- description = "Whether to check whether all option definitions have matching declarations.";
+ description = lib.mdDoc "Whether to check whether all option definitions have matching declarations.";
};
_module.freeformType = mkOption {
type = types.nullOr types.optionType;
internal = true;
default = null;
- description = ''
+ description = lib.mdDoc ''
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.
+ values of all declared options to produce the final `
+ config` value.
- If this is <literal>null</literal>, definitions without an option
- will throw an error unless <option>_module.check</option> is
+ If this is `null`, definitions without an option
+ will throw an error unless {option}`_module.check` is
turned off.
'';
};
+
+ _module.specialArgs = mkOption {
+ readOnly = true;
+ internal = true;
+ description = lib.mdDoc ''
+ Externally provided module arguments that can't be modified from
+ within a configuration, but can be used in module imports.
+ '';
+ };
};
config = {
@@ -273,6 +248,7 @@ rec {
inherit extendModules;
moduleType = type;
};
+ _module.specialArgs = specialArgs;
};
};
@@ -423,7 +399,9 @@ rec {
# modules recursively. It returns the final list of unique-by-key modules
filterModules = modulesPath: { disabled, modules }:
let
- moduleKey = m: if isString m then toString modulesPath + "/" + m else toString m;
+ moduleKey = m: if isString m && (builtins.substring 0 1 m != "/")
+ then toString modulesPath + "/" + m
+ else toString m;
disabledKeys = map moduleKey disabled;
keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
in map (attrs: attrs.module) (builtins.genericClosure {
@@ -1157,7 +1135,7 @@ rec {
{
options = setAttrByPath from (mkOption {
inherit visible;
- description = "Alias of <option>${showOption to}</option>.";
+ description = lib.mdDoc "Alias of {option}`${showOption to}`.";
apply = x: use (toOf config);
} // optionalAttrs (toType != null) {
type = toType;
diff --git a/lib/options.nix b/lib/options.nix
index 3a1c0e540d7c..a56e579ab84d 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -95,7 +95,10 @@ rec {
name: mkOption {
default = false;
example = true;
- description = "Whether to enable ${name}.";
+ description =
+ if name ? _type && name._type == "mdDoc"
+ then lib.mdDoc "Whether to enable ${name.text}."
+ else "Whether to enable ${name}.";
type = lib.types.bool;
};
@@ -121,7 +124,7 @@ rec {
Example:
mkPackageOption pkgs "GHC" {
default = [ "ghc" ];
- example = "pkgs.haskell.package.ghc923.ghc.withPackages (hkgs: [ hkgs.primes ])";
+ example = "pkgs.haskell.packages.ghc924.ghc.withPackages (hkgs: [ hkgs.primes ])";
}
=> { _type = "option"; default = «derivation /nix/store/jxx55cxsjrf8kyh3fp2ya17q99w7541r-ghc-8.10.7.drv»; defaultText = { ... }; description = "The GHC package to use."; example = { ... }; type = { ... }; }
*/
@@ -134,7 +137,7 @@ rec {
let default' = if !isList default then [ default ] else default;
in mkOption {
type = lib.types.package;
- description = "The ${name} package to use.";
+ description = lib.mdDoc "The ${name} package to use.";
default = attrByPath default'
(throw "${concatStringsSep "." default'} cannot be found in pkgs") pkgs;
defaultText = literalExpression ("pkgs." + concatStringsSep "." default');
diff --git a/lib/systems/default.nix b/lib/systems/default.nix
index d9d0918c1cc6..1e65bcc26795 100644
--- a/lib/systems/default.nix
+++ b/lib/systems/default.nix
@@ -16,9 +16,6 @@ rec {
*/
flakeExposed = import ./flake-systems.nix { };
- # TODO(@sternenseemann): remove before 21.11
- supported = throw "2022-05-23: Use lib.systems.flakeExposed instead of lib.systems.supported.hydra, as lib.systems.supported has been removed";
-
# Elaborate a `localSystem` or `crossSystem` so that it contains everything
# necessary.
#
@@ -36,6 +33,7 @@ rec {
config = parse.tripleFromSystem final.parsed;
# Determine whether we can execute binaries built for the provided platform.
canExecute = platform:
+ final.isAndroid == platform.isAndroid &&
parse.isCompatible final.parsed.cpu platform.parsed.cpu
&& final.parsed.kernel == platform.parsed.kernel;
isCompatible = _: throw "2022-05-23: isCompatible has been removed in favor of canExecute, refer to the 22.11 changelog for details";
@@ -67,11 +65,17 @@ rec {
# is why we use the more obscure "bfd" and not "binutils" for this
# choice.
else "bfd";
- extensions = {
+ extensions = rec {
sharedLibrary =
/**/ if final.isDarwin then ".dylib"
else if final.isWindows then ".dll"
else ".so";
+ staticLibrary =
+ /**/ if final.isWindows then ".lib"
+ else ".a";
+ library =
+ /**/ if final.isStatic then staticLibrary
+ else sharedLibrary;
executable =
/**/ if final.isWindows then ".exe"
else "";
@@ -95,7 +99,7 @@ rec {
genode = "Genode";
}.${final.parsed.kernel.name} or null;
- # uname -p
+ # uname -m
processor = final.parsed.cpu.name;
# uname -r
@@ -117,6 +121,8 @@ rec {
else if final.isAarch64 then "arm64"
else if final.isx86_32 then "i386"
else if final.isx86_64 then "x86_64"
+ # linux kernel does not distinguish microblaze/microblazeel
+ else if final.isMicroBlaze then "microblaze"
else if final.isMips32 then "mips"
else if final.isMips64 then "mips" # linux kernel does not distinguish mips32/mips64
else if final.isPower then "powerpc"
diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix
index 90a6eb9f35c9..709b67607f7b 100644
--- a/lib/systems/doubles.nix
+++ b/lib/systems/doubles.nix
@@ -26,9 +26,10 @@ let
# Linux
"aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux"
- "armv7l-linux" "i686-linux" "m68k-linux" "mipsel-linux" "mips64el-linux"
- "powerpc64-linux" "powerpc64le-linux" "riscv32-linux"
- "riscv64-linux" "s390-linux" "s390x-linux" "x86_64-linux"
+ "armv7l-linux" "i686-linux" "m68k-linux" "microblaze-linux"
+ "microblazeel-linux" "mipsel-linux" "mips64el-linux" "powerpc64-linux"
+ "powerpc64le-linux" "riscv32-linux" "riscv64-linux" "s390-linux"
+ "s390x-linux" "x86_64-linux"
# MMIXware
"mmix-mmixware"
@@ -40,9 +41,9 @@ let
# none
"aarch64_be-none" "aarch64-none" "arm-none" "armv6l-none" "avr-none" "i686-none"
- "msp430-none" "or1k-none" "m68k-none" "powerpc-none" "powerpcle-none"
- "riscv32-none" "riscv64-none" "rx-none" "s390-none" "s390x-none" "vc4-none"
- "x86_64-none"
+ "microblaze-none" "microblazeel-none" "msp430-none" "or1k-none" "m68k-none"
+ "powerpc-none" "powerpcle-none" "riscv32-none" "riscv64-none" "rx-none"
+ "s390-none" "s390x-none" "vc4-none" "x86_64-none"
# OpenBSD
"i686-openbsd" "x86_64-openbsd"
@@ -71,6 +72,7 @@ in {
x86 = filterDoubles predicates.isx86;
i686 = filterDoubles predicates.isi686;
x86_64 = filterDoubles predicates.isx86_64;
+ microblaze = filterDoubles predicates.isMicroBlaze;
mips = filterDoubles predicates.isMips;
mmix = filterDoubles predicates.isMmix;
riscv = filterDoubles predicates.isRiscV;
@@ -94,7 +96,9 @@ in {
++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabi; })
++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabihf; })
++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabin32; })
- ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabi64; });
+ ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabi64; })
+ ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabielfv1; })
+ ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabielfv2; });
illumos = filterDoubles predicates.isSunOS;
linux = filterDoubles predicates.isLinux;
netbsd = filterDoubles predicates.isNetBSD;
diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix
index 03bb5ffcdacc..0d9f67037764 100644
--- a/lib/systems/examples.nix
+++ b/lib/systems/examples.nix
@@ -22,12 +22,11 @@ rec {
};
ppc64 = {
- config = "powerpc64-unknown-linux-gnu";
- gcc = { abi = "elfv2"; }; # for gcc configuration
+ config = "powerpc64-unknown-linux-gnuabielfv2";
};
ppc64-musl = {
config = "powerpc64-unknown-linux-musl";
- gcc = { abi = "elfv2"; }; # for gcc configuration
+ gcc = { abi = "elfv2"; };
};
sheevaplug = {
@@ -57,23 +56,23 @@ rec {
armv7a-android-prebuilt = {
config = "armv7a-unknown-linux-androideabi";
rustc.config = "armv7-linux-androideabi";
- sdkVer = "29";
- ndkVer = "21";
+ sdkVer = "28";
+ ndkVer = "24";
useAndroidPrebuilt = true;
} // platforms.armv7a-android;
aarch64-android-prebuilt = {
config = "aarch64-unknown-linux-android";
rustc.config = "aarch64-linux-android";
- sdkVer = "29";
- ndkVer = "21";
+ sdkVer = "28";
+ ndkVer = "24";
useAndroidPrebuilt = true;
};
aarch64-android = {
config = "aarch64-unknown-linux-android";
sdkVer = "30";
- ndkVer = "21";
+ ndkVer = "24";
libc = "bionic";
useAndroidPrebuilt = false;
useLLVM = true;
diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix
index e5bd879e2c42..ee213438e048 100644
--- a/lib/systems/inspect.nix
+++ b/lib/systems/inspect.nix
@@ -13,9 +13,18 @@ rec {
isx86_64 = { cpu = { family = "x86"; bits = 64; }; };
isPower = { cpu = { family = "power"; }; };
isPower64 = { cpu = { family = "power"; bits = 64; }; };
+ # This ABI is the default in NixOS PowerPC64 BE, but not on mainline GCC,
+ # so it sometimes causes issues in certain packages that makes the wrong
+ # assumption on the used ABI.
+ isAbiElfv2 = [
+ { abi = { abi = "elfv2"; }; }
+ { abi = { name = "musl"; }; cpu = { family = "power"; bits = 64; }; }
+ ];
isx86 = { cpu = { family = "x86"; }; };
isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
isAarch64 = { cpu = { family = "arm"; bits = 64; }; };
+ isAarch = { cpu = { family = "arm"; }; };
+ isMicroBlaze = { cpu = { family = "microblaze"; }; };
isMips = { cpu = { family = "mips"; }; };
isMips32 = { cpu = { family = "mips"; bits = 32; }; };
isMips64 = { cpu = { family = "mips"; bits = 64; }; };
@@ -63,7 +72,7 @@ rec {
isNone = { kernel = kernels.none; };
isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ];
- isGnu = with abis; map (a: { abi = a; }) [ gnuabi64 gnu gnueabi gnueabihf ];
+ isGnu = with abis; map (a: { abi = a; }) [ gnuabi64 gnu gnueabi gnueabihf gnuabielfv1 gnuabielfv2 ];
isMusl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf muslabin32 muslabi64 ];
isUClibc = with abis; map (a: { abi = a; }) [ uclibc uclibceabi uclibceabihf ];
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix
index 9d2571c993a9..ac450534fe1e 100644
--- a/lib/systems/parse.nix
+++ b/lib/systems/parse.nix
@@ -88,6 +88,9 @@ rec {
i686 = { bits = 32; significantByte = littleEndian; family = "x86"; arch = "i686"; };
x86_64 = { bits = 64; significantByte = littleEndian; family = "x86"; arch = "x86-64"; };
+ microblaze = { bits = 32; significantByte = bigEndian; family = "microblaze"; };
+ microblazeel = { bits = 32; significantByte = littleEndian; family = "microblaze"; };
+
mips = { bits = 32; significantByte = bigEndian; family = "mips"; };
mipsel = { bits = 32; significantByte = littleEndian; family = "mips"; };
mips64 = { bits = 64; significantByte = bigEndian; family = "mips"; };
@@ -350,6 +353,11 @@ rec {
The "gnu" ABI is ambiguous on 32-bit ARM. Use "gnueabi" or "gnueabihf" instead.
'';
}
+ { assertion = platform: with platform; !(isPower64 && isBigEndian);
+ message = ''
+ The "gnu" ABI is ambiguous on big-endian 64-bit PowerPC. Use "gnuabielfv2" or "gnuabielfv1" instead.
+ '';
+ }
];
};
gnuabi64 = { abi = "64"; };
@@ -361,6 +369,9 @@ rec {
gnuabin32 = { abi = "n32"; };
muslabin32 = { abi = "n32"; };
+ gnuabielfv2 = { abi = "elfv2"; };
+ gnuabielfv1 = { abi = "elfv1"; };
+
musleabi = { float = "soft"; };
musleabihf = { float = "hard"; };
musl = {};
@@ -464,6 +475,8 @@ rec {
if lib.versionAtLeast (parsed.cpu.version or "0") "6"
then abis.gnueabihf
else abis.gnueabi
+ # Default ppc64 BE to ELFv2
+ else if isPower64 parsed && isBigEndian parsed then abis.gnuabielfv2
else abis.gnu
else abis.unknown;
};
diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix
index d93d292a9fb5..41c25484cea0 100644
--- a/lib/systems/platforms.nix
+++ b/lib/systems/platforms.nix
@@ -483,8 +483,8 @@ rec {
};
# can execute on 32bit chip
- gcc_mips32r2_o32 = { gcc = { arch = "mips32r2"; abi = "o32"; }; };
- gcc_mips32r6_o32 = { gcc = { arch = "mips32r6"; abi = "o32"; }; };
+ gcc_mips32r2_o32 = { gcc = { arch = "mips32r2"; abi = "32"; }; };
+ gcc_mips32r6_o32 = { gcc = { arch = "mips32r6"; abi = "32"; }; };
gcc_mips64r2_n32 = { gcc = { arch = "mips64r2"; abi = "n32"; }; };
gcc_mips64r6_n32 = { gcc = { arch = "mips64r6"; abi = "n32"; }; };
gcc_mips64r2_64 = { gcc = { arch = "mips64r2"; abi = "64"; }; };
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh
index c92cc62023b5..2ef7c4806595 100755
--- a/lib/tests/modules.sh
+++ b/lib/tests/modules.sh
@@ -130,6 +130,7 @@ checkConfigOutput '^true$' "$@" ./define-enable.nix ./define-attrsOfSub-foo-enab
set -- config.enable ./define-enable.nix ./declare-enable.nix
checkConfigOutput '^true$' "$@"
checkConfigOutput '^false$' "$@" ./disable-define-enable.nix
+checkConfigOutput '^false$' "$@" ./disable-define-enable-string-path.nix
checkConfigError "The option .*enable.* does not exist. Definition values:\n\s*- In .*: true" "$@" ./disable-declare-enable.nix
checkConfigError "attribute .*enable.* in selection path .*config.enable.* not found" "$@" ./disable-define-enable.nix ./disable-declare-enable.nix
checkConfigError "attribute .*enable.* in selection path .*config.enable.* not found" "$@" ./disable-enable-modules.nix
diff --git a/lib/tests/modules/disable-define-enable-string-path.nix b/lib/tests/modules/disable-define-enable-string-path.nix
new file mode 100644
index 000000000000..6429a6d6354a
--- /dev/null
+++ b/lib/tests/modules/disable-define-enable-string-path.nix
@@ -0,0 +1,5 @@
+{ lib, ... }:
+
+{
+ disabledModules = [ (toString ./define-enable.nix) ];
+}
diff --git a/lib/tests/systems.nix b/lib/tests/systems.nix
index 46e7bd992f1e..4175dc68841e 100644
--- a/lib/tests/systems.nix
+++ b/lib/tests/systems.nix
@@ -31,7 +31,7 @@ with lib.systems.doubles; lib.runTests {
testredox = mseteq redox [ "x86_64-redox" ];
testgnu = mseteq gnu (linux /* ++ kfreebsd ++ ... */);
testillumos = mseteq illumos [ "x86_64-solaris" ];
- testlinux = mseteq linux [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "mips64el-linux" "mipsel-linux" "riscv32-linux" "riscv64-linux" "x86_64-linux" "powerpc64-linux" "powerpc64le-linux" "m68k-linux" "s390-linux" "s390x-linux" ];
+ testlinux = mseteq linux [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "mips64el-linux" "mipsel-linux" "riscv32-linux" "riscv64-linux" "x86_64-linux" "powerpc64-linux" "powerpc64le-linux" "m68k-linux" "s390-linux" "s390x-linux" "microblaze-linux" "microblazeel-linux" ];
testnetbsd = mseteq netbsd [ "aarch64-netbsd" "armv6l-netbsd" "armv7a-netbsd" "armv7l-netbsd" "i686-netbsd" "m68k-netbsd" "mipsel-netbsd" "powerpc-netbsd" "riscv32-netbsd" "riscv64-netbsd" "x86_64-netbsd" ];
testopenbsd = mseteq openbsd [ "i686-openbsd" "x86_64-openbsd" ];
testwindows = mseteq windows [ "i686-cygwin" "x86_64-cygwin" "i686-windows" "x86_64-windows" ];
diff --git a/lib/types.nix b/lib/types.nix
index 76001804e721..f235e3419926 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -55,6 +55,7 @@ let
concatMapStringsSep
concatStringsSep
escapeNixString
+ hasInfix
isCoercibleToString
;
inherit (lib.trivial)
@@ -384,6 +385,11 @@ rec {
deprecationMessage = "See https://github.com/NixOS/nixpkgs/pull/66346 for better alternative types.";
};
+ passwdEntry = entryType: addCheck entryType (str: !(hasInfix ":" str || hasInfix "\n" str)) // {
+ name = "passwdEntry ${entryType.name}";
+ description = "${entryType.description}, not containing newlines or colons";
+ };
+
attrs = mkOptionType {
name = "attrs";
description = "attribute set";