From 286dd9b3088298e5a4625b517f8e72b1c62e4f74 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Sat, 16 Nov 2019 22:05:08 +0100 Subject: [PATCH] lorri: add service --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/services/lorri.nix | 58 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 modules/services/lorri.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index a00c81ee1..bbc05e230 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1229,6 +1229,13 @@ in it anymore. ''; } + + { + time = "2019-11-17T18:47:40+00:00"; + message = '' + A new module is available: 'services.lorri'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 340f0be33..a3bf286c7 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -115,6 +115,7 @@ let (loadModule ./services/kdeconnect.nix { }) (loadModule ./services/keepassx.nix { }) (loadModule ./services/keybase.nix { }) + (loadModule ./services/lorri.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/mbsync.nix { }) (loadModule ./services/mpd.nix { }) (loadModule ./services/mpdris2.nix { condition = hostPlatform.isLinux; }) diff --git a/modules/services/lorri.nix b/modules/services/lorri.nix new file mode 100644 index 000000000..032ae6377 --- /dev/null +++ b/modules/services/lorri.nix @@ -0,0 +1,58 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.lorri; + +in + +{ + meta.maintainers = [ maintainers.gerschtli ]; + + options = { + services.lorri.enable = mkEnableOption "lorri build daemon"; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.lorri ]; + + systemd.user = { + services.lorri = { + Unit = { + Description = "lorri build daemon"; + Requires = "lorri.socket"; + After = "lorri.socket"; + RefuseManualStart = true; + }; + + Service = { + ExecStart = "${pkgs.lorri}/bin/lorri daemon"; + PrivateTmp = true; + ProtectSystem = "strict"; + ProtectHome = "read-only"; + Restart = "on-failure"; + Environment = + let path = with pkgs; makeSearchPath "bin" [ nix 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" ]; + }; + }; + }; + }; +}