nerf/defaultRoles #12
3 changed files with 89 additions and 1 deletions
30
nixos/roles/admins.nix
Normal file
30
nixos/roles/admins.nix
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{lib, ...} :
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
admins = {
|
||||||
|
nerf = {
|
||||||
|
hashedPassword =
|
||||||
|
"$y$j9T$SJcjUIcs3JYuM5oyxfEQa/$tUBQT07FK4cb9xm.A6ZKVnFIPNOYMOKC6Dt6hadCuJ7";
|
||||||
Gonne marked this conversation as resolved
|
|||||||
|
keys = [
|
||||||
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEdA4LpEGUUmN8esFyrNZXFb2GiBID9/S6zzhcnofQuP nerf@nerflap2"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkAdmin = name :
|
||||||
|
{hashedPassword, keys}: {
|
||||||
|
"${name}" = {
|
||||||
|
isNormalUser = true;
|
||||||
|
createHome = true;
|
||||||
Gonne marked this conversation as resolved
Gonne
commented
Why do they get a home directory? I would expect them to have about no personal data. Why do they get a home directory? I would expect them to have about no personal data.
nerf
commented
The home directory is not persistent anyway, but it will give a lot of programs that you might use a safe to throw their stuff. The home directory is not persistent anyway, but it will give a lot of programs that you might use a safe to throw their stuff.
For example bash starts to write things to disk the moment you use it. All in all I think it is convenient and not persistent anyway.
But I also don't think it matters too much. So I can change it if you think that is blocking
Gonne
commented
I don't really care. I don't really care.
|
|||||||
|
extraGroups = [ "wheel" ];
|
||||||
|
group = "users";
|
||||||
|
home = "/home/${name}";
|
||||||
|
openssh.authorizedKeys = { inherit keys; };
|
||||||
|
inherit hashedPassword;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
in {
|
||||||
|
users.users = mkMerge (mapAttrsToList mkAdmin admins);
|
||||||
|
}
|
|
@ -1,4 +1,56 @@
|
||||||
{ ... } : {
|
{pkgs, config, lib, modulesPath, ...} : {
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./admins.nix
|
||||||
|
./nix_keys.nix
|
||||||
|
(modulesPath + "/virtualisation/xen-domU.nix")
|
||||||
|
];
|
||||||
|
nix = {
|
||||||
|
extraOptions = ''
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
builders-use-substitutes = true
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
networking = {
|
||||||
|
firewall = { # these shoud be default, but better make sure!
|
||||||
|
enable = true;
|
||||||
|
allowPing = true;
|
||||||
|
};
|
||||||
|
nftables.enable = true;
|
||||||
|
useDHCP = false; # We don't speak DHCP and even if we would, we should enable it per interface
|
||||||
|
# hosts = # TODO write something to autogenerate ip adresses!
|
||||||
|
};
|
||||||
|
|
||||||
|
users = {
|
||||||
|
mutableUsers = false;
|
||||||
|
users.root.hashedPassword = "!";
|
||||||
|
};
|
||||||
|
|
||||||
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
||||||
|
|
||||||
|
environment = {
|
||||||
|
systemPackages = builtins.attrValues {
|
||||||
|
inherit (pkgs)
|
||||||
|
htop lsof tmux btop;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services = {
|
||||||
|
journald.extraConfig = "SystemMaxUse=5G";
|
||||||
|
|
||||||
|
nginx = {
|
||||||
Gonne marked this conversation as resolved
Gonne
commented
Does this only set the defaults in case we enable some nginx or does this enable nginx (and why)? Does this only set the defaults in case we enable some nginx or does this enable nginx (and why)?
nerf
commented
This does not enable ngingx, but it will set these if you load ngingx (for that there is This does not enable ngingx, but it will set these if you load ngingx (for that there is `services.nginx.enable`). And it isn't nginx default behavior but it kind of should be.
|
|||||||
|
recommendedOptimisation = true;
|
||||||
|
recommendedGzipSettings = true;
|
||||||
|
recommendedTlsSettings = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
openssh = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
PermitRootLogin = "no";
|
||||||
|
PasswordAuthentication = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
6
nixos/roles/nix_keys.nix
Normal file
6
nixos/roles/nix_keys.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
nix.settings.trusted-public-keys = [
|
||||||
|
"nerflap2-1:pDZCg0oo9PxNQxwVSQSvycw7WXTl53PGvVeZWvxuqJc="
|
||||||
|
];
|
||||||
|
}
|
Loading…
Reference in a new issue
Why does this user get a password? We didn't do that on our Debian machines with individual user accounts.
Basically my paranoia, makes privilege escalation on that machine harder.
It also makes sane user based console log ins possible. You might have noticed I disabled root
console (technically password) login.