diff --git a/nixos/doc/manual/development/settings-options.xml b/nixos/doc/manual/development/settings-options.xml index 7795d7c80445..7292cac62b70 100644 --- a/nixos/doc/manual/development/settings-options.xml +++ b/nixos/doc/manual/development/settings-options.xml @@ -50,7 +50,7 @@ - pkgs.formats.ini { listsAsDuplicateKeys ? false, ... } + pkgs.formats.ini { listsAsDuplicateKeys ? false, listToValue ? null, ... } @@ -66,6 +66,16 @@ + + + listToValue + + + + A function for turning a list of values into a single value. + + + It returns a set with INI-specific attributes type and generate as specified below. diff --git a/nixos/modules/services/computing/slurm/slurm.nix b/nixos/modules/services/computing/slurm/slurm.nix index 0b52f8afed83..a3dee94e2dc5 100644 --- a/nixos/modules/services/computing/slurm/slurm.nix +++ b/nixos/modules/services/computing/slurm/slurm.nix @@ -403,9 +403,7 @@ in requires = [ "munged.service" "mysql.service" ]; preStart = '' - cp ${slurmdbdConf} ${configPath} - chmod 600 ${configPath} - chown ${cfg.user} ${configPath} + install -m 600 -o ${cfg.user} -T ${slurmdbdConf} ${configPath} ${optionalString (cfg.dbdserver.storagePassFile != null) '' echo "StoragePass=$(cat ${cfg.dbdserver.storagePassFile})" \ >> ${configPath} diff --git a/nixos/modules/services/networking/searx.nix b/nixos/modules/services/networking/searx.nix index a515e4a3dc3b..04f7d7e31f46 100644 --- a/nixos/modules/services/networking/searx.nix +++ b/nixos/modules/services/networking/searx.nix @@ -4,23 +4,25 @@ with lib; let runDir = "/run/searx"; + cfg = config.services.searx; + settingsFile = pkgs.writeText "settings.yml" + (builtins.toJSON cfg.settings); + generateConfig = '' cd ${runDir} # write NixOS settings as JSON - cat <<'EOF' > settings.yml - ${builtins.toJSON cfg.settings} - EOF + ( + umask 077 + cp --no-preserve=mode ${settingsFile} settings.yml + ) # substitute environment variables env -0 | while IFS='=' read -r -d ''' n v; do sed "s#@$n@#$v#g" -i settings.yml done - - # set strict permissions - chmod 400 settings.yml ''; settingType = with types; (oneOf diff --git a/pkgs/applications/misc/metadata-cleaner/default.nix b/pkgs/applications/misc/metadata-cleaner/default.nix index 6807e056152c..d5f2a4b2462b 100644 --- a/pkgs/applications/misc/metadata-cleaner/default.nix +++ b/pkgs/applications/misc/metadata-cleaner/default.nix @@ -17,7 +17,7 @@ python3.pkgs.buildPythonApplication rec { pname = "metadata-cleaner"; - version = "1.0.5"; + version = "1.0.6"; format = "other"; @@ -25,7 +25,7 @@ python3.pkgs.buildPythonApplication rec { owner = "rmnvgr"; repo = "metadata-cleaner"; rev = "v${version}"; - sha256 = "sha256-9s9i703Svql1Nn1M1sFp3FOtLGjuxXi6YR6nsUJCkeg="; + sha256 = "0k9qnycaqxnmsjsyxqgip6xr5w9affzxjc4zyb38ajbq4arfq5wv"; }; nativeBuildInputs = [ diff --git a/pkgs/pkgs-lib/formats.nix b/pkgs/pkgs-lib/formats.nix index 14589f8ecdc3..4b6982f387d0 100644 --- a/pkgs/pkgs-lib/formats.nix +++ b/pkgs/pkgs-lib/formats.nix @@ -56,7 +56,16 @@ rec { }; }; - ini = { listsAsDuplicateKeys ? false, ... }@args: { + ini = { + # Represents lists as duplicate keys + listsAsDuplicateKeys ? false, + # Alternative to listsAsDuplicateKeys, converts list to non-list + # listToValue :: [IniAtom] -> IniAtom + listToValue ? null, + ... + }@args: + assert !listsAsDuplicateKeys || listToValue == null; + { type = with lib.types; let @@ -74,12 +83,25 @@ rec { coercedTo singleIniAtom lib.singleton (listOf singleIniAtom) // { description = singleIniAtom.description + " or a list of them for duplicate keys"; } + else if listToValue != null then + coercedTo singleIniAtom lib.singleton (nonEmptyListOf singleIniAtom) // { + description = singleIniAtom.description + " or a non-empty list of them"; + } else singleIniAtom; in attrsOf (attrsOf iniAtom); - generate = name: value: pkgs.writeText name (lib.generators.toINI args value); + generate = name: value: + let + transformedValue = + if listToValue != null + then + lib.mapAttrs (section: lib.mapAttrs (key: val: + if lib.isList val then listToValue val else val + )) value + else value; + in pkgs.writeText name (lib.generators.toINI (removeAttrs args ["listToValue"]) transformedValue); }; diff --git a/pkgs/pkgs-lib/tests/formats.nix b/pkgs/pkgs-lib/tests/formats.nix index 16b760a5ada1..2c117e29e9ba 100644 --- a/pkgs/pkgs-lib/tests/formats.nix +++ b/pkgs/pkgs-lib/tests/formats.nix @@ -124,6 +124,22 @@ in runBuildTests { ''; }; + testIniListToValue = { + drv = evalFormat formats.ini { listToValue = concatMapStringsSep ", " (generators.mkValueStringDefault {}); } { + foo = { + bar = [ null true "test" 1.2 10 ]; + baz = false; + qux = "qux"; + }; + }; + expected = '' + [foo] + bar=null, true, test, 1.200000, 10 + baz=false + qux=qux + ''; + }; + testTomlAtoms = { drv = evalFormat formats.toml {} { false = false; diff --git a/pkgs/servers/computing/slurm/default.nix b/pkgs/servers/computing/slurm/default.nix index 25181590ed10..721bbc4735fc 100644 --- a/pkgs/servers/computing/slurm/default.nix +++ b/pkgs/servers/computing/slurm/default.nix @@ -9,7 +9,7 @@ stdenv.mkDerivation rec { pname = "slurm"; - version = "20.11.5.1"; + version = "20.11.6.1"; # N.B. We use github release tags instead of https://www.schedmd.com/downloads.php # because the latter does not keep older releases. @@ -18,7 +18,7 @@ stdenv.mkDerivation rec { repo = "slurm"; # The release tags use - instead of . rev = "${pname}-${builtins.replaceStrings ["."] ["-"] version}"; - sha256 = "1anzjv9sdl1a3j6sxsy2q8dy4dax1a4yqc9rnprlzymjkgb8hy75"; + sha256 = "1c2dqqddw5bfb27smq7rqa7v1wymdj155ky50rbyvl36pmhc9djp"; }; outputs = [ "out" "dev" ]; diff --git a/pkgs/tools/system/bpytop/default.nix b/pkgs/tools/system/bpytop/default.nix index ca53a1956e0b..8cb3c16bebb9 100644 --- a/pkgs/tools/system/bpytop/default.nix +++ b/pkgs/tools/system/bpytop/default.nix @@ -7,13 +7,13 @@ stdenv.mkDerivation rec { pname = "bpytop"; - version = "1.0.64"; + version = "1.0.65"; src = fetchFromGitHub { owner = "aristocratos"; repo = pname; rev = "v${version}"; - sha256 = "sha256-BwpMBPTWSrfmz7SHYa1+SZ79V2YZdIkZcOTLtlVlgr8="; + sha256 = "sha256-sWANeoUbvnrTksqfeIRU4a5XeX7QVzT9+ZT3R5Utp+4="; }; nativeBuildInputs = [ makeWrapper ];