mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
lorri: add nixPackage and enableNotifications options
This commit is contained in:
parent
7a3384c796
commit
a7f0cc2d7b
1 changed files with 42 additions and 1 deletions
|
@ -12,12 +12,22 @@ in {
|
||||||
options.services.lorri = {
|
options.services.lorri = {
|
||||||
enable = mkEnableOption "lorri build daemon";
|
enable = mkEnableOption "lorri build daemon";
|
||||||
|
|
||||||
|
enableNotifications = mkEnableOption "lorri build notifications";
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = pkgs.lorri;
|
default = pkgs.lorri;
|
||||||
defaultText = literalExpression "pkgs.lorri";
|
defaultText = literalExpression "pkgs.lorri";
|
||||||
description = "Which lorri package to install.";
|
description = "Which lorri package to install.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nixPackage = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.nix;
|
||||||
|
defaultText = literalExpression "pkgs.nix";
|
||||||
|
example = literalExpression "pkgs.nixVersions.unstable";
|
||||||
|
description = "Which nix package to use.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -45,7 +55,7 @@ in {
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
Environment = let
|
Environment = let
|
||||||
path = with pkgs;
|
path = with pkgs;
|
||||||
makeSearchPath "bin" [ nix gitMinimal gnutar gzip ];
|
makeSearchPath "bin" [ cfg.nixPackage gitMinimal gnutar gzip ];
|
||||||
in [ "PATH=${path}" ];
|
in [ "PATH=${path}" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -60,6 +70,37 @@ in {
|
||||||
|
|
||||||
Install = { WantedBy = [ "sockets.target" ]; };
|
Install = { WantedBy = [ "sockets.target" ]; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.lorri-notify = mkIf cfg.enableNotifications {
|
||||||
|
Unit = {
|
||||||
|
Description = "lorri build notifications";
|
||||||
|
After = "lorri.service";
|
||||||
|
Requires = "lorri.service";
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
ExecStart = let
|
||||||
|
jqFile = ''
|
||||||
|
(
|
||||||
|
(.Started? | values | "Build starting in \(.nix_file)"),
|
||||||
|
(.Completed? | values | "Build complete in \(.nix_file)"),
|
||||||
|
(.Failure? | values | "Build failed in \(.nix_file)")
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
|
||||||
|
notifyScript = pkgs.writeShellScript "lorri-notify" ''
|
||||||
|
lorri internal stream-events --kind live \
|
||||||
|
| jq --unbuffered '${jqFile}' \
|
||||||
|
| xargs -n 1 notify-send "Lorri Build"
|
||||||
|
'';
|
||||||
|
in toString notifyScript;
|
||||||
|
Restart = "on-failure";
|
||||||
|
Environment = let
|
||||||
|
path = makeSearchPath "bin"
|
||||||
|
(with pkgs; [ bash jq findutils libnotify cfg.package ]);
|
||||||
|
in "PATH=${path}";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue