diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/generators.nix | 24 | ||||
-rw-r--r-- | lib/licenses.nix | 5 | ||||
-rw-r--r-- | lib/modules.nix | 11 | ||||
-rw-r--r-- | lib/sources.nix | 13 | ||||
-rw-r--r-- | lib/systems/default.nix | 5 | ||||
-rw-r--r-- | lib/systems/examples.nix | 2 | ||||
-rw-r--r-- | lib/systems/platforms.nix | 6 | ||||
-rwxr-xr-x | lib/tests/modules.sh | 2 | ||||
-rw-r--r-- | lib/trivial.nix | 2 |
9 files changed, 58 insertions, 12 deletions
diff --git a/lib/generators.nix b/lib/generators.nix index 501a23599f45e..c8144db50ac84 100644 --- a/lib/generators.nix +++ b/lib/generators.nix @@ -307,4 +307,28 @@ rec { ${expr "" v} </plist>''; + /* Translate a simple Nix expression to Dhall notation. + * Note that integers are translated to Integer and never + * the Natural type. + */ + toDhall = { }@args: v: + with builtins; + let concatItems = lib.strings.concatStringsSep ", "; + in if isAttrs v then + "{ ${ + concatItems (lib.attrsets.mapAttrsToList + (key: value: "${key} = ${toDhall args value}") v) + } }" + else if isList v then + "[ ${concatItems (map (toDhall args) v)} ]" + else if isInt v then + "${if v < 0 then "" else "+"}${toString v}" + else if isBool v then + (if v then "True" else "False") + else if isFunction v then + abort "generators.toDhall: cannot convert a function to Dhall" + else if isNull v then + abort "generators.toDhall: cannot convert a null to Dhall" + else + builtins.toJSON v; } diff --git a/lib/licenses.nix b/lib/licenses.nix index 993783db3ed6b..46ac0443a03fb 100644 --- a/lib/licenses.nix +++ b/lib/licenses.nix @@ -603,6 +603,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) ({ free = false; }; + odbl = spdx { + spdxId = "ODbL-1.0"; + fullName = "Open Data Commons Open Database License v1.0"; + }; + ofl = spdx { spdxId = "OFL-1.1"; fullName = "SIL Open Font License 1.1"; diff --git a/lib/modules.nix b/lib/modules.nix index 33a0d84a6d7f2..d3f10944e7085 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -361,6 +361,17 @@ rec { */ byName = attr: f: modules: foldl' (acc: module: + if !(builtins.isAttrs module.${attr}) then + throw '' + You're trying to declare a value of type `${builtins.typeOf module.${attr}}' + rather than an attribute-set for the option + `${builtins.concatStringsSep "." prefix}'! + + This usually happens if `${builtins.concatStringsSep "." prefix}' has option + definitions inside that are not matched. Please check how to properly define + this option by e.g. referring to `man 5 configuration.nix'! + '' + else acc // (mapAttrs (n: v: (acc.${n} or []) ++ f module v ) module.${attr} diff --git a/lib/sources.nix b/lib/sources.nix index 1a3afcae67da3..1a821f55056bd 100644 --- a/lib/sources.nix +++ b/lib/sources.nix @@ -138,12 +138,13 @@ rec { in if m == null then throw ("File contains no gitdir reference: " + path) else - let gitDir = absolutePath (dirOf path) (lib.head m); - commonDir' = if pathIsRegularFile "${gitDir}/commondir" - then lib.fileContents "${gitDir}/commondir" - else gitDir; - commonDir = absolutePath gitDir commonDir'; - refFile = lib.removePrefix "${commonDir}/" "${gitDir}/${file}"; + let gitDir = absolutePath (dirOf path) (lib.head m); + commonDir'' = if pathIsRegularFile "${gitDir}/commondir" + then lib.fileContents "${gitDir}/commondir" + else gitDir; + commonDir' = lib.removeSuffix "/" commonDir''; + commonDir = absolutePath gitDir commonDir'; + refFile = lib.removePrefix "${commonDir}/" "${gitDir}/${file}"; in readCommitFromFile refFile commonDir else if pathIsRegularFile fileName diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 1bbe976c4d217..1e38dbf531b17 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -107,6 +107,11 @@ rec { powerpc64le = "ppc64le"; }.${final.parsed.cpu.name} or final.parsed.cpu.name; + darwinArch = { + armv7a = "armv7"; + aarch64 = "arm64"; + }.${final.parsed.cpu.name} or final.parsed.cpu.name; + emulator = pkgs: let qemu-user = pkgs.qemu.override { smartcardSupport = false; diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 81dc893871d34..838b648e5822a 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -56,6 +56,7 @@ rec { armv7a-android-prebuilt = { config = "armv7a-unknown-linux-androideabi"; + rustc.config = "armv7-linux-androideabi"; sdkVer = "29"; ndkVer = "21"; useAndroidPrebuilt = true; @@ -63,6 +64,7 @@ rec { aarch64-android-prebuilt = { config = "aarch64-unknown-linux-android"; + rustc.config = "aarch64-linux-android"; sdkVer = "29"; ndkVer = "21"; useAndroidPrebuilt = true; diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix index 3bf90cd0cafb5..f46e9c826a5cc 100644 --- a/lib/systems/platforms.nix +++ b/lib/systems/platforms.nix @@ -303,14 +303,12 @@ rec { preferBuiltin = true; target = "zImage"; extraConfig = '' - # Serial port for Raspberry Pi 3. Upstream forgot to add it to the ARMv7 defconfig. + # Serial port for Raspberry Pi 3. Wasn't included in ARMv7 defconfig + # until 4.17. SERIAL_8250_BCM2835AUX y SERIAL_8250_EXTENDED y SERIAL_8250_SHARE_IRQ y - # Fix broken sunxi-sid nvmem driver. - TI_CPTS y - # Hangs ODROID-XU4 ARM_BIG_LITTLE_CPUIDLE n diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index f843d303e440b..2eddeec07b1a3 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -169,7 +169,7 @@ checkConfigOutput "foo" config.submodule.foo ./declare-submoduleWith-special.nix ## shorthandOnlyDefines config behaves as expected checkConfigOutput "true" config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-shorthand.nix checkConfigError 'is not of type `boolean' config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-noshorthand.nix -checkConfigError 'value is a boolean while a set was expected' config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-shorthand.nix +checkConfigError "You're trying to declare a value of type \`bool'\nrather than an attribute-set for the option" config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-shorthand.nix checkConfigOutput "true" config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-noshorthand.nix ## submoduleWith should merge all modules in one swoop diff --git a/lib/trivial.nix b/lib/trivial.nix index 268f39d321035..be6d0115f5b86 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -158,7 +158,7 @@ rec { seq deepSeq genericClosure; - ## nixpks version strings + ## nixpkgs version strings /* Returns the current full nixpkgs version number. */ version = release + versionSuffix; |