mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-28 08:33:54 +00:00
6afb255d97
these changes were generated with nixq 0.0.2, by running nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix two mentions of the mdDoc function remain in nixos/, both of which are inside of comments. Since lib.mdDoc is already defined as just id, this commit is a no-op as far as Nix (and the built manual) is concerned.
96 lines
2.9 KiB
Nix
96 lines
2.9 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
let
|
|
cfg = config.services.harmonia;
|
|
format = pkgs.formats.toml { };
|
|
in
|
|
{
|
|
options = {
|
|
services.harmonia = {
|
|
enable = lib.mkEnableOption "Harmonia: Nix binary cache written in Rust";
|
|
|
|
signKeyPath = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.path;
|
|
default = null;
|
|
description = "Path to the signing key that will be used for signing the cache";
|
|
};
|
|
|
|
package = lib.mkPackageOption pkgs "harmonia" { };
|
|
|
|
settings = lib.mkOption {
|
|
inherit (format) type;
|
|
default = { };
|
|
description = ''
|
|
Settings to merge with the default configuration.
|
|
For the list of the default configuration, see <https://github.com/nix-community/harmonia/tree/master#configuration>.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
nix.settings.extra-allowed-users = [ "harmonia" ];
|
|
users.users.harmonia = {
|
|
isSystemUser = true;
|
|
group = "harmonia";
|
|
};
|
|
users.groups.harmonia = { };
|
|
|
|
systemd.services.harmonia = {
|
|
description = "harmonia binary cache service";
|
|
|
|
requires = [ "nix-daemon.socket" ];
|
|
after = [ "network.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
environment = {
|
|
CONFIG_FILE = format.generate "harmonia.toml" cfg.settings;
|
|
SIGN_KEY_PATH = lib.mkIf (cfg.signKeyPath != null) "%d/sign-key";
|
|
# Note: it's important to set this for nix-store, because it wants to use
|
|
# $HOME in order to use a temporary cache dir. bizarre failures will occur
|
|
# otherwise
|
|
HOME = "/run/harmonia";
|
|
};
|
|
|
|
serviceConfig = {
|
|
ExecStart = lib.getExe cfg.package;
|
|
User = "harmonia";
|
|
Group = "harmonia";
|
|
Restart = "on-failure";
|
|
PrivateUsers = true;
|
|
DeviceAllow = [ "" ];
|
|
UMask = "0066";
|
|
RuntimeDirectory = "harmonia";
|
|
LoadCredential = lib.mkIf (cfg.signKeyPath != null) [ "sign-key:${cfg.signKeyPath}" ];
|
|
SystemCallFilter = [
|
|
"@system-service"
|
|
"~@privileged"
|
|
"~@resources"
|
|
];
|
|
CapabilityBoundingSet = "";
|
|
ProtectKernelModules = true;
|
|
ProtectKernelTunables = true;
|
|
ProtectControlGroups = true;
|
|
ProtectKernelLogs = true;
|
|
ProtectHostname = true;
|
|
ProtectClock = true;
|
|
RestrictRealtime = true;
|
|
MemoryDenyWriteExecute = true;
|
|
ProcSubset = "pid";
|
|
ProtectProc = "invisible";
|
|
RestrictNamespaces = true;
|
|
SystemCallArchitectures = "native";
|
|
PrivateNetwork = false;
|
|
PrivateTmp = true;
|
|
PrivateDevices = true;
|
|
PrivateMounts = true;
|
|
NoNewPrivileges = true;
|
|
ProtectSystem = "strict";
|
|
ProtectHome = true;
|
|
LockPersonality = true;
|
|
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6";
|
|
LimitNOFILE = 65536;
|
|
};
|
|
};
|
|
};
|
|
}
|