nix/home/util/ez.nix
2023-09-28 13:15:38 +10:00

51 lines
1.1 KiB
Nix

{
config,
lib,
pkgs,
...
}: {
options = {
ezServices = with lib;
mkOption {
type = with types; attrsOf str;
default = {};
};
ezConf = with lib;
mkOption {
type = with types; attrsOf path;
default = {};
};
# for launching a systemd target on wm startup
extraTarget = with lib;
mkOption {
type = with types; listOf str;
default = [];
};
};
config = rec {
systemd.user.services = with pkgs;
builtins.mapAttrs (name: cmd: {
Unit = {
Description = "${name}";
Requires = ["graphical-session.target"] ++ config.extraTarget;
After = ["graphical-session.target"] ++ config.extraTarget;
};
Service = {
ExecStart = cmd;
};
Install = {
WantedBy = ["graphical-session.target"] ++ config.extraTarget;
};
})
config.ezServices;
xdg.configFile =
builtins.mapAttrs (name: value: {
enable = true;
source = value;
})
config.ezConf;
};
}