1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

pbgopy: add missing options

This commit is contained in:
Ivar Scholten 2021-04-22 23:46:05 +02:00 committed by Robert Helgesson
parent 4edc2091e0
commit 4727b0543d
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 30 additions and 2 deletions

View file

@ -3,14 +3,32 @@
with lib;
let
cfg = config.services.pbgopy;
package = pkgs.pbgopy;
commandLine = concatStringsSep " " ([
"${package}/bin/pbgopy serve"
"--port ${toString cfg.port}"
"--ttl ${cfg.cache.ttl}"
] ++ optional (cfg.httpAuth != null)
"--basic-auth ${escapeShellArg cfg.httpAuth}");
in {
meta.maintainers = [ maintainers.ivar ];
options.services.pbgopy = {
enable = mkEnableOption "pbgopy";
port = mkOption {
type = types.port;
default = 9090;
example = 8080;
description = ''
The port to host the pbgopy server on.
'';
};
cache.ttl = mkOption {
type = types.str;
default = "24h";
@ -19,6 +37,16 @@ in {
The TTL for the cache. Use <literal>"0s"</literal> to disable it.
'';
};
httpAuth = mkOption {
type = types.nullOr types.str;
default = null;
example = "user:pass";
description = ''
Basic HTTP authentication's username and password. Both the username and
password are escaped.
'';
};
};
config = mkIf cfg.enable {
@ -31,7 +59,7 @@ in {
PartOf = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${package}/bin/pbgopy serve --ttl ${cfg.cache.ttl}";
ExecStart = commandLine;
Restart = "on-abort";
};
Install = { WantedBy = [ "graphical-session.target" ]; };

View file

@ -16,7 +16,7 @@
assertFileExists $serviceFile
assertFileContains $serviceFile \
'ExecStart=@pbgopy@/bin/pbgopy serve --ttl 24h'
'ExecStart=@pbgopy@/bin/pbgopy serve --port 9090 --ttl 24h'
'';
};
}