fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.3 KiB60 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.services.pueue;
8  yamlFormat = pkgs.formats.yaml { };
9  configFile = yamlFormat.generate "pueue.yaml" cfg.settings;
10
11in {
12  meta.maintainers = [ maintainers.AndersonTorres ];
13
14  options.services.pueue = {
15    enable = mkEnableOption "Pueue, CLI process scheduler and manager";
16
17    package = mkPackageOption pkgs "pueue" { };
18
19    settings = mkOption {
20      type = yamlFormat.type;
21      default = { };
22      example = literalExpression ''
23        {
24          daemon = {
25            default_parallel_tasks = 2;
26          };
27        }
28      '';
29      description = ''
30        Configuration written to
31        {file}`$XDG_CONFIG_HOME/pueue/pueue.yml`.
32      '';
33    };
34  };
35
36  config = mkIf cfg.enable {
37    assertions =
38      [ (hm.assertions.assertPlatform "services.pueue" pkgs platforms.linux) ];
39
40    home.packages = [ cfg.package ];
41
42    xdg.configFile =
43      mkIf (cfg.settings != { }) { "pueue/pueue.yml".source = configFile; };
44
45    systemd.user = {
46      services.pueued = {
47        Unit = {
48          Description = "Pueue Daemon - CLI process scheduler and manager";
49        };
50
51        Service = {
52          Restart = "on-failure";
53          ExecStart = "${cfg.package}/bin/pueued -v -c ${configFile}";
54        };
55
56        Install.WantedBy = [ "default.target" ];
57      };
58    };
59  };
60}