mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
`literalExpression` is intended just to signify code that needs to stay a string that gets represented exactly as-is for docs. It has been misused heavily and people get confused repeatedly on when or not to use it because of the rampant misuse.
78 lines
1.8 KiB
Nix
78 lines
1.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.pueue;
|
|
yamlFormat = pkgs.formats.yaml { };
|
|
configDir =
|
|
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support" else config.xdg.configHome;
|
|
configFile = yamlFormat.generate "pueue.yaml" ({ shared = { }; } // cfg.settings);
|
|
pueuedBin = "${cfg.package}/bin/pueued";
|
|
in
|
|
{
|
|
meta.maintainers = [ ];
|
|
|
|
options.services.pueue = {
|
|
enable = lib.mkEnableOption "Pueue, CLI process scheduler and manager";
|
|
|
|
package = lib.mkPackageOption pkgs "pueue" { nullable = true; };
|
|
|
|
settings = lib.mkOption {
|
|
inherit (yamlFormat) type;
|
|
default = { };
|
|
example = {
|
|
daemon = {
|
|
default_parallel_tasks = 2;
|
|
};
|
|
};
|
|
description = ''
|
|
Configuration written to
|
|
{file}`$XDG_CONFIG_HOME/pueue/pueue.yml`.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
|
|
|
home.file."${configDir}/pueue/pueue.yml".source = configFile;
|
|
|
|
systemd.user = lib.mkIf (cfg.package != null) {
|
|
services.pueued = {
|
|
Unit = {
|
|
Description = "Pueue Daemon - CLI process scheduler and manager";
|
|
};
|
|
|
|
Service = {
|
|
Restart = "on-failure";
|
|
ExecStart = "${pueuedBin} -v -c ${configFile}";
|
|
};
|
|
|
|
Install.WantedBy = [ "default.target" ];
|
|
};
|
|
};
|
|
|
|
launchd.agents.pueued = lib.mkIf (cfg.package != null) {
|
|
enable = true;
|
|
|
|
config = {
|
|
ProgramArguments = [
|
|
pueuedBin
|
|
"-v"
|
|
"-c"
|
|
"${configFile}"
|
|
];
|
|
KeepAlive = {
|
|
Crashed = true;
|
|
SuccessfulExit = false;
|
|
};
|
|
ProcessType = "Background";
|
|
RunAtLoad = true;
|
|
};
|
|
};
|
|
};
|
|
}
|