From 904ecf0b4e055dc465f5ae6574be2af8cc25dec3 Mon Sep 17 00:00:00 2001 From: Cole Mickens Date: Thu, 13 Jan 2022 15:14:42 -0800 Subject: [PATCH 001/245] extlinux-conf-builder: specialisations entries --- .../generic-extlinux-compatible/extlinux-conf-builder.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.sh b/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.sh index 1a0da0050291..f2b281d23292 100644 --- a/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.sh +++ b/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.sh @@ -141,7 +141,13 @@ if [ "$numGenerations" -gt 0 ]; then | sort -n -r \ | head -n $numGenerations); do link=/nix/var/nix/profiles/system-$generation-link - addEntry $link $generation + addEntry $link "${generation}-default" + for specialisation in $( + ls /nix/var/nix/profiles/system-$generation-link/specialisation \ + | sort -n -r); do + link=/nix/var/nix/profiles/system-$generation-link/specialisation/$specialisation + addEntry $link "${generation}-${specialisation}" + done done >> $tmpFile fi From 3d14617fc7006d161d531a9e9ddff9c163f84734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 17 Jul 2023 13:25:43 +0200 Subject: [PATCH 002/245] cloud-init: enable filesystems based on what is used --- nixos/modules/services/system/cloud-init.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/system/cloud-init.nix b/nixos/modules/services/system/cloud-init.nix index d782bb1a3666..61966fa6ce86 100644 --- a/nixos/modules/services/system/cloud-init.nix +++ b/nixos/modules/services/system/cloud-init.nix @@ -17,6 +17,7 @@ let ++ optional cfg.ext4.enable e2fsprogs ++ optional cfg.xfs.enable xfsprogs ; + hasFs = fsName: lib.any (fs: fs.fsType == fsName) (lib.attrValues config.fileSystems); settingsFormat = pkgs.formats.yaml { }; cfgfile = settingsFormat.generate "cloud.cfg" cfg.settings; in @@ -44,7 +45,8 @@ in btrfs.enable = mkOption { type = types.bool; - default = false; + default = hasFs "btrfs"; + defaultText = literalExpression ''hasFs "btrfs"''; description = mdDoc '' Allow the cloud-init service to operate `btrfs` filesystem. ''; @@ -52,7 +54,8 @@ in ext4.enable = mkOption { type = types.bool; - default = true; + default = hasFs "ext4"; + defaultText = literalExpression ''hasFs "ext4"''; description = mdDoc '' Allow the cloud-init service to operate `ext4` filesystem. ''; @@ -60,7 +63,8 @@ in xfs.enable = mkOption { type = types.bool; - default = false; + default = hasFs "xfs"; + defaultText = literalExpression ''hasFs "xfs"''; description = mdDoc '' Allow the cloud-init service to operate `xfs` filesystem. ''; From deae0161005f1fe8b7e4b7eb0c4897cfe73dd8cb Mon Sep 17 00:00:00 2001 From: Serg Date: Tue, 6 Feb 2024 23:27:14 +0300 Subject: [PATCH 003/245] geeqie: 2.1 -> 2.2 --- pkgs/applications/graphics/geeqie/default.nix | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/pkgs/applications/graphics/geeqie/default.nix b/pkgs/applications/graphics/geeqie/default.nix index 653dad23b638..bf1e69e9152a 100644 --- a/pkgs/applications/graphics/geeqie/default.nix +++ b/pkgs/applications/graphics/geeqie/default.nix @@ -2,36 +2,32 @@ , gtk3, lcms2, exiv2, libchamplain, clutter-gtk, ffmpegthumbnailer, fbida , libarchive, djvulibre, libheif, openjpeg, libjxl, libraw, lua5_3, poppler , gspell, libtiff, libwebp +, gphoto2, imagemagick, yad, exiftool, gnome, libnotify , wrapGAppsHook, fetchpatch, doxygen , nix-update-script }: stdenv.mkDerivation rec { pname = "geeqie"; - version = "2.1"; + version = "2.2"; src = fetchFromGitHub { owner = "BestImageViewer"; repo = "geeqie"; rev = "v${version}"; - hash = "sha256-qkM/7auZ9TMF2r8KLnitxmvlyPmIjh7q9Ugh+QKh8hw="; + hash = "sha256-13Ayr6r4JhqexaUvwzdc6XHT+j2l2D5YBws6gSAhU3Y="; }; patches = [ + # Remove changelog from menu (fetchpatch { - name = "exiv2-0.28.0-support-1.patch"; - url = "https://github.com/BestImageViewer/geeqie/commit/c45cca777aa3477eaf297db99f337e18d9683c61.patch"; - hash = "sha256-YiFzAj3G3Z2w7p+8zZlDBjWqUqnfSqvaxMkESfPFdzc="; + url = "https://salsa.debian.org/debian/geeqie/-/raw/debian/master/debian/patches/Remove-changelog-from-menu-item.patch"; + hash = "sha256-0awKKTLg/gUZhmwluVbHCOqssog9SneFOaUtG89q0go="; }) + # Fix missing execute permissions for geocode-parametres.awk plugin (fetchpatch { - name = "exiv2-0.28.0-support-2.patch"; - url = "https://github.com/BestImageViewer/geeqie/commit/b04f7cd0546976dc4f7ea440648ac0eedd8df3ce.patch"; - hash = "sha256-V0ZOHbAZOrhLcNN+Al1/kvxvbw0vc/R7r99CegjuBQg="; - }) - (fetchpatch { - name = "fix-compilation-with-lua.patch"; - url = "https://github.com/BestImageViewer/geeqie/commit/a132645ee87e612217ac955b227cad04f21a5722.patch"; - hash = "sha256-BozarBPoIKxZS3qpjuzHHAWZGIWZAwvJyqsNC8v+TMk="; + url = "https://github.com/BestImageViewer/geeqie/commit/4d3ddcf5b9c0668bfdaf1dfe24219ee57c2f0237.patch"; + hash = "sha256-Na2qiwCTbOv1yt251oaSZiLaOwJCkjWew+us4lQju0I="; }) ]; @@ -54,8 +50,29 @@ stdenv.mkDerivation rec { postInstall = '' # Allow geeqie to find exiv2 and exiftran, necessary to # losslessly rotate JPEG images. + # Requires exiftran (fbida package) and exiv2. sed -i $out/lib/geeqie/geeqie-rotate \ -e '1 a export PATH=${lib.makeBinPath [ exiv2 fbida ]}:$PATH' + # Zenity and yad are used in some scripts for reporting errors. + # Allow change quality of image. + # Requires imagemagick and yad. + sed -i $out/lib/geeqie/geeqie-resize-image \ + -e '1 a export PATH=${lib.makeBinPath [ imagemagick yad ]}:$PATH' + # Allow to crop image. + # Requires imagemagick, exiv2 and exiftool. + sed -i $out/lib/geeqie/geeqie-image-crop \ + -e '1 a export PATH=${lib.makeBinPath [ imagemagick exiv2 exiftool gnome.zenity ]}:$PATH' + # Requires gphoto2 and libnotify + sed -i $out/lib/geeqie/geeqie-tethered-photography \ + -e '1 a export PATH=${lib.makeBinPath [ gphoto2 gnome.zenity libnotify ]}:$PATH' + # Import images from camera. + # Requires gphoto2. + sed -i $out/lib/geeqie/geeqie-camera-import \ + -e '1 a export PATH=${lib.makeBinPath [ gphoto2 gnome.zenity ]}:$PATH' + # Export jpeg from raw file. + # Requires exiv2, exiftool and lcms2. + sed -i $out/lib/geeqie/geeqie-export-jpeg \ + -e '1 a export PATH=${lib.makeBinPath [ gnome.zenity exiv2 exiftool lcms2 ]}:$PATH' ''; enableParallelBuilding = true; From ca81a89839176c2e0d0b0fb01a931a4a65404fa6 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 28 Jan 2024 00:30:36 +0100 Subject: [PATCH 004/245] lib.types.attrTag: init --- lib/tests/modules.sh | 11 ++++ lib/tests/modules/types-attrTag.nix | 64 +++++++++++++++++++ lib/types.nix | 37 +++++++++++ .../development/option-types.section.md | 10 +++ 4 files changed, 122 insertions(+) create mode 100644 lib/tests/modules/types-attrTag.nix diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index b3bbdf9485ac..318efc4c3d05 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -103,6 +103,17 @@ checkConfigError 'The option .sub.wrong2. does not exist. Definition values:' co checkConfigError '.*This can happen if you e.g. declared your options in .types.submodule.' config.sub ./error-mkOption-in-submodule-config.nix checkConfigError '.*A definition for option .bad. is not of type .non-empty .list of .submodule...\.' config.bad ./error-nonEmptyListOf-submodule.nix +# types.attrTag +checkConfigOutput '^true$' config.okChecks ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError. is not of type .attribute-tagged union of left, right' config.intStrings.syntaxError ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError2. is not of type .attribute-tagged union of left, right' config.intStrings.syntaxError2 ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError3. is not of type .attribute-tagged union of left, right' config.intStrings.syntaxError3 ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError4. is not of type .attribute-tagged union of left, right' config.intStrings.syntaxError4 ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.mergeError. is not of type .attribute-tagged union of left, right' config.intStrings.mergeError ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.badTagError. is not of type .attribute-tagged union of left, right' config.intStrings.badTagError ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.badTagTypeError\.left. is not of type .signed integer.' config.intStrings.badTagTypeError.left ./types-attrTag.nix +checkConfigError 'A definition for option .nested\.right\.left. is not of type .signed integer.' config.nested.right.left ./types-attrTag.nix + # types.pathInStore checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix checkConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathInStore.ok2 ./types.nix diff --git a/lib/tests/modules/types-attrTag.nix b/lib/tests/modules/types-attrTag.nix new file mode 100644 index 000000000000..08854ca73f56 --- /dev/null +++ b/lib/tests/modules/types-attrTag.nix @@ -0,0 +1,64 @@ +{ lib, config, ... }: +let + inherit (lib) mkOption types; + forceDeep = x: builtins.deepSeq x x; +in +{ + options = { + intStrings = mkOption { + type = types.attrsOf + (types.attrTag { + left = types.int; + right = types.str; + }); + }; + nested = mkOption { + type = types.attrTag { + left = types.int; + right = types.attrTag { + left = types.int; + right = types.str; + }; + }; + }; + merged = mkOption { + type = types.attrsOf ( + types.attrTag { + yay = types.int; + } + ); + }; + okChecks = mkOption {}; + }; + imports = [ + { + options.merged = mkOption { + type = types.attrsOf ( + types.attrTag { + nay = types.bool; + } + ); + }; + } + ]; + config = { + intStrings.syntaxError = 1; + intStrings.syntaxError2 = {}; + intStrings.syntaxError3 = { a = true; b = true; }; + intStrings.syntaxError4 = lib.mkMerge [ { a = true; } { b = true; } ]; + intStrings.mergeError = lib.mkMerge [ { int = throw "do not eval"; } { string = throw "do not eval"; } ]; + intStrings.badTagError.rite = throw "do not eval"; + intStrings.badTagTypeError.left = "bad"; + intStrings.numberOne.left = 1; + intStrings.hello.right = "hello world"; + nested.right.left = "not a number"; + merged.negative.nay = false; + merged.positive.yay = 100; + okChecks = + assert config.intStrings.hello.right == "hello world"; + assert config.intStrings.numberOne.left == 1; + assert config.merged.negative.nay == false; + assert config.merged.positive.yay == 100; + true; + }; +} diff --git a/lib/types.nix b/lib/types.nix index 12bf18633e3a..59577856f4e1 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -614,6 +614,43 @@ rec { nestedTypes.elemType = elemType; }; + attrTag = tags: attrTagWith { inherit tags; }; + + attrTagWith = { tags }: + let + choicesStr = concatMapStringsSep ", " lib.strings.escapeNixIdentifier (attrNames tags); + in + mkOptionType { + name = "attrTag"; + description = "attribute-tagged union of ${choicesStr}"; + getSubModules = null; + substSubModules = m: attrTagWith { tags = mapAttrs (n: v: v.substSubModules m) tags; }; + check = v: isAttrs v && length (attrNames v) == 1 && tags?${head (attrNames v)}; + merge = loc: defs: + let + choice = head (attrNames (head defs).value); + checkedValueDefs = map + (def: + assert (length (attrNames def.value)) == 1; + if (head (attrNames def.value)) != choice + then throw "The option `${showOption loc}` is defined both as `${choice}` and `${head (attrNames def.value)}`, in ${showFiles (getFiles defs)}." + else { inherit (def) file; value = def.value.${choice}; }) + defs; + in + if tags?${choice} + then + { ${choice} = + (mergeDefinitions + (loc ++ [choice]) + tags.${choice} + checkedValueDefs + ).mergedValue; + } + else throw "The option `${showOption loc}` is defined as ${lib.strings.escapeNixIdentifier choice}, but ${lib.strings.escapeNixIdentifier choice} is not among the valid choices (${choicesStr}). Value ${choice} was defined in ${showFiles (getFiles defs)}."; + nestedTypes = tags; + functor = (defaultFunctor "attrTagWith") // { payload = { inherit tags; }; binOp = a: b: { tags = a.tags // b.tags; }; }; + }; + uniq = unique { message = ""; }; unique = { message }: type: mkOptionType rec { diff --git a/nixos/doc/manual/development/option-types.section.md b/nixos/doc/manual/development/option-types.section.md index 04edf99e70b0..1dfb4354f887 100644 --- a/nixos/doc/manual/development/option-types.section.md +++ b/nixos/doc/manual/development/option-types.section.md @@ -334,6 +334,16 @@ Composed types are types that take a type as parameter. `listOf the line `The option