move nix remote builder to a module
This commit is contained in:
@@ -1,18 +1,7 @@
|
||||
{ keys, ... }:
|
||||
let
|
||||
username = "nixremote";
|
||||
in
|
||||
{
|
||||
users.users."${username}" = {
|
||||
createHome = true;
|
||||
home = "/home/${username}";
|
||||
isSystemUser = true;
|
||||
group = username;
|
||||
useDefaultShell = true;
|
||||
openssh.authorizedKeys.keys = [ keys.hosts.haze ];
|
||||
roles.remote-builder = {
|
||||
enable = true;
|
||||
authorizedKeys = [ keys.hosts.haze ];
|
||||
};
|
||||
|
||||
users.groups."${username}" = { };
|
||||
|
||||
nix.settings.trusted-users = [ username ];
|
||||
}
|
||||
|
||||
5
modules/default.nix
Normal file
5
modules/default.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
imports = [
|
||||
./remote-builder.nix
|
||||
];
|
||||
}
|
||||
49
modules/remote-builder.nix
Normal file
49
modules/remote-builder.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.roles.remote-builder;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
roles.remote-builder = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Whether to allow remote building on this machine";
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "nixremote";
|
||||
example = "remote-builder";
|
||||
description = "The name of the user used to run the builds";
|
||||
};
|
||||
|
||||
group = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "${cfg.user}";
|
||||
example = "remote-builder";
|
||||
description = "The group of the user used to run the builds";
|
||||
};
|
||||
|
||||
authorizedKeys = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
example = [ "ssh-ed25519 AAAA... user@host" ];
|
||||
description = "List of SSH keys authorized to run builds on this machine";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users."${cfg.user}" = {
|
||||
createHome = true;
|
||||
home = "/home/${cfg.user}";
|
||||
isSystemUser = true;
|
||||
group = cfg.group;
|
||||
useDefaultShell = true;
|
||||
openssh.authorizedKeys.keys = cfg.authorizedKeys;
|
||||
};
|
||||
|
||||
users.groups.${cfg.user} = { };
|
||||
|
||||
nix.settings.trusted-users = [ cfg.user ];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user