at 25.11-pre 1.5 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.services.lorri; 10 socketPath = "lorri/daemon.socket"; 11in 12{ 13 options = { 14 services.lorri = { 15 enable = lib.mkOption { 16 default = false; 17 type = lib.types.bool; 18 description = '' 19 Enables the daemon for `lorri`, a nix-shell replacement for project 20 development. The socket-activated daemon starts on the first request 21 issued by the `lorri` command. 22 ''; 23 }; 24 package = lib.mkOption { 25 default = pkgs.lorri; 26 type = lib.types.package; 27 description = '' 28 The lorri package to use. 29 ''; 30 defaultText = lib.literalExpression "pkgs.lorri"; 31 }; 32 }; 33 }; 34 35 config = lib.mkIf cfg.enable { 36 systemd.user.sockets.lorri = { 37 description = "Socket for Lorri Daemon"; 38 wantedBy = [ "sockets.target" ]; 39 socketConfig = { 40 ListenStream = "%t/${socketPath}"; 41 RuntimeDirectory = "lorri"; 42 }; 43 }; 44 45 systemd.user.services.lorri = { 46 description = "Lorri Daemon"; 47 requires = [ "lorri.socket" ]; 48 after = [ "lorri.socket" ]; 49 path = with pkgs; [ 50 config.nix.package 51 git 52 gnutar 53 gzip 54 ]; 55 serviceConfig = { 56 ExecStart = "${cfg.package}/bin/lorri daemon"; 57 PrivateTmp = true; 58 ProtectSystem = "full"; 59 Restart = "on-failure"; 60 }; 61 }; 62 63 environment.systemPackages = [ 64 cfg.package 65 pkgs.direnv 66 ]; 67 }; 68}