fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . pbgopy ; 8package = pkgs . pbgopy ; 9 10commandLine = concatStringsSep " " ([ 11" ${ package } /bin/pbgopy serve" 12"--port ${ toString cfg . port } " 13"--ttl ${ cfg . cache . ttl } " 14] ++ optional ( cfg . httpAuth != null ) 15"--basic-auth ${ escapeShellArg cfg . httpAuth } " ); 16 17in { 18meta . maintainers = [ maintainers . ivar ]; 19 20options . services . pbgopy = { 21enable = mkEnableOption "pbgopy" ; 22 23port = mkOption { 24type = types . port ; 25default = 9090 ; 26example = 8080 ; 27description = '' 28The port to host the pbgopy server on. 29'' ; 30}; 31 32cache . ttl = mkOption { 33type = types . str ; 34default = "24h" ; 35example = "10m" ; 36description = '' 37The TTL for the cache. Use `"0s"` to disable it. 38'' ; 39}; 40 41httpAuth = mkOption { 42type = types . nullOr types . str ; 43default = null ; 44example = "user:pass" ; 45description = '' 46Basic HTTP authentication's username and password. Both the username and 47password are escaped. 48'' ; 49}; 50}; 51 52config = mkIf cfg . enable { 53assertions = [ 54( lib . hm . assertions . assertPlatform "services.pbgopy" pkgs 55lib . platforms . linux ) 56]; 57 58home . packages = [ package ]; 59 60systemd . user . services . pbgopy = { 61Unit = { 62Description = "pbgopy server for sharing the clipboard between devices" ; 63After = [ "graphical-session-pre.target" ]; 64PartOf = [ "graphical-session.target" ]; 65}; 66Service = { 67ExecStart = commandLine ; 68Restart = "on-abort" ; 69}; 70Install = { WantedBy = [ "graphical-session.target" ]; }; 71}; 72}; 73}