mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-18 23:50:07 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
99 lines
2.5 KiB
Nix
99 lines
2.5 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
...
|
|
}:
|
|
|
|
let
|
|
cfg = config.services.go-camo;
|
|
inherit (lib)
|
|
mkOption
|
|
mkEnableOption
|
|
mkIf
|
|
mkMerge
|
|
types
|
|
optionalString
|
|
;
|
|
in
|
|
{
|
|
options.services.go-camo = {
|
|
enable = mkEnableOption "go-camo service";
|
|
listen = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
description = "Address:Port to bind to for HTTP (default: 0.0.0.0:8080).";
|
|
apply = v: optionalString (v != null) "--listen=${v}";
|
|
};
|
|
sslListen = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
description = "Address:Port to bind to for HTTPS.";
|
|
apply = v: optionalString (v != null) "--ssl-listen=${v}";
|
|
};
|
|
sslKey = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
description = "Path to TLS private key.";
|
|
apply = v: optionalString (v != null) "--ssl-key=${v}";
|
|
};
|
|
sslCert = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
description = "Path to TLS certificate.";
|
|
apply = v: optionalString (v != null) "--ssl-cert=${v}";
|
|
};
|
|
keyFile = mkOption {
|
|
type = types.path;
|
|
default = null;
|
|
description = ''
|
|
A file containing the HMAC key to use for signing URLs.
|
|
The file can contain any string. Can be generated using "openssl rand -base64 18 > the_file".
|
|
'';
|
|
};
|
|
extraOptions = mkOption {
|
|
type = with types; listOf str;
|
|
default = [ ];
|
|
description = "Extra options passed to the go-camo command.";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.services.go-camo = {
|
|
description = "go-camo service";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" ];
|
|
environment = {
|
|
GOCAMO_HMAC_FILE = "%d/hmac";
|
|
};
|
|
script = ''
|
|
GOCAMO_HMAC="$(cat "$GOCAMO_HMAC_FILE")"
|
|
export GOCAMO_HMAC
|
|
exec ${
|
|
lib.escapeShellArgs (
|
|
lib.lists.remove "" (
|
|
[
|
|
"${pkgs.go-camo}/bin/go-camo"
|
|
cfg.listen
|
|
cfg.sslListen
|
|
cfg.sslKey
|
|
cfg.sslCert
|
|
]
|
|
++ cfg.extraOptions
|
|
)
|
|
)
|
|
}
|
|
'';
|
|
serviceConfig = {
|
|
NoNewPrivileges = true;
|
|
ProtectSystem = "strict";
|
|
DynamicUser = true;
|
|
User = "gocamo";
|
|
Group = "gocamo";
|
|
LoadCredential = [
|
|
"hmac:${cfg.keyFile}"
|
|
];
|
|
};
|
|
};
|
|
};
|
|
}
|