feat: scratchpads
Some checks failed
Nix Build / nix build (push) Has been cancelled

This commit is contained in:
atagen 2026-02-25 17:04:50 +11:00
parent 4c748be113
commit b970e02f36
3 changed files with 125 additions and 43 deletions

View file

@ -8,9 +8,12 @@ let
inherit (lib)
mkEnableOption
mkPackageOption
mkOption
mkIf
getExe
types
;
inherit (types) attrsOf bool;
name = "Niri Tag Manager";
in
{
@ -20,6 +23,18 @@ in
nullable = true;
default = "niri-tag";
};
prepopulate = mkOption {
type = types.numbers.between 0 255;
default = 3;
};
scratchpads = mkOption {
type = attrsOf (types.numbers.between 1 255);
default = { };
};
strict = mkOption {
type = bool;
default = true;
};
};
config =
let
@ -40,6 +55,22 @@ in
PrivateTmp = true;
};
};
etc.environment."/etc/niri-tag/config.toml" =
let
scratchpads =
let
contents = lib.mapAttrsToList (app: number: "${app} = ${toString number}\n") cfg.scratchpads;
in
lib.optionalString (lib.count <| lib.attrsToList cfg.scratchpads) ''
[scratchpads]
${contents}
'';
in
pkgs.writeTextFile "config.toml" ''
prepopulate = ${toString cfg.prepopulate}
strict = ${lib.boolToString cfg.strict}
${scratchpads}
'';
environment.systemPackages = [ cfg.package ];
};
}