forked from jan-leila/nix-config
		
	fixed nix-darwin building
This commit is contained in:
		
							parent
							
								
									0d0443a02a
								
							
						
					
					
						commit
						5f21fd43ff
					
				
					 14 changed files with 201 additions and 105 deletions
				
			
		
							
								
								
									
										20
									
								
								configurations/darwin/hesperium/configuration.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								configurations/darwin/hesperium/configuration.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,20 @@ | ||||||
|  | {...}: { | ||||||
|  |   host = { | ||||||
|  |     users = { | ||||||
|  |       leyla = { | ||||||
|  |         isDesktopUser = true; | ||||||
|  |         isTerminalUser = true; | ||||||
|  |         isPrincipleUser = true; | ||||||
|  |       }; | ||||||
|  |       ester = { | ||||||
|  |         isPrincipleUser = true; | ||||||
|  |         isNormalUser = true; | ||||||
|  |       }; | ||||||
|  |       eve.isNormalUser = false; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   system.stateVersion = 5; | ||||||
|  | 
 | ||||||
|  |   nixpkgs.hostPlatform = "aarch64-darwin"; | ||||||
|  | } | ||||||
|  | @ -1 +1,5 @@ | ||||||
| {...}: {} | {...}: { | ||||||
|  |   imports = [ | ||||||
|  |     ./configuration.nix | ||||||
|  |   ]; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -2,5 +2,7 @@ | ||||||
| {...}: { | {...}: { | ||||||
|   imports = [ |   imports = [ | ||||||
|     ./home-manager |     ./home-manager | ||||||
|  |     ./users.nix | ||||||
|  |     ./system.nix | ||||||
|   ]; |   ]; | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										27
									
								
								modules/darwin-modules/system.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								modules/darwin-modules/system.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | ||||||
|  | {self, ...}: { | ||||||
|  |   system.configurationRevision = self.rev or self.dirtyRev or null; | ||||||
|  | 
 | ||||||
|  |   nix = { | ||||||
|  |     gc = { | ||||||
|  |       automatic = true; | ||||||
|  |       interval = [ | ||||||
|  |         { | ||||||
|  |           Hour = 4; | ||||||
|  |           Minute = 15; | ||||||
|  |           Weekday = 7; | ||||||
|  |         } | ||||||
|  |       ]; | ||||||
|  |       options = "--delete-older-than 7d"; | ||||||
|  |     }; | ||||||
|  |     optimise = { | ||||||
|  |       automatic = true; | ||||||
|  |       interval = [ | ||||||
|  |         { | ||||||
|  |           Hour = 4; | ||||||
|  |           Minute = 15; | ||||||
|  |           Weekday = 7; | ||||||
|  |         } | ||||||
|  |       ]; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | } | ||||||
							
								
								
									
										20
									
								
								modules/darwin-modules/users.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								modules/darwin-modules/users.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,20 @@ | ||||||
|  | { | ||||||
|  |   lib, | ||||||
|  |   config, | ||||||
|  |   ... | ||||||
|  | }: let | ||||||
|  |   host = config.host; | ||||||
|  | in { | ||||||
|  |   users = { | ||||||
|  |     users = { | ||||||
|  |       leyla = { | ||||||
|  |         name = lib.mkForce host.users.leyla.name; | ||||||
|  |         home = lib.mkForce "/home/${host.users.leyla.name}"; | ||||||
|  |       }; | ||||||
|  |       ester = { | ||||||
|  |         name = lib.mkForce host.users.ester.name; | ||||||
|  |         home = lib.mkForce "/home/${host.users.ester.name}"; | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | } | ||||||
|  | @ -6,7 +6,7 @@ | ||||||
|     ./hardware.nix |     ./hardware.nix | ||||||
|     ./users.nix |     ./users.nix | ||||||
|     ./desktop.nix |     ./desktop.nix | ||||||
|     ./nix-development.nix |     ./ssh.nix | ||||||
|     ./i18n.nix |     ./i18n.nix | ||||||
|   ]; |   ]; | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										13
									
								
								modules/nixos-modules/ssh.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								modules/nixos-modules/ssh.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | ||||||
|  | {...}: { | ||||||
|  |   services = { | ||||||
|  |     openssh = { | ||||||
|  |       enable = true; | ||||||
|  |       ports = [22]; | ||||||
|  |       settings = { | ||||||
|  |         PasswordAuthentication = false; | ||||||
|  |         UseDns = true; | ||||||
|  |         X11Forwarding = false; | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | } | ||||||
|  | @ -1,8 +1,5 @@ | ||||||
| {...}: { | {...}: { | ||||||
|   nix = { |   nix = { | ||||||
|     settings = { |  | ||||||
|       experimental-features = ["nix-command" "flakes"]; |  | ||||||
|     }; |  | ||||||
|     gc = { |     gc = { | ||||||
|       automatic = true; |       automatic = true; | ||||||
|       dates = "weekly"; |       dates = "weekly"; | ||||||
|  | @ -13,16 +10,4 @@ | ||||||
|       dates = ["weekly"]; |       dates = ["weekly"]; | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| 
 |  | ||||||
|   services = { |  | ||||||
|     openssh = { |  | ||||||
|       enable = true; |  | ||||||
|       ports = [22]; |  | ||||||
|       settings = { |  | ||||||
|         PasswordAuthentication = false; |  | ||||||
|         UseDns = true; |  | ||||||
|         X11Forwarding = false; |  | ||||||
|       }; |  | ||||||
|     }; |  | ||||||
|   }; |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -8,7 +8,6 @@ | ||||||
| 
 | 
 | ||||||
|   host = config.host; |   host = config.host; | ||||||
| 
 | 
 | ||||||
|   hostUsers = host.hostUsers; |  | ||||||
|   principleUsers = host.principleUsers; |   principleUsers = host.principleUsers; | ||||||
|   terminalUsers = host.terminalUsers; |   terminalUsers = host.terminalUsers; | ||||||
|   # normalUsers = host.normalUsers; |   # normalUsers = host.normalUsers; | ||||||
|  | @ -44,91 +43,7 @@ | ||||||
|   ester = users.ester.name; |   ester = users.ester.name; | ||||||
|   eve = users.eve.name; |   eve = users.eve.name; | ||||||
| in { | in { | ||||||
|   options.host = { |  | ||||||
|     users = lib.mkOption { |  | ||||||
|       type = lib.types.attrsOf (lib.types.submodule ({ |  | ||||||
|         config, |  | ||||||
|         name, |  | ||||||
|         ... |  | ||||||
|       }: { |  | ||||||
|         options = { |  | ||||||
|           name = lib.mkOption { |  | ||||||
|             type = lib.types.str; |  | ||||||
|             default = name; |  | ||||||
|             description = '' |  | ||||||
|               What should this users name on the system be |  | ||||||
|             ''; |  | ||||||
|             defaultText = lib.literalExpression "config.host.users.\${name}.name"; |  | ||||||
|           }; |  | ||||||
|           isPrincipleUser = lib.mkOption { |  | ||||||
|             type = lib.types.bool; |  | ||||||
|             default = false; |  | ||||||
|             description = '' |  | ||||||
|               User should be configured as root and have ssh access |  | ||||||
|             ''; |  | ||||||
|             defaultText = lib.literalExpression "config.host.users.\${name}.isPrincipleUser"; |  | ||||||
|           }; |  | ||||||
|           isDesktopUser = lib.mkOption { |  | ||||||
|             type = lib.types.bool; |  | ||||||
|             default = false; |  | ||||||
|             description = '' |  | ||||||
|               User should install their desktop applications |  | ||||||
|             ''; |  | ||||||
|             defaultText = lib.literalExpression "config.host.users.\${name}.isDesktopUser"; |  | ||||||
|           }; |  | ||||||
|           isTerminalUser = lib.mkOption { |  | ||||||
|             type = lib.types.bool; |  | ||||||
|             default = false; |  | ||||||
|             description = '' |  | ||||||
|               User should install their terminal applications |  | ||||||
|             ''; |  | ||||||
|             defaultText = lib.literalExpression "config.host.users.\${name}.isTerminalUser"; |  | ||||||
|           }; |  | ||||||
|           isNormalUser = lib.mkOption { |  | ||||||
|             type = lib.types.bool; |  | ||||||
|             default = config.isDesktopUser || config.isTerminalUser; |  | ||||||
|             description = '' |  | ||||||
|               User should install their applications and can log in |  | ||||||
|             ''; |  | ||||||
|             defaultText = lib.literalExpression "config.host.users.\${name}.isNormalUser"; |  | ||||||
|           }; |  | ||||||
|         }; |  | ||||||
|       })); |  | ||||||
|     }; |  | ||||||
|     hostUsers = lib.mkOption { |  | ||||||
|       default = lib.attrsets.mapAttrsToList (_: user: user) host.users; |  | ||||||
|     }; |  | ||||||
|     principleUsers = lib.mkOption { |  | ||||||
|       default = lib.lists.filter (user: user.isPrincipleUser) hostUsers; |  | ||||||
|     }; |  | ||||||
|     normalUsers = lib.mkOption { |  | ||||||
|       default = lib.lists.filter (user: user.isTerminalUser) hostUsers; |  | ||||||
|     }; |  | ||||||
|     terminalUsers = lib.mkOption { |  | ||||||
|       default = lib.lists.filter (user: user.isNormalUser) hostUsers; |  | ||||||
|     }; |  | ||||||
|   }; |  | ||||||
| 
 |  | ||||||
|   config = { |   config = { | ||||||
|     assertions = |  | ||||||
|       ( |  | ||||||
|         builtins.map (user: { |  | ||||||
|           assertion = !(user.isPrincipleUser && !user.isNormalUser); |  | ||||||
|           message = '' |  | ||||||
|             Non normal user ${user.name} can not be a principle user. |  | ||||||
|           ''; |  | ||||||
|         }) |  | ||||||
|         hostUsers |  | ||||||
|       ) |  | ||||||
|       ++ [ |  | ||||||
|         { |  | ||||||
|           assertion = (builtins.length principleUsers) > 0; |  | ||||||
|           message = '' |  | ||||||
|             At least one user must be a principle user. |  | ||||||
|           ''; |  | ||||||
|         } |  | ||||||
|       ]; |  | ||||||
| 
 |  | ||||||
|     # principle users are by definition trusted |     # principle users are by definition trusted | ||||||
|     nix.settings.trusted-users = builtins.map (user: user.name) principleUsers; |     nix.settings.trusted-users = builtins.map (user: user.name) principleUsers; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -2,5 +2,8 @@ | ||||||
| {...}: { | {...}: { | ||||||
|   imports = [ |   imports = [ | ||||||
|     ./home-manager |     ./home-manager | ||||||
|  |     ./system.nix | ||||||
|  |     ./nix-development.nix | ||||||
|  |     ./users.nix | ||||||
|   ]; |   ]; | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										7
									
								
								modules/system-modules/system.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								modules/system-modules/system.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | ||||||
|  | {...}: { | ||||||
|  |   nix = { | ||||||
|  |     settings = { | ||||||
|  |       experimental-features = ["nix-command" "flakes"]; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | } | ||||||
							
								
								
									
										97
									
								
								modules/system-modules/users.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								modules/system-modules/users.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,97 @@ | ||||||
|  | { | ||||||
|  |   lib, | ||||||
|  |   config, | ||||||
|  |   ... | ||||||
|  | }: let | ||||||
|  |   host = config.host; | ||||||
|  | 
 | ||||||
|  |   hostUsers = host.hostUsers; | ||||||
|  |   principleUsers = host.principleUsers; | ||||||
|  | in { | ||||||
|  |   options.host = { | ||||||
|  |     users = lib.mkOption { | ||||||
|  |       default = {}; | ||||||
|  |       type = lib.types.attrsOf (lib.types.submodule ({ | ||||||
|  |         config, | ||||||
|  |         name, | ||||||
|  |         ... | ||||||
|  |       }: { | ||||||
|  |         options = { | ||||||
|  |           name = lib.mkOption { | ||||||
|  |             type = lib.types.str; | ||||||
|  |             default = name; | ||||||
|  |             description = '' | ||||||
|  |               What should this users name on the system be | ||||||
|  |             ''; | ||||||
|  |             defaultText = lib.literalExpression "config.host.users.\${name}.name"; | ||||||
|  |           }; | ||||||
|  |           isPrincipleUser = lib.mkOption { | ||||||
|  |             type = lib.types.bool; | ||||||
|  |             default = false; | ||||||
|  |             description = '' | ||||||
|  |               User should be configured as root and have ssh access | ||||||
|  |             ''; | ||||||
|  |             defaultText = lib.literalExpression "config.host.users.\${name}.isPrincipleUser"; | ||||||
|  |           }; | ||||||
|  |           isDesktopUser = lib.mkOption { | ||||||
|  |             type = lib.types.bool; | ||||||
|  |             default = false; | ||||||
|  |             description = '' | ||||||
|  |               User should install their desktop applications | ||||||
|  |             ''; | ||||||
|  |             defaultText = lib.literalExpression "config.host.users.\${name}.isDesktopUser"; | ||||||
|  |           }; | ||||||
|  |           isTerminalUser = lib.mkOption { | ||||||
|  |             type = lib.types.bool; | ||||||
|  |             default = false; | ||||||
|  |             description = '' | ||||||
|  |               User should install their terminal applications | ||||||
|  |             ''; | ||||||
|  |             defaultText = lib.literalExpression "config.host.users.\${name}.isTerminalUser"; | ||||||
|  |           }; | ||||||
|  |           isNormalUser = lib.mkOption { | ||||||
|  |             type = lib.types.bool; | ||||||
|  |             default = config.isDesktopUser || config.isTerminalUser; | ||||||
|  |             description = '' | ||||||
|  |               User should install their applications and can log in | ||||||
|  |             ''; | ||||||
|  |             defaultText = lib.literalExpression "config.host.users.\${name}.isNormalUser"; | ||||||
|  |           }; | ||||||
|  |         }; | ||||||
|  |       })); | ||||||
|  |     }; | ||||||
|  |     hostUsers = lib.mkOption { | ||||||
|  |       default = lib.attrsets.mapAttrsToList (_: user: user) host.users; | ||||||
|  |     }; | ||||||
|  |     principleUsers = lib.mkOption { | ||||||
|  |       default = lib.lists.filter (user: user.isPrincipleUser) hostUsers; | ||||||
|  |     }; | ||||||
|  |     normalUsers = lib.mkOption { | ||||||
|  |       default = lib.lists.filter (user: user.isTerminalUser) hostUsers; | ||||||
|  |     }; | ||||||
|  |     terminalUsers = lib.mkOption { | ||||||
|  |       default = lib.lists.filter (user: user.isNormalUser) hostUsers; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   config = { | ||||||
|  |     assertions = | ||||||
|  |       ( | ||||||
|  |         builtins.map (user: { | ||||||
|  |           assertion = !(user.isPrincipleUser && !user.isNormalUser); | ||||||
|  |           message = '' | ||||||
|  |             Non normal user ${user.name} can not be a principle user. | ||||||
|  |           ''; | ||||||
|  |         }) | ||||||
|  |         hostUsers | ||||||
|  |       ) | ||||||
|  |       ++ [ | ||||||
|  |         { | ||||||
|  |           assertion = (builtins.length principleUsers) > 0; | ||||||
|  |           message = '' | ||||||
|  |             At least one user must be a principle user. | ||||||
|  |           ''; | ||||||
|  |         } | ||||||
|  |       ]; | ||||||
|  |   }; | ||||||
|  | } | ||||||
|  | @ -26,6 +26,7 @@ | ||||||
|   home-manager-modules = |   home-manager-modules = | ||||||
|     common-modules |     common-modules | ||||||
|     ++ [ |     ++ [ | ||||||
|  |       sops-nix.homeManagerModules.sops | ||||||
|       ../modules/home-manager-modules |       ../modules/home-manager-modules | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|  | @ -41,10 +42,8 @@ | ||||||
|   system-modules = |   system-modules = | ||||||
|     common-modules |     common-modules | ||||||
|     ++ [ |     ++ [ | ||||||
|       ../modules/system-modules |  | ||||||
|       sops-nix.nixosModules.sops |  | ||||||
|       home-manager.nixosModules.home-manager |  | ||||||
|       home-manager-config |       home-manager-config | ||||||
|  |       ../modules/system-modules | ||||||
|     ]; |     ]; | ||||||
| in { | in { | ||||||
|   forEachPkgs = lambda: forEachSystem (system: lambda (pkgsFor system)); |   forEachPkgs = lambda: forEachSystem (system: lambda (pkgsFor system)); | ||||||
|  | @ -62,6 +61,8 @@ in { | ||||||
|       modules = |       modules = | ||||||
|         system-modules |         system-modules | ||||||
|         ++ [ |         ++ [ | ||||||
|  |           sops-nix.nixosModules.sops | ||||||
|  |           home-manager.nixosModules.home-manager | ||||||
|           ../modules/nixos-modules |           ../modules/nixos-modules | ||||||
|           ../configurations/nixos/${host} |           ../configurations/nixos/${host} | ||||||
|         ]; |         ]; | ||||||
|  | @ -73,6 +74,8 @@ in { | ||||||
|       modules = |       modules = | ||||||
|         system-modules |         system-modules | ||||||
|         ++ [ |         ++ [ | ||||||
|  |           sops-nix.darwinModules.sops | ||||||
|  |           home-manager.darwinModules.home-manager | ||||||
|           ../modules/darwin-modules |           ../modules/darwin-modules | ||||||
|           ../configurations/darwin/${host} |           ../configurations/darwin/${host} | ||||||
|         ]; |         ]; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue