options/machine: allow to define users without wheel
This commit is contained in:
parent
87e83f336f
commit
88a6a90ab2
10 changed files with 26 additions and 25 deletions
|
@ -32,7 +32,7 @@ in
|
||||||
substituters = [
|
substituters = [
|
||||||
"https://cache.nixos.org"
|
"https://cache.nixos.org"
|
||||||
] ++ cfg.binaryCaches;
|
] ++ cfg.binaryCaches;
|
||||||
allowed-users = [ "root" ] ++ (map (n: n.name) cfg.administrators);
|
allowed-users = [ "root" ] ++ (map (n: n.name) cfg.users);
|
||||||
};
|
};
|
||||||
extraOptions = ''
|
extraOptions = ''
|
||||||
build-timeout = 86400 # 24 hours
|
build-timeout = 86400 # 24 hours
|
||||||
|
|
|
@ -9,7 +9,7 @@ with lib;
|
||||||
let
|
let
|
||||||
withDocker = config.virtualisation.docker.enable;
|
withDocker = config.virtualisation.docker.enable;
|
||||||
withPodman = config.virtualisation.podman.enable;
|
withPodman = config.virtualisation.podman.enable;
|
||||||
administrators = user: {
|
users = user: {
|
||||||
inherit (user) name;
|
inherit (user) name;
|
||||||
value =
|
value =
|
||||||
let
|
let
|
||||||
|
@ -20,24 +20,23 @@ let
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
inherit (user) name;
|
inherit (user) name;
|
||||||
uid = user.id;
|
uid = user.id;
|
||||||
subUidRanges = optional withPodman {
|
subUidRanges = optional (user.isAdmin && withPodman) {
|
||||||
startUid = 100000;
|
startUid = 100000;
|
||||||
count = 65536;
|
count = 65536;
|
||||||
};
|
};
|
||||||
subGidRanges = optional withPodman {
|
subGidRanges = optional (user.isAdmin && withPodman) {
|
||||||
startGid = 100000;
|
startGid = 100000;
|
||||||
count = 65536;
|
count = 65536;
|
||||||
};
|
};
|
||||||
home = builtins.toPath "/home/${user.name}";
|
home = builtins.toPath "/home/${user.name}";
|
||||||
createHome = true;
|
createHome = true;
|
||||||
description = "Administrative user ${user.name}.";
|
|
||||||
group = user.name;
|
group = user.name;
|
||||||
extraGroups =
|
extraGroups =
|
||||||
[
|
[
|
||||||
"audio"
|
"audio"
|
||||||
"wheel"
|
|
||||||
"network"
|
"network"
|
||||||
]
|
]
|
||||||
|
++ (optional user.isAdmin "wheel")
|
||||||
++ (optionals (lib.elem "desktop" config.machine.services) [
|
++ (optionals (lib.elem "desktop" config.machine.services) [
|
||||||
"input"
|
"input"
|
||||||
"video"
|
"video"
|
||||||
|
@ -66,12 +65,12 @@ let
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
sops.secrets = fn.sopsHelper (user: "users/${user.name}/password") config.machine.administrators {
|
sops.secrets = fn.sopsHelper (user: "users/${user.name}/password") config.machine.users {
|
||||||
neededForUsers = true;
|
neededForUsers = true;
|
||||||
};
|
};
|
||||||
users = {
|
users = {
|
||||||
mutableUsers = false;
|
mutableUsers = false;
|
||||||
users = listToAttrs (map administrators config.machine.administrators);
|
users = listToAttrs (map users config.machine.users);
|
||||||
groups = listToAttrs (map mkusergroup config.machine.administrators);
|
groups = listToAttrs (map mkusergroup config.machine.users);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
waitOnline = false;
|
waitOnline = false;
|
||||||
};
|
};
|
||||||
administrators = [
|
users = [
|
||||||
{
|
{
|
||||||
name = "derped";
|
name = "derped";
|
||||||
id = 1337;
|
id = 1337;
|
||||||
|
isAdmin = true;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
conffiles = [
|
conffiles = [
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
config.machine = {
|
config.machine = {
|
||||||
allowUnfree = true;
|
allowUnfree = true;
|
||||||
hostName = "Marid";
|
hostName = "Marid";
|
||||||
administrators = [
|
users = [
|
||||||
{
|
{
|
||||||
name = "derped";
|
name = "derped";
|
||||||
id = 1337;
|
id = 1337;
|
||||||
|
isAdmin = true;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
conffiles = [
|
conffiles = [
|
||||||
|
|
|
@ -11,10 +11,11 @@ in
|
||||||
config.machine = rec {
|
config.machine = rec {
|
||||||
hostName = "Ophanim";
|
hostName = "Ophanim";
|
||||||
domain = "ophanim.de";
|
domain = "ophanim.de";
|
||||||
administrators = [
|
users = [
|
||||||
{
|
{
|
||||||
name = "derped";
|
name = "derped";
|
||||||
id = 1337;
|
id = 1337;
|
||||||
|
isAdmin = true;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
mailAccounts = [
|
mailAccounts = [
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
waitOnline = false;
|
waitOnline = false;
|
||||||
};
|
};
|
||||||
administrators = [
|
users = [
|
||||||
{
|
{
|
||||||
name = "derped";
|
name = "derped";
|
||||||
id = 1337;
|
id = 1337;
|
||||||
|
isAdmin = true;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
conffiles = [
|
conffiles = [
|
||||||
|
|
|
@ -89,10 +89,10 @@ in
|
||||||
Adds binary caches to both nix.trustedBinaryCaches and nix.binaryCaches. ("https://cache.nixos.org" is kept by default)
|
Adds binary caches to both nix.trustedBinaryCaches and nix.binaryCaches. ("https://cache.nixos.org" is kept by default)
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
administrators = mkOption {
|
users = mkOption {
|
||||||
type = types.listOf types.attrs;
|
type = types.listOf types.attrs;
|
||||||
description = ''
|
description = ''
|
||||||
List of administrative users.
|
List of normal users.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
domain = mkOption {
|
domain = mkOption {
|
||||||
|
|
|
@ -76,7 +76,7 @@ in
|
||||||
"/etc/ssh/ssh_host_rsa_key"
|
"/etc/ssh/ssh_host_rsa_key"
|
||||||
"/etc/ssh/ssh_host_rsa_key.pub"
|
"/etc/ssh/ssh_host_rsa_key.pub"
|
||||||
];
|
];
|
||||||
users = listToAttrs (map persistUser config.machine.administrators);
|
users = listToAttrs (map persistUser config.machine.users);
|
||||||
};
|
};
|
||||||
|
|
||||||
# link current home manager profile if it exists
|
# link current home manager profile if it exists
|
||||||
|
@ -91,6 +91,6 @@ in
|
||||||
ln -sfn /home/${name}/.local/state/nix/profiles/profile /home/${name}/.nix-profile
|
ln -sfn /home/${name}/.local/state/nix/profiles/profile /home/${name}/.nix-profile
|
||||||
fi
|
fi
|
||||||
''
|
''
|
||||||
) config.machine.administrators
|
) config.machine.users
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ mkIf (elem "nextcloud" config.machine.services) {
|
||||||
maxUploadSize = "1024M";
|
maxUploadSize = "1024M";
|
||||||
package = pkgs.nextcloud30;
|
package = pkgs.nextcloud30;
|
||||||
config = {
|
config = {
|
||||||
adminuser = mkDefault (elemAt cfg.administrators 0).name;
|
adminuser = mkDefault (findFirst (user: user.isAdmin) { name = "admin"; } cfg.users).name;
|
||||||
adminpassFile = config.sops.secrets."services/nextcloud/adminPass".path;
|
adminpassFile = config.sops.secrets."services/nextcloud/adminPass".path;
|
||||||
dbtype = "mysql";
|
dbtype = "mysql";
|
||||||
dbhost = "localhost:3306";
|
dbhost = "localhost:3306";
|
||||||
|
|
|
@ -25,7 +25,7 @@ mkIf (elem "openssh" config.machine.services) {
|
||||||
extraConfig =
|
extraConfig =
|
||||||
let
|
let
|
||||||
users =
|
users =
|
||||||
concatMapStrings (user: "${user.name} ") config.machine.administrators
|
concatMapStrings (user: "${user.name} ") config.machine.users
|
||||||
+ (optionalString config.services.forgejo.enable (config.services.forgejo.user + " "));
|
+ (optionalString config.services.forgejo.enable (config.services.forgejo.user + " "));
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
|
@ -36,10 +36,8 @@ mkIf (elem "openssh" config.machine.services) {
|
||||||
};
|
};
|
||||||
# Add public keys to /etc/ssh/authorized_keys.d
|
# Add public keys to /etc/ssh/authorized_keys.d
|
||||||
# This replaces users.users.*.openssh.authorizedKeys.*
|
# This replaces users.users.*.openssh.authorizedKeys.*
|
||||||
sops.secrets =
|
sops.secrets = fn.sopsHelper (user: "users/${user.name}/publicKey") config.machine.users (user: {
|
||||||
fn.sopsHelper (user: "users/${user.name}/publicKey") config.machine.administrators
|
path = "/etc/ssh/authorized_keys.d/${user.name}";
|
||||||
(user: {
|
mode = "444";
|
||||||
path = "/etc/ssh/authorized_keys.d/${user.name}";
|
});
|
||||||
mode = "444";
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue