mirror of
				https://github.com/Jokiller230/puzzlevision.git
				synced 2025-10-31 05:40:05 +00:00 
			
		
		
		
	🚧 Initial work on generating homeConfigurations output + syntax changes
This commit is contained in:
		
							parent
							
								
									f139b88c0b
								
							
						
					
					
						commit
						f89cbcc552
					
				
					 12 changed files with 131 additions and 106 deletions
				
			
		
							
								
								
									
										28
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										28
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							|  | @ -2,15 +2,15 @@ | |||
|   "nodes": { | ||||
|     "easy-hosts": { | ||||
|       "locked": { | ||||
|         "lastModified": 1736680851, | ||||
|         "narHash": "sha256-KUkO4H0W+1u5piwAzIzCuVhamQ0L3io8vR61NrODtHs=", | ||||
|         "owner": "isabelroses", | ||||
|         "lastModified": 1739315072, | ||||
|         "narHash": "sha256-m0Lzdrj95GbdmKhqlTKkr4vvHy2Ghdi1GxISOKqUeSA=", | ||||
|         "owner": "tgirlcloud", | ||||
|         "repo": "easy-hosts", | ||||
|         "rev": "450d2ae463bb8fb55194f33073ebdd83b8b7ddaa", | ||||
|         "rev": "e96af44cae1f48a1a94f2471faee92caf22aa45f", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|         "owner": "isabelroses", | ||||
|         "owner": "tgirlcloud", | ||||
|         "repo": "easy-hosts", | ||||
|         "type": "github" | ||||
|       } | ||||
|  | @ -22,11 +22,11 @@ | |||
|         ] | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1736143030, | ||||
|         "narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=", | ||||
|         "lastModified": 1741352980, | ||||
|         "narHash": "sha256-+u2UunDA4Cl5Fci3m7S643HzKmIDAe+fiXrLqYsR2fs=", | ||||
|         "owner": "hercules-ci", | ||||
|         "repo": "flake-parts", | ||||
|         "rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de", | ||||
|         "rev": "f4330d22f1c5d2ba72d3d22df5597d123fdb60a9", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|  | @ -42,11 +42,11 @@ | |||
|         ] | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1736785676, | ||||
|         "narHash": "sha256-TY0jUwR3EW0fnS0X5wXMAVy6h4Z7Y6a3m+Yq++C9AyE=", | ||||
|         "lastModified": 1742305478, | ||||
|         "narHash": "sha256-iYCinzZnnUeCkZ031qGRwPdwRsqW6o9Y0MgGpA7Zva4=", | ||||
|         "owner": "nix-community", | ||||
|         "repo": "home-manager", | ||||
|         "rev": "fc52a210b60f2f52c74eac41a8647c1573d2071d", | ||||
|         "rev": "fb74bb76d94a6c55632376c931fc108131260ee9", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|  | @ -57,11 +57,11 @@ | |||
|     }, | ||||
|     "nixpkgs": { | ||||
|       "locked": { | ||||
|         "lastModified": 1736701207, | ||||
|         "narHash": "sha256-jG/+MvjVY7SlTakzZ2fJ5dC3V1PrKKrUEOEE30jrOKA=", | ||||
|         "lastModified": 1742069588, | ||||
|         "narHash": "sha256-C7jVfohcGzdZRF6DO+ybyG/sqpo1h6bZi9T56sxLy+k=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "ed4a395ea001367c1f13d34b1e01aa10290f67d6", | ||||
|         "rev": "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|  |  | |||
							
								
								
									
										16
									
								
								flake.nix
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								flake.nix
									
										
									
									
									
								
							|  | @ -1,9 +1,23 @@ | |||
| { | ||||
|   description = "Jo's dotfiles"; | ||||
| 
 | ||||
|   nixConfig = { | ||||
|     experimental-features = [ | ||||
|       "flakes" | ||||
|       "nix-command" | ||||
|     ]; | ||||
|     extra-substituters = [ | ||||
|       "https://nix-community.cachix.org" | ||||
|     ]; | ||||
|     extra-trusted-public-keys = [ | ||||
|       "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" | ||||
|       "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" | ||||
|     ]; | ||||
|   }; | ||||
| 
 | ||||
|   inputs = { | ||||
|     nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||||
|     easy-hosts.url = "github:isabelroses/easy-hosts"; | ||||
|     easy-hosts.url = "github:tgirlcloud/easy-hosts"; | ||||
| 
 | ||||
|     flake-parts = { | ||||
|       url = "github:hercules-ci/flake-parts"; | ||||
|  |  | |||
|  | @ -1,16 +1,13 @@ | |||
| { | ||||
|   lib, | ||||
|   ... | ||||
| }: | ||||
| { | ||||
| {lib, ...}: { | ||||
|   # Create a NixOS module option on a single line. | ||||
|   mkOpt = | ||||
|     type: default: description: | ||||
|   mkOpt = type: default: description: | ||||
|     lib.mkOption {inherit type default description;}; | ||||
| 
 | ||||
|   mkBool = | ||||
|     default: description: | ||||
|       lib.mkOption { inherit default description; type = lib.types.bool; }; | ||||
|   mkBool = default: description: | ||||
|     lib.mkOption { | ||||
|       inherit default description; | ||||
|       type = lib.types.bool; | ||||
|     }; | ||||
| 
 | ||||
|   # Todo: add mkIfElse function | ||||
| } | ||||
|  |  | |||
|  | @ -1,8 +1,4 @@ | |||
| { | ||||
|   config, | ||||
|   ... | ||||
| }: | ||||
| { | ||||
| {config, ...}: { | ||||
|   # Apply some useful module arguments. | ||||
|   _module.args = { | ||||
|     namespace = config.flake.namespace; | ||||
|  |  | |||
|  | @ -11,5 +11,8 @@ | |||
| 
 | ||||
|     # Automagically imports systems from "/systems/arch-classname/system-name". | ||||
|     ./systems.nix | ||||
| 
 | ||||
|     # Automagically imports homes from "/homes/user-name". | ||||
|     ./homes.nix | ||||
|   ]; | ||||
| } | ||||
|  |  | |||
							
								
								
									
										22
									
								
								modules/flake/homes.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								modules/flake/homes.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| { | ||||
|   lib, | ||||
|   inputs, | ||||
|   puzzlelib, | ||||
|   ... | ||||
| }: let | ||||
|   HomeConfiguration = args: let | ||||
|     nixpkgs = inputs.nixpkgs; | ||||
|   in | ||||
|     inputs.home-manager.lib.homeManagerConfiguration { | ||||
|       modules = (puzzlelib.dirToModuleList ../home) ++ args.modules; | ||||
|       extraSpecialArgs = | ||||
|         { | ||||
|           inherit (args) nixpkgs; | ||||
|         } | ||||
|         // args.extraSpecialArgs; | ||||
|     }; | ||||
| in { | ||||
|   perSystem = { | ||||
|     # TODO Dynamically export homeConfigurations by consuming contents of /homes/user-name | ||||
|   }; | ||||
| } | ||||
|  | @ -2,50 +2,46 @@ | |||
|   lib, | ||||
|   puzzlelib, | ||||
|   ... | ||||
| }: | ||||
| let | ||||
| }: let | ||||
|   # Utility function to read a directory and return its contents. | ||||
|   readDirectory = directory: builtins.readDir directory; | ||||
| 
 | ||||
|   # Utility function to handle each filesystem entity (file or directory). | ||||
|   filesystemEntityToAttrSet = directory: importArgs: name: type: | ||||
|     if type == "directory" then | ||||
|       dirToAttrSet "${directory}/${name}" importArgs | ||||
|     else if name == "default.nix" then | ||||
|       import "${directory}/${name}" importArgs | ||||
|     else | ||||
|       {}; | ||||
|     if type == "directory" | ||||
|     then dirToAttrSet "${directory}/${name}" importArgs | ||||
|     else if name == "default.nix" | ||||
|     then import "${directory}/${name}" importArgs | ||||
|     else {}; | ||||
| 
 | ||||
|   filesystemEntityToList = directory: name: type: | ||||
|     if type == "directory" then | ||||
|       dirToModuleList "${directory}/${name}" | ||||
|     else if name == "default.nix" then | ||||
|       [ "${directory}/${name}" ] | ||||
|     else | ||||
|       []; | ||||
|     if type == "directory" | ||||
|     then dirToModuleList "${directory}/${name}" | ||||
|     else if name == "default.nix" | ||||
|     then ["${directory}/${name}"] | ||||
|     else []; | ||||
| 
 | ||||
|   dirToModuleList = directory: | ||||
|     let | ||||
|   dirToModuleList = directory: let | ||||
|     readDir = readDirectory directory; | ||||
|   in | ||||
|       builtins.foldl' (acc: name: | ||||
|     builtins.foldl' ( | ||||
|       acc: name: | ||||
|         acc ++ (filesystemEntityToList directory name (builtins.getAttr name readDir)) | ||||
|     ) [] (builtins.attrNames readDir); | ||||
| 
 | ||||
|   # Utility function to recursively load modules from a directory. | ||||
|   dirToAttrSet = directory: importArgs: | ||||
|     let | ||||
|   dirToAttrSet = directory: importArgs: let | ||||
|     # Read provided directory only once at the very start and save the result. | ||||
|     readDir = readDirectory directory; | ||||
|   in | ||||
|     # Iterate over the attr names of a readDir operation. | ||||
|       builtins.foldl' (acc: name: | ||||
|     builtins.foldl' ( | ||||
|       acc: name: | ||||
|       # Merge outputs of handling a filesystem entity (file or directory) into accumulator. | ||||
|       # Files return attribute sets with their resulting expressions, directories return the result of multiple file handling operations. | ||||
|         acc // (filesystemEntityToAttrSet directory importArgs name (builtins.getAttr name readDir)) | ||||
|     ) {} (builtins.attrNames readDir); | ||||
| in | ||||
| { | ||||
| in { | ||||
|   # Add lib.${namespace} attribute to module arguments, for easy access. | ||||
|   # Additionally, pass on dirToAttrSet method on lib.${namespace} for reusability in other modules. | ||||
|   _module.args = { | ||||
|  |  | |||
|  | @ -4,8 +4,7 @@ | |||
|   namespace, | ||||
|   puzzlelib, | ||||
|   ... | ||||
| }: | ||||
| { | ||||
| }: { | ||||
|   imports = [inputs.easy-hosts.flakeModule]; | ||||
| 
 | ||||
|   easyHosts = { | ||||
|  | @ -19,11 +18,11 @@ | |||
|     }; | ||||
| 
 | ||||
|     perClass = class: { | ||||
|       modules = [ | ||||
|       modules = | ||||
|         (lib.optionals (class == "nixos") [ | ||||
|           inputs.home-manager.nixosModules.default | ||||
|         ]) | ||||
|       ] ++ (puzzlelib.dirToModuleList ../${class}); # Import modules based on current classname. | ||||
|         ++ (puzzlelib.dirToModuleList ../${class}); # Import modules based on current classname. | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
|  |  | |||
							
								
								
									
										2
									
								
								modules/home/desktop/gnome.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								modules/home/desktop/gnome.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | |||
| {}: { | ||||
| } | ||||
|  | @ -3,12 +3,10 @@ | |||
|   config, | ||||
|   namespace, | ||||
|   ... | ||||
| }: | ||||
| let | ||||
| }: let | ||||
|   inherit (lib) mkEnableOption mkIf; | ||||
|   cfg = config.${namespace}.desktop.gnome; | ||||
| in | ||||
| { | ||||
| in { | ||||
|   options.${namespace}.desktop.gnome = {enable = mkEnableOption "Enable the gnome desktop environment ${namespace}";}; | ||||
| 
 | ||||
|   config = mkIf cfg.enable { | ||||
|  |  | |||
|  | @ -4,14 +4,12 @@ | |||
|   namespace, | ||||
|   puzzlelib, | ||||
|   ... | ||||
| }: | ||||
| let | ||||
| }: let | ||||
|   inherit (lib) mkIf mkMerge; | ||||
|   inherit (puzzlelib) mkOpt mkBool; | ||||
| 
 | ||||
|   cfg = config.${namespace}.utils.vm; | ||||
| in | ||||
| { | ||||
| in { | ||||
|   options.${namespace}.utils.vm = { | ||||
|     enable = mkBool true "Whether to enable custom vm presets"; | ||||
|     preset = mkOpt lib.types.str "performance" "Specify the prefered vm settings preset: performance, balance or powersave"; | ||||
|  | @ -19,20 +17,23 @@ in | |||
| 
 | ||||
|   config = mkIf cfg.enable { | ||||
|     virtualisation.vmVariant = mkMerge [ | ||||
|       (mkIf cfg.preset == "performance" { | ||||
|       (mkIf cfg.preset | ||||
|         == "performance" { | ||||
|           virtualisation = { | ||||
|             cores = 6; | ||||
|             memorySize = 4096; | ||||
|             graphics = true; | ||||
|           }; | ||||
|         }) | ||||
|       (mkIf cfg.preset == "balance" { | ||||
|       (mkIf cfg.preset | ||||
|         == "balance" { | ||||
|           virtualisation = { | ||||
|             cores = 4; | ||||
|             memorySize = 2048; | ||||
|           }; | ||||
|         }) | ||||
|       (mkIf cfg.preset == "powersave" { | ||||
|       (mkIf cfg.preset | ||||
|         == "powersave" { | ||||
|           virtualisation = { | ||||
|             cores = 2; | ||||
|             memorySize = 1024; | ||||
|  |  | |||
|  | @ -1,8 +1,4 @@ | |||
| { | ||||
|   pkgs, | ||||
|   ... | ||||
| }: | ||||
| { | ||||
| {pkgs, ...}: { | ||||
|   imports = [ | ||||
|     ./hardware.nix | ||||
|   ]; | ||||
|  | @ -14,7 +10,6 @@ | |||
|   # System configuration | ||||
|   puzzlevision = { | ||||
|     # Todo: pass a set of users to enable from within easy-hosts and automatically map the corresponding home-manager configurations | ||||
|     # mainUser = "jo"; | ||||
|     # users = [ "jo" ]; | ||||
| 
 | ||||
|     desktop.gnome.enable = true; | ||||
|  | @ -22,6 +17,8 @@ | |||
| 
 | ||||
|   environment.systemPackages = with pkgs; [ | ||||
|     ghostty | ||||
|     firefox | ||||
|     vscodium | ||||
|   ]; | ||||
| 
 | ||||
|   system.stateVersion = "25.05"; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue