diff options
author | Artturin <Artturin@artturin.com> | 2023-07-12 20:12:10 +0300 |
---|---|---|
committer | Artturin <Artturin@artturin.com> | 2023-07-12 20:13:03 +0300 |
commit | 4cf80061735a4cb12d87fd8c5c9e90d1ecc3f040 (patch) | |
tree | 7ec993c0b53a2ecad1401ad285052d9e1f34a774 | |
parent | 1b1f25312dea83efcea0307e6407af5d9adc93aa (diff) | |
download | nixlib-4cf80061735a4cb12d87fd8c5c9e90d1ecc3f040.tar nixlib-4cf80061735a4cb12d87fd8c5c9e90d1ecc3f040.tar.gz nixlib-4cf80061735a4cb12d87fd8c5c9e90d1ecc3f040.tar.bz2 nixlib-4cf80061735a4cb12d87fd8c5c9e90d1ecc3f040.tar.lz nixlib-4cf80061735a4cb12d87fd8c5c9e90d1ecc3f040.tar.xz nixlib-4cf80061735a4cb12d87fd8c5c9e90d1ecc3f040.tar.zst nixlib-4cf80061735a4cb12d87fd8c5c9e90d1ecc3f040.zip |
nixos/ananicy: take `listOf attrs` instead of `string`
-rw-r--r-- | nixos/doc/manual/release-notes/rl-2311.section.md | 2 | ||||
-rw-r--r-- | nixos/modules/services/misc/ananicy.nix | 58 |
2 files changed, 28 insertions, 32 deletions
diff --git a/nixos/doc/manual/release-notes/rl-2311.section.md b/nixos/doc/manual/release-notes/rl-2311.section.md index 29ee2ec5aa61..c78af2d0a36b 100644 --- a/nixos/doc/manual/release-notes/rl-2311.section.md +++ b/nixos/doc/manual/release-notes/rl-2311.section.md @@ -46,6 +46,8 @@ - `getent` has been moved from `glibc`'s `bin` output to its own dedicated output, reducing closure size for many dependents. Dependents using the `getent` alias should not be affected; others should move from using `glibc.bin` or `getBin glibc` to `getent` (which also improves compatibility with non-glibc platforms). +- The `services.ananicy.extraRules` option now has the type of `listOf attrs` instead of `string`. + - `etcd` has been updated to 3.5, you will want to read the [3.3 to 3.4](https://etcd.io/docs/v3.5/upgrades/upgrade_3_4/) and [3.4 to 3.5](https://etcd.io/docs/v3.5/upgrades/upgrade_3_5/) upgrade guides - `consul` has been updated to `1.16.0`. See the [release note](https://github.com/hashicorp/consul/releases/tag/v1.16.0) for more details. Once a new Consul version has started and upgraded its data directory, it generally cannot be downgraded to the previous version. diff --git a/nixos/modules/services/misc/ananicy.nix b/nixos/modules/services/misc/ananicy.nix index 809eee033696..bc1b28efc0ba 100644 --- a/nixos/modules/services/misc/ananicy.nix +++ b/nixos/modules/services/misc/ananicy.nix @@ -5,9 +5,9 @@ with lib; let cfg = config.services.ananicy; configFile = pkgs.writeText "ananicy.conf" (generators.toKeyValue { } cfg.settings); - extraRules = pkgs.writeText "extraRules" cfg.extraRules; - extraTypes = pkgs.writeText "extraTypes" cfg.extraTypes; - extraCgroups = pkgs.writeText "extraCgroups" cfg.extraCgroups; + extraRules = pkgs.writeText "extraRules" (concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraRules); + extraTypes = pkgs.writeText "extraTypes" (concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraTypes); + extraCgroups = pkgs.writeText "extraCgroups" (concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraCgroups); servicename = if ((lib.getName cfg.package) == (lib.getName pkgs.ananicy-cpp)) then "ananicy-cpp" else "ananicy"; in { @@ -47,46 +47,40 @@ in }; extraRules = mkOption { - type = types.str; - default = ""; + type = with types; listOf attrs; + default = [ ]; description = lib.mdDoc '' - Extra rules in json format on separate lines. See: + Rules to write in 'nixRules.rules'. See: <https://github.com/Nefelim4ag/Ananicy#configuration> <https://gitlab.com/ananicy-cpp/ananicy-cpp/#global-configuration> ''; - example = literalExpression '' - ''' - { "name": "eog", "type": "Image-Viewer" } - { "name": "fdupes", "type": "BG_CPUIO" } - ''' - ''; + example = [ + { name = "eog"; type = "Image-Viewer"; } + { name = "fdupes"; type = "BG_CPUIO"; } + ]; }; extraTypes = mkOption { - type = types.str; - default = ""; + type = with types; listOf attrs; + default = [ ]; description = lib.mdDoc '' - Extra types in json format on separate lines. See: + Types to write in 'nixTypes.types'. See: <https://gitlab.com/ananicy-cpp/ananicy-cpp/#types> ''; - example = literalExpression '' - ''' - {"type": "my_type", "nice": 19, "other_parameter": "value"} - {"type": "compiler", "nice": 19, "sched": "batch", "ioclass": "idle"} - ''' - ''; + example = [ + { type = "my_type"; nice = 19; other_parameter = "value"; } + { type = "compiler"; nice = 19; sched = "batch"; ioclass = "idle"; } + ]; }; extraCgroups = mkOption { - type = types.str; - default = ""; + type = with types; listOf attrs; + default = [ ]; description = lib.mdDoc '' - Extra cgroups in json format on separate lines. See: + Cgroups to write in 'nixCgroups.cgroups'. See: <https://gitlab.com/ananicy-cpp/ananicy-cpp/#cgroups> ''; - example = literalExpression '' - ''' - {"cgroup": "cpu80", "CPUQuota": 80} - ''' - ''; + example = [ + { cgroup = "cpu80"; CPUQuota = 80; } + ]; }; }; }; @@ -106,9 +100,9 @@ in # configured through .setings rm -f $out/ananicy.conf cp ${configFile} $out/ananicy.conf - ${optionalString (cfg.extraRules != "") "cp ${extraRules} $out/nixRules.rules"} - ${optionalString (cfg.extraTypes != "") "cp ${extraTypes} $out/nixTypes.types"} - ${optionalString (cfg.extraCgroups != "") "cp ${extraCgroups} $out/nixCgroups.cgroups"} + ${optionalString (cfg.extraRules != [ ]) "cp ${extraRules} $out/nixRules.rules"} + ${optionalString (cfg.extraTypes != [ ]) "cp ${extraTypes} $out/nixTypes.types"} + ${optionalString (cfg.extraCgroups != [ ]) "cp ${extraCgroups} $out/nixCgroups.cgroups"} ''; }; |