mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 13:39:46 +01:00
36a53d9f26
This process was automated by [my fork of `nix-doc-munge`]. All conversions were automatically checked to produce the same DocBook result when converted back, modulo minor typographical/formatting differences on the acceptable-to-desirable spectrum. To reproduce this commit, run: $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \ nix shell nixpkgs#coreutils \ -c find . -name '*.nix' \ -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \ {} + $ ./format [my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
107 lines
2.9 KiB
Nix
107 lines
2.9 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.lorri;
|
|
|
|
in {
|
|
meta.maintainers = [ maintainers.gerschtli ];
|
|
|
|
options.services.lorri = {
|
|
enable = mkEnableOption (lib.mdDoc "lorri build daemon");
|
|
|
|
enableNotifications =
|
|
mkEnableOption (lib.mdDoc "lorri build notifications");
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.lorri;
|
|
defaultText = literalExpression "pkgs.lorri";
|
|
description = lib.mdDoc "Which lorri package to install.";
|
|
};
|
|
|
|
nixPackage = mkOption {
|
|
type = types.package;
|
|
default = pkgs.nix;
|
|
defaultText = literalExpression "pkgs.nix";
|
|
example = literalExpression "pkgs.nixVersions.unstable";
|
|
description = lib.mdDoc "Which nix package to use.";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "services.lorri" pkgs
|
|
lib.platforms.linux)
|
|
];
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
systemd.user = {
|
|
services.lorri = {
|
|
Unit = {
|
|
Description = "lorri build daemon";
|
|
Requires = "lorri.socket";
|
|
After = "lorri.socket";
|
|
RefuseManualStart = true;
|
|
};
|
|
|
|
Service = {
|
|
ExecStart = "${cfg.package}/bin/lorri daemon";
|
|
PrivateTmp = true;
|
|
ProtectSystem = "strict";
|
|
ProtectHome = "read-only";
|
|
Restart = "on-failure";
|
|
Environment = let
|
|
path = with pkgs;
|
|
makeSearchPath "bin" [ cfg.nixPackage gitMinimal gnutar gzip ];
|
|
in [ "PATH=${path}" ];
|
|
};
|
|
};
|
|
|
|
sockets.lorri = {
|
|
Unit = { Description = "Socket for lorri build daemon"; };
|
|
|
|
Socket = {
|
|
ListenStream = "%t/lorri/daemon.socket";
|
|
RuntimeDirectory = "lorri";
|
|
};
|
|
|
|
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}";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|