mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
44 lines
1.1 KiB
Nix
44 lines
1.1 KiB
Nix
{ config, lib, pkgs, ... }: with lib;
|
|
|
|
let cfg = config.programs.swaylock; in
|
|
{
|
|
options.programs.swaylock = {
|
|
enable = mkEnableOption "locker integration";
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.swaylock-effects;
|
|
};
|
|
wrapped = mkOption {
|
|
type = types.package;
|
|
};
|
|
script = mkOption {
|
|
type = types.path;
|
|
default = "${cfg.wrapped}/bin/swaylock";
|
|
};
|
|
colors = mkOption {
|
|
type = types.attrsOf types.str;
|
|
default = { };
|
|
};
|
|
args = mkOption {
|
|
type = with types; attrsOf (oneOf [ str bool int float ]);
|
|
default = { };
|
|
};
|
|
};
|
|
config = mkIf cfg.enable {
|
|
programs.swaylock = let
|
|
argList = concatLists (mapAttrsToList (arg: value:
|
|
if value == true then
|
|
singleton "--${toString arg}"
|
|
else [
|
|
"--${arg}"
|
|
(toString value)
|
|
]) cfg.args);
|
|
argStr = escapeShellArgs argList;
|
|
in {
|
|
args = mapAttrs' (arg: color: nameValuePair ("${arg}-color") (removePrefix "#" color)) cfg.colors;
|
|
wrapped = pkgs.writeShellScriptBin "swaylock" ''
|
|
${cfg.package}/bin/swaylock ${argStr} $@
|
|
'';
|
|
};
|
|
};
|
|
}
|