Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions darwin/roles/nix-remote-builder.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ }
50 changes: 1 addition & 49 deletions nixos/roles/nix-remote-builder.nix
Original file line number Diff line number Diff line change
@@ -1,49 +1 @@
{
lib,
config,
pkgs,
...
}:
let
cfg = config.roles.nix-remote-builder;
in
{

options.roles.nix-remote-builder = {
schedulerPublicKeys = lib.mkOption {
description = "SSH public keys of the central build scheduler";
type = lib.types.listOf lib.types.str;
};
};

config = {
# Garbage-collect often
nix.gc.automatic = true;
nix.gc.dates = "*:45";
nix.gc.options = ''--max-freed "$((128 * 1024**3 - 1024 * $(df -P -k /nix/store | tail -n 1 | ${pkgs.gawk}/bin/awk '{ print $4 }')))"'';

# Randomize GC to avoid thundering herd effects.
nix.gc.randomizedDelaySec = "1800";

# Allow more open files for non-root users to run NixOS VM tests.
security.pam.loginLimits = [
{
domain = "*";
item = "nofile";
type = "-";
value = "20480";
}
];

# Give restricted SSH access to the build scheduler
users.users.nix-remote-builder.openssh.authorizedKeys.keys = map (
key: ''restrict,command="nix-daemon --stdio" ${key}''
) cfg.schedulerPublicKeys;
users.users.nix-remote-builder.isNormalUser = true;
users.users.nix-remote-builder.group = "nogroup";
nix.settings.trusted-users = [ "nix-remote-builder" ];

# Allow more nix-daemon sessions to connect at the same time.
services.openssh.settings.MaxStartups = 100;
};
}
{ }
27 changes: 27 additions & 0 deletions shared/roles/nix-remote-builder.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
lib,
config,
pkgs,
...
}:
let
cfg = config.roles.nix-remote-builder;
in
{

options.roles.nix-remote-builder = {
schedulerPublicKeys = lib.mkOption {
description = "SSH public keys of the central build scheduler";
type = lib.types.listOf lib.types.str;
};
};

config = {
# Give restricted SSH access to the build scheduler
users.users.nix-remote-builder.openssh.authorizedKeys.keys = map (
key: ''restrict,command="nix-daemon --stdio" ${key}''
) cfg.schedulerPublicKeys;

nix.settings.trusted-users = [ "nix-remote-builder" ];
};
}