From 5117de65771b6ed15a8ebda5601dfcdfa7aa35a8 Mon Sep 17 00:00:00 2001 From: "Mohamed C." Date: Fri, 30 Aug 2024 21:34:02 +0200 Subject: [PATCH] way better syntax with groups --- flake.nix | 191 +++++++++++++++--------------------------------------- 1 file changed, 51 insertions(+), 140 deletions(-) diff --git a/flake.nix b/flake.nix index 0d9ed97..450ca82 100644 --- a/flake.nix +++ b/flake.nix @@ -8,53 +8,71 @@ url = "github:nix-community/home-manager/master"; inputs.nixpkgs.follows = "nixpkgs"; }; - jovian.url = "github:Jovian-Experiments/Jovian-NixOS/development"; plasma-manager = { url = "github:nix-community/plasma-manager/trunk"; inputs.nixpkgs.follows = "nixpkgs"; inputs.home-manager.follows = "home-manager"; }; + jovian.url = "github:Jovian-Experiments/Jovian-NixOS/development"; nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=v0.4.1"; }; # Define Outputs, import Modules - outputs = { - nixpkgs, - home-manager, - jovian, - plasma-manager, - nix-flatpak, - ... - }: + outputs = { nixpkgs, home-manager, plasma-manager, jovian, nix-flatpak, ... }: let # Define system globally since I have no aarch devices system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; }; lib = nixpkgs.lib; - - # NixOS Modules for all hosts - systemModules = [ - home-manager.nixosModules.home-manager - nix-flatpak.nixosModules.nix-flatpak - ./modules/system/apps-shell - ./modules/system/boot - ./modules/system/devices - ./modules/system/home-manager - ./modules/system/locale - ./modules/system/networking - ./modules/system/nixsettings - ./modules/system/shell - ./modules/system/systemversion - ./modules/system/upgrades - ./modules/system/users + # External Modules + externalSystemModules = [home-manager.nixosModules.home-manager jovian.nixosModules.jovian nix-flatpak.nixosModules.nix-flatpak]; + externalUserModules = [ plasma-manager.homeManagerModules.plasma-manager]; + # System Module groups + baseSystemModules = [ + ./modules/system/apps-shell + ./modules/system/boot + ./modules/system/devices + ./modules/system/home-manager + ./modules/system/locale + ./modules/system/networking + ./modules/system/nixsettings + ./modules/system/shell + ./modules/system/systemversion + ./modules/system/upgrades + ./modules/system/users + ]; + desktopSystemModules = [ + ./modules/system/ai + ./modules/system/apps-misc + ./modules/system/browser + ./modules/system/flatpak + ./modules/system/plasma + ]; + displaySystemModules = [ + ./modules/system/sddm + ]; + gamingSystemModules = [ + ./modules/system/controller + ./modules/system/lact + ./modules/system/retrodeck + ./modules/system/steam + ./modules/system/syncthing ]; - # Home Manager Modules for all hosts - userModules = [ - ./modules/user/git - ./modules/user/homeversion - ./modules/user/shell + serverSystemModules = [ + ./modules/system/docker ]; + # USER Module groups + baseUserModules = [ + ./modules/user/git + ./modules/user/homeversion + ./modules/user/shell + ]; + desktopUserModules = [ + ./modules/user/plasma + ]; + gamingUserModules = []; + serverUserModules = []; in { nixosConfigurations = { @@ -68,123 +86,16 @@ specialArgs = {inherit user; inherit hostName;}; system = system; # Device specific NixOS Modules - modules = systemModules ++ [ - jovian.nixosModules.jovian + modules = externalSystemModules ++ baseSystemModules ++ desktopSystemModules ++ displaySystemModules ++ gamingSystemModules ++ [ ./hosts/${hostName} - ./modules/system/ai - ./modules/system/apps-misc - ./modules/system/browser - ./modules/system/controller - ./modules/system/flatpak ./modules/system/jovian-${hostName} - ./modules/system/lact - ./modules/system/plasma - ./modules/system/retrodeck - ./modules/system/steam - ./modules/system/syncthing - ./modules/system/sddm { # Device specific Home Manager Modules - home-manager.users.${user}.imports = userModules ++ [ - ./modules/user/plasma + home-manager.users.${user}.imports = baseUserModules ++ desktopUserModules ++ [ ]; # Issue with Plasma Manager, has to be imported in a special way home-manager.extraSpecialArgs = { inherit user; inherit hostName;}; - home-manager.sharedModules = [ plasma-manager.homeManagerModules.plasma-manager ]; - } - ]; - }; - - # Steamdeck config - steamdeck = - let - user = "deck"; - hostName = "steamdeck"; - in - lib.nixosSystem { - specialArgs = {inherit user; inherit hostName;}; - system = system; - # Device specific NixOS Modules - modules = systemModules ++ [ - jovian.nixosModules.jovian - ./hosts/${hostName} - ./modules/system/apps-misc - ./modules/system/browser - ./modules/system/controller - ./modules/system/flatpak - ./modules/system/jovian-${hostName} - ./modules/system/lact - ./modules/system/plasma - ./modules/system/retrodeck - ./modules/system/steam - ./modules/system/syncthing - { - # Device specific Home Manager Modules - home-manager.users.${user}.imports = userModules ++ [ - ./modules/user/plasma - ]; - # Issue with Plasma Manager, has to be imported in a special way - home-manager.extraSpecialArgs = { inherit user; inherit hostName;}; - home-manager.sharedModules = [ plasma-manager.homeManagerModules.plasma-manager ]; - } - ]; - }; - - # Konsole config - konsole = - let - user = "deck"; - hostName = "konsole"; - in - lib.nixosSystem { - specialArgs = {inherit user; inherit hostName;}; - system = system; - # Device specific NixOS Modules - modules = systemModules ++ [ - jovian.nixosModules.jovian - ./hosts/${hostName} - ./modules/system/apps-misc - ./modules/system/browser - ./modules/system/controller - ./modules/system/flatpak - ./modules/system/jovian-${hostName} - ./modules/system/lact - ./modules/system/plasma - ./modules/system/retrodeck - ./modules/system/steam - ./modules/system/syncthing - { - # Device specific Home Manager Modules - home-manager.users.${user}.imports = userModules ++ [ - ./modules/user/plasma - ]; - # Issue with Plasma Manager, has to be imported in a special way - home-manager.extraSpecialArgs = { inherit user; inherit hostName;}; - home-manager.sharedModules = [ plasma-manager.homeManagerModules.plasma-manager ]; - } - ]; - }; - - # Server config - server = - let - user = "administrator"; - hostName = "server"; - in - lib.nixosSystem { - specialArgs = {inherit user; inherit hostName;}; - system = system; - # Device specific NixOS Modules - modules = systemModules ++ [ - ./hosts/${hostName} - ./modules/docker - ./modules/system/syncthing - { - # Device specific Home Manager Modules - home-manager.users.${user}.imports = userModules; - # Issue with Plasma Manager, has to be imported in a special way - home-manager.extraSpecialArgs = { inherit user; inherit hostName;}; - home-manager.sharedModules = []; + home-manager.sharedModules = externalUserModules; } ]; };