at master 1.3 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.mkPackageOption pkgs "lorri" { }; 25 }; 26 }; 27 28 config = lib.mkIf cfg.enable { 29 systemd.user.sockets.lorri = { 30 description = "Socket for Lorri Daemon"; 31 wantedBy = [ "sockets.target" ]; 32 socketConfig = { 33 ListenStream = "%t/${socketPath}"; 34 RuntimeDirectory = "lorri"; 35 }; 36 }; 37 38 systemd.user.services.lorri = { 39 description = "Lorri Daemon"; 40 requires = [ "lorri.socket" ]; 41 after = [ "lorri.socket" ]; 42 path = with pkgs; [ 43 config.nix.package 44 git 45 gnutar 46 gzip 47 ]; 48 serviceConfig = { 49 ExecStart = "${cfg.package}/bin/lorri daemon"; 50 PrivateTmp = true; 51 ProtectSystem = "full"; 52 Restart = "on-failure"; 53 }; 54 }; 55 56 environment.systemPackages = [ 57 cfg.package 58 pkgs.direnv 59 ]; 60 }; 61}