From b04a04929cccfaabf811a8442b9b03da1c7ea9fe Mon Sep 17 00:00:00 2001 From: Artturin Date: Sat, 8 Jul 2023 19:42:46 +0300 Subject: [PATCH 1/6] nixos/ananicy: add extraTypes, extraCgroups --- nixos/modules/services/misc/ananicy.nix | 32 ++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/ananicy.nix b/nixos/modules/services/misc/ananicy.nix index d2287fba6afc..59fc98792843 100644 --- a/nixos/modules/services/misc/ananicy.nix +++ b/nixos/modules/services/misc/ananicy.nix @@ -6,6 +6,8 @@ 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; servicename = if ((lib.getName cfg.package) == (lib.getName pkgs.ananicy-cpp)) then "ananicy-cpp" else "ananicy"; in { @@ -48,7 +50,33 @@ in { "name": "fdupes", "type": "BG_CPUIO" } ''' ''; - + }; + extraTypes = mkOption { + type = types.str; + default = ""; + description = lib.mdDoc '' + Extra types in json format on separate lines. See: + + ''; + example = literalExpression '' + ''' + {"type": "my_type", "nice": 19, "other_parameter": "value"} + {"type": "compiler", "nice": 19, "sched": "batch", "ioclass": "idle"} + ''' + ''; + }; + extraCgroups = mkOption { + type = types.str; + default = ""; + description = lib.mdDoc '' + Extra cgroups in json format on separate lines. See: + + ''; + example = literalExpression '' + ''' + {"cgroup": "cpu80", "CPUQuota": 80} + ''' + ''; }; }; }; @@ -63,6 +91,8 @@ in rm $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"} ''; }; From ff28d7a9823583812c4edc366dcd1d39647bd38c Mon Sep 17 00:00:00 2001 From: Artturin Date: Sat, 8 Jul 2023 20:19:13 +0300 Subject: [PATCH 2/6] nixos/ananicy: don't error if $out/ananicy-cpp doesn't exist copy new rule --- nixos/modules/services/misc/ananicy.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/ananicy.nix b/nixos/modules/services/misc/ananicy.nix index 59fc98792843..fde3dfc6492f 100644 --- a/nixos/modules/services/misc/ananicy.nix +++ b/nixos/modules/services/misc/ananicy.nix @@ -88,7 +88,8 @@ in mkdir -p $out # ananicy-cpp does not include rules or settings on purpose cp -r ${pkgs.ananicy}/etc/ananicy.d/* $out - rm $out/ananicy.conf + # 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"} @@ -115,6 +116,7 @@ in # https://gitlab.com/ananicy-cpp/ananicy-cpp/-/blob/master/src/config.cpp#L12 loglevel = mkOD "warn"; # default is info but its spammy cgroup_realtime_workaround = mkOD config.systemd.enableUnifiedCgroupHierarchy; + log_applied_rule = mkOD false; } else { # https://github.com/Nefelim4ag/Ananicy/blob/master/ananicy.d/ananicy.conf check_disks_schedulers = mkOD true; From aae2268e0a451c16570962945fffa8876df883d5 Mon Sep 17 00:00:00 2001 From: Artturin Date: Sat, 8 Jul 2023 20:28:45 +0300 Subject: [PATCH 3/6] nixos/ananicy-cpp: add rulesProvider --- nixos/modules/services/misc/ananicy.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/ananicy.nix b/nixos/modules/services/misc/ananicy.nix index fde3dfc6492f..a15e72e70163 100644 --- a/nixos/modules/services/misc/ananicy.nix +++ b/nixos/modules/services/misc/ananicy.nix @@ -25,6 +25,16 @@ in ''; }; + rulesProvider = mkOption { + type = types.package; + default = pkgs.ananicy; + defaultText = literalExpression "pkgs.ananicy"; + example = literalExpression "pkgs.ananicy-cpp"; + description = lib.mdDoc '' + Which package to copy default rules,types,cgroups from. + ''; + }; + settings = mkOption { type = with types; attrsOf (oneOf [ int bool str ]); default = { }; @@ -87,7 +97,12 @@ in etc."ananicy.d".source = pkgs.runCommandLocal "ananicyfiles" { } '' mkdir -p $out # ananicy-cpp does not include rules or settings on purpose - cp -r ${pkgs.ananicy}/etc/ananicy.d/* $out + if [[ -d "${cfg.rulesProvider}/etc/ananicy.d/00-default" ]]; then + cp -r ${cfg.rulesProvider}/etc/ananicy.d/* $out + else + cp -r ${cfg.rulesProvider}/* $out + fi + # configured through .setings rm -f $out/ananicy.conf cp ${configFile} $out/ananicy.conf From 7b0df0c04225a107e283a210cbee95f462d8ad7d Mon Sep 17 00:00:00 2001 From: Artturin Date: Sat, 8 Jul 2023 20:43:46 +0300 Subject: [PATCH 4/6] ananicy-cpp-rules: init at unstable-2023-06-28 --- pkgs/misc/ananicy-rules-cachyos/default.nix | 32 +++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 pkgs/misc/ananicy-rules-cachyos/default.nix diff --git a/pkgs/misc/ananicy-rules-cachyos/default.nix b/pkgs/misc/ananicy-rules-cachyos/default.nix new file mode 100644 index 000000000000..575f582d2c9f --- /dev/null +++ b/pkgs/misc/ananicy-rules-cachyos/default.nix @@ -0,0 +1,32 @@ +{ lib, stdenv, fetchFromGitHub }: + +stdenv.mkDerivation rec { + pname = "ananicy"; + version = "unstable-2023-06-28"; + + src = fetchFromGitHub { + owner = "CachyOS"; + repo = "ananicy-rules"; + rev = "b2b4342d769bc3c6abc4ce77bd53d6ca06d659e5"; + sha256 = "sha256-TGX7GlfSeKu68mVM71/kdJH31gzMmhzCAqA390aEq8U="; + }; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preBuild + mkdir -p $out + cp -r * $out + rm $out/README.md + runHook postBuild + ''; + + meta = with lib; { + homepage = "https://github.com/CachyOS/ananicy-rules"; + description = "ananicy-cpp-rules for CachyOS "; + license = licenses.gpl3Only; + platforms = platforms.linux; + maintainers = with maintainers; [ artturin ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8dc19e94c7fa..71e8e4edde54 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -28456,6 +28456,8 @@ with pkgs; ananicy-cpp = callPackage ../misc/ananicy-cpp { }; + ananicy-rules-cachyos = callPackage ../misc/ananicy-rules-cachyos { }; + andagii = callPackage ../data/fonts/andagii { }; andika = callPackage ../data/fonts/andika { }; From 1b1f25312dea83efcea0307e6407af5d9adc93aa Mon Sep 17 00:00:00 2001 From: Artturin Date: Sat, 8 Jul 2023 21:01:08 +0300 Subject: [PATCH 5/6] ananicy: unstable-2021-11-05 -> unstable-2023-03-21 type's were renamed so this will break some user rules --- nixos/modules/services/misc/ananicy.nix | 2 +- pkgs/misc/ananicy/default.nix | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/nixos/modules/services/misc/ananicy.nix b/nixos/modules/services/misc/ananicy.nix index a15e72e70163..809eee033696 100644 --- a/nixos/modules/services/misc/ananicy.nix +++ b/nixos/modules/services/misc/ananicy.nix @@ -56,7 +56,7 @@ in ''; example = literalExpression '' ''' - { "name": "eog", "type": "Image-View" } + { "name": "eog", "type": "Image-Viewer" } { "name": "fdupes", "type": "BG_CPUIO" } ''' ''; diff --git a/pkgs/misc/ananicy/default.nix b/pkgs/misc/ananicy/default.nix index 3c2392df731d..62daaad2c604 100644 --- a/pkgs/misc/ananicy/default.nix +++ b/pkgs/misc/ananicy/default.nix @@ -2,13 +2,13 @@ stdenv.mkDerivation rec { pname = "ananicy"; - version = "unstable-2021-11-05"; + version = "unstable-2023-03-21"; src = fetchFromGitHub { owner = "nefelim4ag"; repo = "ananicy"; - rev = "b8968e9b32b0e4e6a01dc2314e43de8fee9da691"; - sha256 = "sha256-tlPY81xdUpZrDYdApXooZ0Mst0n7ARVHyUrmymqg0rk="; + rev = "1e2cc9a62ba3b6793e59da66aa0039f89e1ad49f"; + sha256 = "sha256-nHp47eYI36edka+cBMzayPHEflAzpgLx0VehhsyYpwI="; }; patches = [ @@ -20,12 +20,6 @@ stdenv.mkDerivation rec { # only used for debian packaging. lets exclude it so the patch applies even when that file is changed excludes = [ "package.sh" ]; }) - # https://github.com/Nefelim4ag/Ananicy/pull/439 - # fix syntax error - (fetchpatch { - url = "https://github.com/Nefelim4ag/Ananicy/commit/0f8b809298ccfd88d0e2ab952d6e4131865246da.patch"; - sha256 = "sha256-PWE4F0G97gecgc9HnG7ScA78+QVc8u8aF9u74qVChX0="; - }) ]; nativeBuildInputs = [ makeWrapper ]; From 4cf80061735a4cb12d87fd8c5c9e90d1ecc3f040 Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 12 Jul 2023 20:12:10 +0300 Subject: [PATCH 6/6] nixos/ananicy: take `listOf attrs` instead of `string` --- .../manual/release-notes/rl-2311.section.md | 2 + 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: ''; - 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: ''; - 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: ''; - 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"} ''; };