From c680b715c1333cc09ce724fcb9beb62a75e9fd91 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Tue, 16 Jul 2024 17:15:29 +0300 Subject: [PATCH] feat: restructure --- {users/skye => hosts/arwen}/default.nix | 18 ++++++++++-- roles/base.nix | 38 ++++++++++++++++++------- systems/default.nix | 2 +- systems/hosts/arwen/default.nix | 9 ------ systems/profiles/laptop/default.nix | 1 - users/default.nix | 3 -- 6 files changed, 43 insertions(+), 28 deletions(-) rename {users/skye => hosts/arwen}/default.nix (54%) delete mode 100644 users/default.nix diff --git a/users/skye/default.nix b/hosts/arwen/default.nix similarity index 54% rename from users/skye/default.nix rename to hosts/arwen/default.nix index 7238b18..19e6246 100644 --- a/users/skye/default.nix +++ b/hosts/arwen/default.nix @@ -1,10 +1,22 @@ {config, ...}: { + sops.secrets.rootPwd.neededForUsers = true; sops.secrets.skyePwd.neededForUsers = true; roles.base = { - username = "skye"; - isWheel = true; - hashedPasswordFile = config.sops.secrets.skyePwd.path; + root = { + hashedPasswordFile = config.sops.secrets.rootPwd.path; + }; + primaryUser = { + username = "skye"; + isWheel = true; + hashedPasswordFile = config.sops.secrets.skyePwd.path; + }; + }; + + roles.audio.enable = true; + roles.bluetooth = { + enable = true; + enableHDAudio = true; }; roles.git = { diff --git a/roles/base.nix b/roles/base.nix index addf1c9..5b843c2 100644 --- a/roles/base.nix +++ b/roles/base.nix @@ -6,12 +6,27 @@ cfg = config.roles.base; in { options.roles.base = { - username = lib.mkOption { - type = lib.types.str; + root = lib.mkOption { + type = lib.types.submodule { + options = { + hashedPasswordFile = lib.mkOption { + type = lib.types.path; + }; + }; + }; }; - isWheel = lib.mkEnableOption "wheter to enable admin permissions"; - hashedPasswordFile = lib.mkOption { - type = lib.types.path; + primaryUser = lib.mkOption { + type = lib.types.submodule { + options = { + username = lib.mkOption { + type = lib.types.str; + }; + isWheel = lib.mkEnableOption "wheter to enable admin permissions"; + hashedPasswordFile = lib.mkOption { + type = lib.types.path; + }; + }; + }; }; }; @@ -19,25 +34,26 @@ in { (lib.mkAliasOptionModule ["hm"] [ "home-manager" "users" - cfg.username + cfg.primaryUser.username ]) ]; config = let - homeDirectory = "/home/${cfg.username}"; + homeDirectory = "/home/${cfg.primaryUser.username}"; in { - users.users.${cfg.username} = { + users.users.root.hashedPasswordFile = cfg.root.hashedPasswordFile; + users.users.${cfg.primaryUser.username} = { isNormalUser = true; - extraGroups = lib.optional cfg.isWheel "wheel"; + extraGroups = lib.optional cfg.primaryUser.isWheel "wheel"; home = homeDirectory; - hashedPasswordFile = cfg.hashedPasswordFile; + hashedPasswordFile = cfg.primaryUser.hashedPasswordFile; }; home-manager = { useUserPackages = true; useGlobalPkgs = true; }; hm.home = { - inherit (cfg) username; + inherit (cfg.primaryUser) username; inherit homeDirectory; stateVersion = config.system.stateVersion; }; diff --git a/systems/default.nix b/systems/default.nix index b0cad42..d4dd91b 100644 --- a/systems/default.nix +++ b/systems/default.nix @@ -1,5 +1,4 @@ { - self, inputs, ... }: { @@ -13,6 +12,7 @@ ++ cfg.modules ++ [ ./hosts/${name} + ../hosts/${name} { networking.hostName = name; } diff --git a/systems/hosts/arwen/default.nix b/systems/hosts/arwen/default.nix index 403cb1f..959476f 100644 --- a/systems/hosts/arwen/default.nix +++ b/systems/hosts/arwen/default.nix @@ -1,5 +1,4 @@ { - config, inputs, lib, pkgs, @@ -18,8 +17,6 @@ sops.defaultSopsFile = ../../../secrets/arwen/secrets.yaml; sops.gnupg.sshKeyPaths = ["/persist/etc/ssh/ssh_host_rsa_key"]; sops.age.sshKeyPaths = ["/persist/etc/ssh/ssh_host_ed25519_key"]; - sops.secrets.rootPwd.neededForUsers = true; - users.users.root.hashedPasswordFile = config.sops.secrets.rootPwd.path; networking.hostId = "d2a2e2cb"; networking.networkmanager.enable = true; @@ -28,12 +25,6 @@ services.xserver.xkb.layout = "us"; - roles.audio.enable = true; - roles.bluetooth = { - enable = true; - enableHDAudio = true; - }; - services.libinput.enable = true; environment.systemPackages = with pkgs; [ diff --git a/systems/profiles/laptop/default.nix b/systems/profiles/laptop/default.nix index 3a87a8a..e4402e1 100644 --- a/systems/profiles/laptop/default.nix +++ b/systems/profiles/laptop/default.nix @@ -10,7 +10,6 @@ inputs @ { home-manager.nixosModules.home-manager ../../../roles - ../../../users ]; specialArgs = { inherit inputs; diff --git a/users/default.nix b/users/default.nix deleted file mode 100644 index 91f9f98..0000000 --- a/users/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ - imports = [./skye]; -} -- 2.44.1