1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-28 17:38:33 +02: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; with lib;
let let
cfg = config.services.pbgopy; cfg = config.services.pbgopy;
package = pkgs.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 { in {
meta.maintainers = [ maintainers.ivar ]; meta.maintainers = [ maintainers.ivar ];
options.services.pbgopy = { options.services.pbgopy = {
enable = mkEnableOption "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 { cache.ttl = mkOption {
type = types.str; type = types.str;
default = "24h"; default = "24h";
@ -19,6 +37,16 @@ in {
The TTL for the cache. Use <literal>"0s"</literal> to disable it. 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 { config = mkIf cfg.enable {
@ -31,7 +59,7 @@ in {
PartOf = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ];
}; };
Service = { Service = {
ExecStart = "${package}/bin/pbgopy serve --ttl ${cfg.cache.ttl}"; ExecStart = commandLine;
Restart = "on-abort"; Restart = "on-abort";
}; };
Install = { WantedBy = [ "graphical-session.target" ]; }; Install = { WantedBy = [ "graphical-session.target" ]; };

View File

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