From e61ada3cd23171d78b951c3e82066ba9a25ce81c Mon Sep 17 00:00:00 2001 From: matt1432 Date: Thu, 5 Sep 2024 08:17:23 -0400 Subject: [PATCH] refactor: add default in device modules and put home state ver in common --- common/default.nix | 24 +++++++----------------- devices/bbsteamie/default.nix | 3 +-- devices/bbsteamie/modules/default.nix | 5 +++++ devices/binto/default.nix | 13 ++++--------- devices/binto/modules/default.nix | 6 ++++++ devices/cluster/default.nix | 3 +-- devices/cluster/modules/default.nix | 10 ++++++++++ devices/cluster/modules/pcsd.nix | 10 +--------- devices/homie/default.nix | 3 +-- devices/homie/modules/default.nix | 5 +++++ devices/nos/default.nix | 9 +-------- devices/nos/modules/default.nix | 11 +++++++++++ devices/servivi/default.nix | 7 +------ devices/servivi/modules/default.nix | 9 +++++++++ devices/wim/default.nix | 12 ++++-------- devices/wim/modules/default.nix | 5 +++++ outputs.nix | 1 - 17 files changed, 72 insertions(+), 64 deletions(-) create mode 100644 devices/bbsteamie/modules/default.nix create mode 100644 devices/binto/modules/default.nix create mode 100644 devices/cluster/modules/default.nix create mode 100644 devices/homie/modules/default.nix create mode 100644 devices/nos/modules/default.nix create mode 100644 devices/servivi/modules/default.nix create mode 100644 devices/wim/modules/default.nix diff --git a/common/default.nix b/common/default.nix index e1d77f1e..9db70f5c 100644 --- a/common/default.nix +++ b/common/default.nix @@ -107,17 +107,15 @@ ]; home-manager = let - inherit (lib) mapAttrs' nameValuePair; - + inherit (lib) mapAttrs' mkIf mkOption nameValuePair types; inherit (config.vars) mainUser; - mainUserConf = config.home-manager.users.${mainUser}; default = { imports = [ # Make the vars be the same on Nix and HM { - options.vars = lib.mkOption { - type = lib.types.attrs; + options.vars = mkOption { + type = types.attrs; readOnly = true; default = config.vars; }; @@ -139,21 +137,13 @@ source = v; }) self.devShells.${pkgs.system}; + + home.stateVersion = config.system.stateVersion; }; in { users = { - root = - default - // { - home.stateVersion = mainUserConf.home.stateVersion; - }; - greeter = - lib.mkIf (config.services.greetd.enable) - (default - // { - home.stateVersion = mainUserConf.home.stateVersion; - }); - + root = default; + greeter = mkIf (config.services.greetd.enable) default; ${mainUser} = default; }; }; diff --git a/devices/bbsteamie/default.nix b/devices/bbsteamie/default.nix index a7230a4f..aa3cb406 100644 --- a/devices/bbsteamie/default.nix +++ b/devices/bbsteamie/default.nix @@ -11,7 +11,7 @@ in { imports = [ ./hardware-configuration.nix - ./modules/desktop + ./modules self.nixosModules.kmscon self.nixosModules.plymouth @@ -20,7 +20,6 @@ in { # State Version: DO NOT CHANGE system.stateVersion = "24.11"; - home-manager.users.${mainUser}.home.stateVersion = "24.11"; # ------------------------------------------------ # User Settings diff --git a/devices/bbsteamie/modules/default.nix b/devices/bbsteamie/modules/default.nix new file mode 100644 index 00000000..35db9a5a --- /dev/null +++ b/devices/bbsteamie/modules/default.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ./desktop + ]; +} diff --git a/devices/binto/default.nix b/devices/binto/default.nix index d5fde0df..2428ae57 100644 --- a/devices/binto/default.nix +++ b/devices/binto/default.nix @@ -11,8 +11,7 @@ in { imports = [ ./hardware-configuration.nix - ./modules/gpu-replay.nix - ./modules/nix-gaming.nix + ./modules self.nixosModules.adb self.nixosModules.desktop @@ -20,14 +19,10 @@ in { self.nixosModules.server ]; - home-manager.users.${mainUser} = { - imports = [ - self.homeManagerModules.firefox - ]; + home-manager.users.${mainUser}.imports = [ + self.homeManagerModules.firefox + ]; - # State Version: DO NOT CHANGE - home.stateVersion = "23.11"; - }; # State Version: DO NOT CHANGE system.stateVersion = "23.11"; diff --git a/devices/binto/modules/default.nix b/devices/binto/modules/default.nix new file mode 100644 index 00000000..ab27a3b3 --- /dev/null +++ b/devices/binto/modules/default.nix @@ -0,0 +1,6 @@ +{...}: { + imports = [ + ./gpu-replay.nix + ./nix-gaming.nix + ]; +} diff --git a/devices/cluster/default.nix b/devices/cluster/default.nix index e9817683..351779c3 100644 --- a/devices/cluster/default.nix +++ b/devices/cluster/default.nix @@ -13,7 +13,7 @@ in { imports = [ ./hardware-configuration.nix - ./modules/pcsd.nix + ./modules self.nixosModules.kmscon self.nixosModules.server @@ -21,7 +21,6 @@ in { # State Version: DO NOT CHANGE system.stateVersion = "24.05"; - home-manager.users.${mainUser}.home.stateVersion = "24.05"; # ------------------------------------------------ # User Settings diff --git a/devices/cluster/modules/default.nix b/devices/cluster/modules/default.nix new file mode 100644 index 00000000..2d8e70fb --- /dev/null +++ b/devices/cluster/modules/default.nix @@ -0,0 +1,10 @@ +{...}: { + imports = [ + ./blocky.nix + ./caddy.nix + ./headscale + ./nfs-client.nix + ./pcsd.nix + ./unbound.nix + ]; +} diff --git a/devices/cluster/modules/pcsd.nix b/devices/cluster/modules/pcsd.nix index 62a23514..cd655626 100644 --- a/devices/cluster/modules/pcsd.nix +++ b/devices/cluster/modules/pcsd.nix @@ -5,15 +5,7 @@ }: let inherit (config.sops) secrets; in { - imports = [ - pcsd.nixosModules.default - - ./blocky.nix - ./caddy.nix - ./headscale - ./nfs-client.nix - ./unbound.nix - ]; + imports = [pcsd.nixosModules.default]; services.pcsd = { enable = true; diff --git a/devices/homie/default.nix b/devices/homie/default.nix index 23bdf9aa..07003323 100644 --- a/devices/homie/default.nix +++ b/devices/homie/default.nix @@ -11,7 +11,7 @@ in { imports = [ ./hardware-configuration.nix - ./modules/home-assistant.nix + ./modules self.nixosModules.kmscon self.nixosModules.server @@ -19,7 +19,6 @@ in { # State Version: DO NOT CHANGE system.stateVersion = "24.11"; - home-manager.users.${mainUser}.home.stateVersion = "24.11"; # ------------------------------------------------ # User Settings diff --git a/devices/homie/modules/default.nix b/devices/homie/modules/default.nix new file mode 100644 index 00000000..0ae84ed6 --- /dev/null +++ b/devices/homie/modules/default.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ./home-assistant.nix + ]; +} diff --git a/devices/nos/default.nix b/devices/nos/default.nix index a8dc6da0..c8265aee 100644 --- a/devices/nos/default.nix +++ b/devices/nos/default.nix @@ -11,13 +11,7 @@ in { imports = [ ./hardware-configuration.nix - ./modules/docker - ./modules/jellyfin - ./modules/llm.nix - ./modules/mergerfs.nix - ./modules/qbittorrent - ./modules/snapraid.nix - ./modules/subtitles + ./modules self.nixosModules.kmscon self.nixosModules.server @@ -25,7 +19,6 @@ in { # State Version: DO NOT CHANGE system.stateVersion = "24.05"; - home-manager.users.${mainUser}.home.stateVersion = "24.05"; # ------------------------------------------------ # User Settings diff --git a/devices/nos/modules/default.nix b/devices/nos/modules/default.nix new file mode 100644 index 00000000..ffcfdfd5 --- /dev/null +++ b/devices/nos/modules/default.nix @@ -0,0 +1,11 @@ +{...}: { + imports = [ + ./docker + ./jellyfin + ./qbittorrent + ./subtitles + ./llm.nix + ./mergerfs.nix + ./snapraid.nix + ]; +} diff --git a/devices/servivi/default.nix b/devices/servivi/default.nix index a8209807..20b862ad 100644 --- a/devices/servivi/default.nix +++ b/devices/servivi/default.nix @@ -11,11 +11,7 @@ in { imports = [ ./hardware-configuration.nix - ./modules/7-days-to-die.nix - ./modules/binary-cache.nix - ./modules/minecraft.nix - ./modules/nfs.nix - ./modules/pr-tracker.nix + ./modules self.nixosModules.docker self.nixosModules.kmscon @@ -24,7 +20,6 @@ in { # State Version: DO NOT CHANGE system.stateVersion = "24.05"; - home-manager.users.${mainUser}.home.stateVersion = "24.05"; # ------------------------------------------------ # User Settings diff --git a/devices/servivi/modules/default.nix b/devices/servivi/modules/default.nix new file mode 100644 index 00000000..e757b3b4 --- /dev/null +++ b/devices/servivi/modules/default.nix @@ -0,0 +1,9 @@ +{...}: { + imports = [ + ./7-days-to-die.nix + ./binary-cache.nix + ./minecraft.nix + ./nfs.nix + ./pr-tracker.nix + ]; +} diff --git a/devices/wim/default.nix b/devices/wim/default.nix index 96dacef1..5d2dab35 100644 --- a/devices/wim/default.nix +++ b/devices/wim/default.nix @@ -12,7 +12,7 @@ in { imports = [ ./hardware-configuration.nix - ./modules/security.nix + ./modules self.nixosModules.adb self.nixosModules.desktop @@ -21,14 +21,10 @@ in { self.nixosModules.server ]; - home-manager.users.${mainUser} = { - imports = [ - self.homeManagerModules.firefox - ]; + home-manager.users.${mainUser}.imports = [ + self.homeManagerModules.firefox + ]; - # State Version: DO NOT CHANGE - home.stateVersion = "23.05"; - }; # State Version: DO NOT CHANGE system.stateVersion = "23.05"; diff --git a/devices/wim/modules/default.nix b/devices/wim/modules/default.nix new file mode 100644 index 00000000..4f99fcf3 --- /dev/null +++ b/devices/wim/modules/default.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ./security.nix + ]; +} diff --git a/outputs.nix b/outputs.nix index 1d4267af..52299a39 100644 --- a/outputs.nix +++ b/outputs.nix @@ -117,7 +117,6 @@ live-image = mkNixOS { extraModules = [ "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" - {home-manager.users.nixos.home.stateVersion = "24.05";} { vars = { mainUser = "nixos";