mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 03:17:13 +00:00
b37bbca521
These were broken since 2016:f0367da7d1
since StartLimitIntervalSec got moved into [Unit] from [Service]. StartLimitBurst has also been moved accordingly, so let's fix that one too. NixOS systems have been producing logs such as: /nix/store/wf98r55aszi1bkmln1lvdbp7znsfr70i-unit-caddy.service/caddy.service:31: Unknown key name 'StartLimitIntervalSec' in section 'Service', ignoring. I have also removed some unnecessary duplication in units disabling rate limiting since setting either interval or burst to zero disables it (ad16158c10/src/basic/ratelimit.c (L16)
)
76 lines
2 KiB
Nix
76 lines
2 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
opts = { name, config, ... }: {
|
|
options = {
|
|
enable = mkOption {
|
|
default = true;
|
|
type = types.bool;
|
|
example = true;
|
|
description = "Whether to enable proxy for this bucket";
|
|
};
|
|
bucketName = mkOption {
|
|
type = types.str;
|
|
default = name;
|
|
example = "my-bucket-name";
|
|
description = "Name of Google storage bucket";
|
|
};
|
|
address = mkOption {
|
|
type = types.str;
|
|
example = "localhost:3000";
|
|
description = "The address of the proxy.";
|
|
};
|
|
};
|
|
};
|
|
enabledProxies = lib.filterAttrs (n: v: v.enable) config.services.nix-store-gcs-proxy;
|
|
mapProxies = function: lib.mkMerge (lib.mapAttrsToList function enabledProxies);
|
|
in
|
|
{
|
|
options.services.nix-store-gcs-proxy = mkOption {
|
|
type = types.attrsOf (types.submodule opts);
|
|
default = {};
|
|
description = ''
|
|
An attribute set describing an HTTP to GCS proxy that allows us to use GCS
|
|
bucket via HTTP protocol.
|
|
'';
|
|
};
|
|
|
|
config.systemd.services = mapProxies (name: cfg: {
|
|
"nix-store-gcs-proxy-${name}" = {
|
|
description = "A HTTP nix store that proxies requests to Google Storage";
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
startLimitIntervalSec = 10;
|
|
serviceConfig = {
|
|
RestartSec = 5;
|
|
ExecStart = ''
|
|
${pkgs.nix-store-gcs-proxy}/bin/nix-store-gcs-proxy \
|
|
--bucket-name ${cfg.bucketName} \
|
|
--addr ${cfg.address}
|
|
'';
|
|
|
|
DynamicUser = true;
|
|
|
|
ProtectSystem = "strict";
|
|
ProtectHome = true;
|
|
PrivateTmp = true;
|
|
PrivateDevices = true;
|
|
PrivateMounts = true;
|
|
PrivateUsers = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
ProtectKernelModules = true;
|
|
ProtectControlGroups = true;
|
|
|
|
NoNewPrivileges = true;
|
|
LockPersonality = true;
|
|
RestrictRealtime = true;
|
|
};
|
|
};
|
|
});
|
|
|
|
meta.maintainers = [ maintainers.mrkkrp ];
|
|
}
|