feat: scratchpads
All checks were successful
Nix Build / nix build (push) Successful in 23s

This commit is contained in:
atagen 2026-02-25 17:04:50 +11:00
parent 4c748be113
commit db66162b3f
3 changed files with 127 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,24 @@ in
PrivateTmp = true;
};
};
environment.etc."niri-tag/config.toml".text =
let
scratchpads =
let
contents =
lib.mapAttrsToList (app: number: "${app} = ${toString number}") cfg.scratchpads
|> lib.concatStringsSep "\n";
in
lib.optionalString ((lib.attrsToList cfg.scratchpads |> builtins.length) > 0) ''
[scratchpads]
${contents}
'';
in
''
prepopulate = ${toString cfg.prepopulate}
strict = ${lib.boolToString cfg.strict}
${scratchpads}
'';
environment.systemPackages = [ cfg.package ];
};
}