From 7bb4576f46f7f7590347e21b14d2f6a2dbc76638 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Fri, 12 Aug 2022 23:37:04 -0300 Subject: [PATCH] pueue: add module --- .github/CODEOWNERS | 2 ++ modules/misc/news.nix | 8 ++++++ modules/modules.nix | 1 + modules/services/pueue.nix | 59 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 modules/services/pueue.nix diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9979fa816..51bea0ec7 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -421,6 +421,8 @@ Makefile @thiagokokada /modules/services/poweralertd.nix @ThibautMarty +/modules/services/pueue.nix @AndersonTorres + /modules/services/pulseeffects.nix @jonringer /modules/services/random-background.nix @rycee diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 188206cf9..bfc736671 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -653,6 +653,14 @@ in A new module is available: 'programs.bashmount'. ''; } + + { + time = "2022-08-25T21:01:37+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.pueue'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 8a4ac0ab0..92433906b 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -244,6 +244,7 @@ let ./services/plex-mpv-shim.nix ./services/polybar.nix ./services/poweralertd.nix + ./services/pueue.nix ./services/pulseeffects.nix ./services/random-background.nix ./services/recoll.nix diff --git a/modules/services/pueue.nix b/modules/services/pueue.nix new file mode 100644 index 000000000..b812e2710 --- /dev/null +++ b/modules/services/pueue.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.pueue; + yamlFormat = pkgs.formats.yaml { }; + configFile = yamlFormat.generate "pueue.yaml" cfg.settings; + +in { + meta.maintainers = [ maintainers.AndersonTorres ]; + + options.services.pueue = { + enable = mkEnableOption "Pueue, CLI process scheduler and manager"; + + package = mkPackageOption pkgs "pueue" { }; + + settings = mkOption { + type = yamlFormat.type; + default = { }; + example = literalExpression '' + { + daemon = { + default_parallel_tasks = 2; + }; + } + ''; + description = '' + Configuration written to + $XDG_CONFIG_HOME/pueue/pueue.yml. + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = + [ (hm.assertions.assertPlatform "services.pueue" pkgs platforms.linux) ]; + + home.packages = [ cfg.package ]; + + xdg.configFile."pueue/pueue.yml".source = configFile; + + systemd.user = { + services.pueued = { + Unit = { + Description = "Pueue Daemon - CLI process scheduler and manager"; + }; + + Service = { + Restart = "on-failure"; + ExecStart = "${cfg.package}/bin/pueued -v -c ${configFile}"; + }; + + Install.WantedBy = [ "default.target" ]; + }; + }; + }; +}