mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
Merge pull request #242309 from Artturin/ananicyextraxadd
This commit is contained in:
commit
d1abbbd9b6
5 changed files with 93 additions and 22 deletions
|
@ -5,7 +5,9 @@ with lib;
|
|||
let
|
||||
cfg = config.services.ananicy;
|
||||
configFile = pkgs.writeText "ananicy.conf" (generators.toKeyValue { } cfg.settings);
|
||||
extraRules = pkgs.writeText "extraRules" cfg.extraRules;
|
||||
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
|
||||
{
|
||||
|
@ -23,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 = { };
|
||||
|
@ -35,20 +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-View" }
|
||||
{ "name": "fdupes", "type": "BG_CPUIO" }
|
||||
'''
|
||||
example = [
|
||||
{ name = "eog"; type = "Image-Viewer"; }
|
||||
{ name = "fdupes"; type = "BG_CPUIO"; }
|
||||
];
|
||||
};
|
||||
extraTypes = mkOption {
|
||||
type = with types; listOf attrs;
|
||||
default = [ ];
|
||||
description = lib.mdDoc ''
|
||||
Types to write in 'nixTypes.types'. See:
|
||||
<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"; }
|
||||
];
|
||||
};
|
||||
extraCgroups = mkOption {
|
||||
type = with types; listOf attrs;
|
||||
default = [ ];
|
||||
description = lib.mdDoc ''
|
||||
Cgroups to write in 'nixCgroups.cgroups'. See:
|
||||
<https://gitlab.com/ananicy-cpp/ananicy-cpp/#cgroups>
|
||||
'';
|
||||
example = [
|
||||
{ cgroup = "cpu80"; CPUQuota = 80; }
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -59,10 +91,18 @@ 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
|
||||
rm $out/ananicy.conf
|
||||
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
|
||||
${optionalString (cfg.extraRules != "") "cp ${extraRules} $out/nixRules.rules"}
|
||||
${optionalString (cfg.extraRules != [ ]) "cp ${extraRules} $out/nixRules.rules"}
|
||||
${optionalString (cfg.extraTypes != [ ]) "cp ${extraTypes} $out/nixTypes.types"}
|
||||
${optionalString (cfg.extraCgroups != [ ]) "cp ${extraCgroups} $out/nixCgroups.cgroups"}
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -85,6 +125,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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue