User management module #80
@@ -8,12 +8,11 @@ in
|
||||
[ # Include the results of the hardware scan.
|
||||
#./hardware-configuration.nix
|
||||
../modules/xserver.nix
|
||||
../modules/malobeo_user.nix
|
||||
../modules/sshd.nix
|
||||
../modules/minimal_tools.nix
|
||||
../modules/autoupdate.nix
|
||||
inputs.self.nixosModules.malobeo.disko
|
||||
inputs.self.nixosModules.malobeo.initssh
|
||||
inputs.self.nixosModules.malobeo.users
|
||||
];
|
||||
|
||||
malobeo.autoUpdate = {
|
||||
@@ -38,6 +37,8 @@ in
|
||||
ethernetDrivers = ["r8169"];
|
||||
};
|
||||
|
||||
malobeo.users.malobeo = true;
|
||||
|
|
||||
|
||||
hardware.sane.enable = true; #scanner support
|
||||
|
||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
|
||||
@@ -9,7 +9,6 @@ in
|
||||
imports =
|
||||
[ # Include the results of the hardware scan.
|
||||
#./hardware-configuration.nix
|
||||
../modules/malobeo_user.nix
|
||||
../modules/sshd.nix
|
||||
../modules/minimal_tools.nix
|
||||
../modules/autoupdate.nix
|
||||
@@ -18,6 +17,7 @@ in
|
||||
inputs.self.nixosModules.malobeo.disko
|
||||
inputs.self.nixosModules.malobeo.microvm
|
||||
inputs.self.nixosModules.malobeo.metrics
|
||||
inputs.self.nixosModules.malobeo.users
|
||||
];
|
||||
|
||||
virtualisation.vmVariantWithDisko = {
|
||||
@@ -50,6 +50,10 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
malobeo.users = {
|
||||
malobeo = true;
|
||||
admin = true;
|
||||
|
ahtlon
commented
Forgot to remove this when I changed the default, but it also doesn't hurt to write it explicitly Forgot to remove this when I changed the default, but it also doesn't hurt to write it explicitly
|
||||
};
|
||||
|
||||
malobeo.disks = {
|
||||
enable = true;
|
||||
|
||||
63
machines/modules/malobeo/users.nix
Normal file
63
machines/modules/malobeo/users.nix
Normal file
@@ -0,0 +1,63 @@
|
||||
{config, lib, pkgs, inputs, ...}:
|
||||
let
|
||||
cfg = config.malobeo.users;
|
||||
sshKeys = import ( inputs.self + /machines/ssh_keys.nix);
|
||||
in
|
||||
{
|
||||
options.malobeo.users = {
|
||||
malobeo = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "enable malobeo user, defaults to on";
|
||||
};
|
||||
admin = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "enable admin user, defaults to on to prevent lockouts";
|
||||
};
|
||||
};
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf cfg.malobeo {
|
||||
users.users.malobeo = {
|
||||
isNormalUser = true;
|
||||
description = "malobeo user, password and ssh access, no root";
|
||||
extraGroups = [ "pipewire" "pulse-access" "scanner" "lp" ];
|
||||
openssh.authorizedKeys.keys = sshKeys.admins;
|
||||
hashedPassword = "$y$j9T$39oJwpbFDeETiyi9TjZ/2.$olUdnIIABp5TQSOzoysuEsomn2XPyzwVlM91ZsEkIz1";
|
||||
|
ahtlon
commented
Should be changed at some point to use sops Should be changed at some point to use sops
|
||||
};
|
||||
environment.systemPackages = with pkgs; [];
|
||||
})
|
||||
(lib.mkIf cfg.admin {
|
||||
users.users.admin = {
|
||||
isNormalUser = true;
|
||||
description = "admin user, passwordless sudo access, only ssh";
|
||||
hashedPassword = null;
|
||||
extraGroups = [ "networkmanager" ];
|
||||
};
|
||||
environment.systemPackages = with pkgs; [];
|
||||
nix.settings.trusted-users = [ "admin" ];
|
||||
security.sudo.extraRules = [
|
||||
{
|
||||
users = [ "admin" ];
|
||||
commands = [
|
||||
{
|
||||
command = "ALL";
|
||||
options = [ "NOPASSWD" ];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
})
|
||||
{
|
||||
users.mutableUsers = false;
|
||||
environment.systemPackages = with pkgs; [
|
||||
nix-output-monitor
|
||||
vim
|
||||
htop
|
||||
wget
|
||||
git
|
||||
pciutils
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -115,6 +115,7 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
|
||||
initssh.imports = [ ./machines/modules/malobeo/initssh.nix ];
|
||||
metrics.imports = [ ./machines/modules/malobeo/metrics.nix ];
|
||||
disko.imports = [ ./machines/modules/disko ];
|
||||
users.imports = [ ./machines/modules/malobeo/users.nix ];
|
||||
};
|
||||
|
||||
hydraJobs = nixpkgs.lib.mapAttrs (_: nixpkgs.lib.hydraJob) (
|
||||
|
||||
Reference in New Issue
Block a user
With default enable, this does nothing anymore... Should we disable the admin account on bakunin? The autoupdate script should still run to apply updates but we (and any attackers) could no longer change the system manually