Loading nixos/modules/services/misc/ananicy.nix +110 −76 Original line number Diff line number Diff line { config, lib, pkgs, ... }: { config, lib, pkgs, ... }: let cfg = config.services.ananicy; configFile = pkgs.writeText "ananicy.conf" (lib.generators.toKeyValue { } cfg.settings); extraRules = pkgs.writeText "extraRules" (lib.concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraRules); extraTypes = pkgs.writeText "extraTypes" (lib.concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraTypes); extraCgroups = pkgs.writeText "extraCgroups" (lib.concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraCgroups); servicename = if ((lib.getName cfg.package) == (lib.getName pkgs.ananicy-cpp)) then "ananicy-cpp" else "ananicy"; extraRules = pkgs.writeText "extraRules" ( lib.concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraRules ); extraTypes = pkgs.writeText "extraTypes" ( lib.concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraTypes ); extraCgroups = pkgs.writeText "extraCgroups" ( lib.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 { options = { services.ananicy = { options.services.ananicy = { enable = lib.mkEnableOption "Ananicy, an auto nice daemon"; package = lib.mkPackageOption pkgs "ananicy" { example = "ananicy-cpp"; }; package = lib.mkPackageOption pkgs "ananicy" { example = "ananicy-cpp"; }; rulesProvider = lib.mkPackageOption pkgs "ananicy" { example = "ananicy-cpp"; } // { rulesProvider = lib.mkPackageOption pkgs "ananicy" { example = "ananicy-cpp"; } // { description = '' Which package to copy default rules,types,cgroups from. ''; }; settings = lib.mkOption { type = with lib.types; attrsOf (oneOf [ int bool str ]); type = with lib.types; attrsOf (oneOf [ int bool str ]); default = { }; example = { apply_nice = false; Loading @@ -45,8 +58,14 @@ in <https://gitlab.com/ananicy-cpp/ananicy-cpp/#global-configuration> ''; example = [ { name = "eog"; type = "Image-Viewer"; } { name = "fdupes"; type = "BG_CPUIO"; } { name = "eog"; type = "Image-Viewer"; } { name = "fdupes"; type = "BG_CPUIO"; } ]; }; extraTypes = lib.mkOption { Loading @@ -57,8 +76,17 @@ in <https://gitlab.com/ananicy-cpp/ananicy-cpp/#types> ''; example = [ { type = "my_type"; nice = 19; other_parameter = "value"; } { type = "compiler"; nice = 19; sched = "batch"; ioclass = "idle"; } { type = "my_type"; nice = 19; other_parameter = "value"; } { type = "compiler"; nice = 19; sched = "batch"; ioclass = "idle"; } ]; }; extraCgroups = lib.mkOption { Loading @@ -69,11 +97,13 @@ in <https://gitlab.com/ananicy-cpp/ananicy-cpp/#cgroups> ''; example = [ { cgroup = "cpu80"; CPUQuota = 80; } { cgroup = "cpu80"; CPUQuota = 80; } ]; }; }; }; config = lib.mkIf cfg.enable { environment = { Loading Loading @@ -111,16 +141,22 @@ in apply_sched = mkOD true; apply_oom_score_adj = mkOD true; apply_cgroup = mkOD true; } // (if ((lib.getName cfg.package) == (lib.getName pkgs.ananicy-cpp)) then { } // ( if servicename == "ananicy-cpp" then { # 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 = true; log_applied_rule = mkOD false; } else { } else { # https://github.com/Nefelim4ag/Ananicy/blob/master/ananicy.d/ananicy.conf check_disks_schedulers = mkOD true; check_freq = mkOD 5; }); } ); systemd = { packages = [ cfg.package ]; Loading @@ -130,7 +166,5 @@ in }; }; meta = { maintainers = with lib.maintainers; [ artturin ]; }; meta.maintainers = with lib.maintainers; [ artturin ]; } Loading
nixos/modules/services/misc/ananicy.nix +110 −76 Original line number Diff line number Diff line { config, lib, pkgs, ... }: { config, lib, pkgs, ... }: let cfg = config.services.ananicy; configFile = pkgs.writeText "ananicy.conf" (lib.generators.toKeyValue { } cfg.settings); extraRules = pkgs.writeText "extraRules" (lib.concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraRules); extraTypes = pkgs.writeText "extraTypes" (lib.concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraTypes); extraCgroups = pkgs.writeText "extraCgroups" (lib.concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraCgroups); servicename = if ((lib.getName cfg.package) == (lib.getName pkgs.ananicy-cpp)) then "ananicy-cpp" else "ananicy"; extraRules = pkgs.writeText "extraRules" ( lib.concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraRules ); extraTypes = pkgs.writeText "extraTypes" ( lib.concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.extraTypes ); extraCgroups = pkgs.writeText "extraCgroups" ( lib.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 { options = { services.ananicy = { options.services.ananicy = { enable = lib.mkEnableOption "Ananicy, an auto nice daemon"; package = lib.mkPackageOption pkgs "ananicy" { example = "ananicy-cpp"; }; package = lib.mkPackageOption pkgs "ananicy" { example = "ananicy-cpp"; }; rulesProvider = lib.mkPackageOption pkgs "ananicy" { example = "ananicy-cpp"; } // { rulesProvider = lib.mkPackageOption pkgs "ananicy" { example = "ananicy-cpp"; } // { description = '' Which package to copy default rules,types,cgroups from. ''; }; settings = lib.mkOption { type = with lib.types; attrsOf (oneOf [ int bool str ]); type = with lib.types; attrsOf (oneOf [ int bool str ]); default = { }; example = { apply_nice = false; Loading @@ -45,8 +58,14 @@ in <https://gitlab.com/ananicy-cpp/ananicy-cpp/#global-configuration> ''; example = [ { name = "eog"; type = "Image-Viewer"; } { name = "fdupes"; type = "BG_CPUIO"; } { name = "eog"; type = "Image-Viewer"; } { name = "fdupes"; type = "BG_CPUIO"; } ]; }; extraTypes = lib.mkOption { Loading @@ -57,8 +76,17 @@ in <https://gitlab.com/ananicy-cpp/ananicy-cpp/#types> ''; example = [ { type = "my_type"; nice = 19; other_parameter = "value"; } { type = "compiler"; nice = 19; sched = "batch"; ioclass = "idle"; } { type = "my_type"; nice = 19; other_parameter = "value"; } { type = "compiler"; nice = 19; sched = "batch"; ioclass = "idle"; } ]; }; extraCgroups = lib.mkOption { Loading @@ -69,11 +97,13 @@ in <https://gitlab.com/ananicy-cpp/ananicy-cpp/#cgroups> ''; example = [ { cgroup = "cpu80"; CPUQuota = 80; } { cgroup = "cpu80"; CPUQuota = 80; } ]; }; }; }; config = lib.mkIf cfg.enable { environment = { Loading Loading @@ -111,16 +141,22 @@ in apply_sched = mkOD true; apply_oom_score_adj = mkOD true; apply_cgroup = mkOD true; } // (if ((lib.getName cfg.package) == (lib.getName pkgs.ananicy-cpp)) then { } // ( if servicename == "ananicy-cpp" then { # 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 = true; log_applied_rule = mkOD false; } else { } else { # https://github.com/Nefelim4ag/Ananicy/blob/master/ananicy.d/ananicy.conf check_disks_schedulers = mkOD true; check_freq = mkOD 5; }); } ); systemd = { packages = [ cfg.package ]; Loading @@ -130,7 +166,5 @@ in }; }; meta = { maintainers = with lib.maintainers; [ artturin ]; }; meta.maintainers = with lib.maintainers; [ artturin ]; }