mirror of
				https://github.com/Stunkymonkey/nixos.git
				synced 2025-10-30 01:12:10 +01:00 
			
		
		
		
	service/homer: simplify
This commit is contained in:
		
							parent
							
								
									efd88fb11b
								
							
						
					
					
						commit
						6d3a814015
					
				
					 2 changed files with 36 additions and 38 deletions
				
			
		|  | @ -105,39 +105,46 @@ | ||||||
|   config = |   config = | ||||||
|     let |     let | ||||||
|       cfg = config.webapps; |       cfg = config.webapps; | ||||||
|  |       appsWithName = builtins.filter (app: app.dashboard.name != null) (lib.attrValues cfg.apps); | ||||||
|     in |     in | ||||||
|     { |     { | ||||||
|       lib.webapps.homerServices = |       lib.webapps.homerServices = lib.forEach cfg.dashboardCategories ( | ||||||
|         let |         category: | ||||||
|           apps = builtins.filter (a: a.dashboard.name != null) (lib.attrValues cfg.apps); |  | ||||||
|         in |  | ||||||
|         lib.forEach cfg.dashboardCategories ( |  | ||||||
|           cat: |  | ||||||
|         let |         let | ||||||
|  |           catTag = category.tag; | ||||||
|           catApps = lib.sort (a: b: a.dashboard.name < b.dashboard.name) ( |           catApps = lib.sort (a: b: a.dashboard.name < b.dashboard.name) ( | ||||||
|             builtins.filter ( |             builtins.filter ( | ||||||
|                 a: |               app: | ||||||
|                 a.dashboard.category != null && a.dashboard.category == cat.tag |               let | ||||||
|                 || a.dashboard.category == null && cat.tag == "misc" |                 cat = app.dashboard.category; | ||||||
|               ) apps |               in | ||||||
|  |               (cat != null && cat == catTag) || (cat == null && catTag == "misc") | ||||||
|  |             ) appsWithName | ||||||
|           ); |           ); | ||||||
|         in |         in | ||||||
|         { |         { | ||||||
|             inherit (cat) name; |           inherit (category) name; | ||||||
|             items = lib.forEach catApps (a: { |           items = lib.forEach catApps ( | ||||||
|               inherit (a.dashboard) |             app: | ||||||
|  |             let | ||||||
|  |               dash = app.dashboard; | ||||||
|  |             in | ||||||
|  |             { | ||||||
|  |               inherit (dash) | ||||||
|                 method |                 method | ||||||
|                 name |                 name | ||||||
|                 type |                 type | ||||||
|                 url |                 url | ||||||
|                 ; |                 ; | ||||||
|               icon = lib.optionalString (a.dashboard.icon != null) "fas fa-${a.dashboard.icon}"; |               icon = lib.optionalString (dash.icon != null) "fas fa-${dash.icon}"; | ||||||
|               target = "_blank"; |               target = "_blank"; | ||||||
|             }); |  | ||||||
|             } |             } | ||||||
|           ); |           ); | ||||||
|       my.services.blackbox.http_endpoints = |         } | ||||||
|         lib.mapAttrsToList (_key: value: value.dashboard.url) config.webapps.apps |       ); | ||||||
|         ++ [ "https://${config.networking.domain}/" ]; | 
 | ||||||
|  |       my.services.blackbox.http_endpoints = lib.mapAttrsToList (_: app: app.dashboard.url) cfg.apps ++ [ | ||||||
|  |         "https://${config.networking.domain}/" | ||||||
|  |       ]; | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -10,10 +10,8 @@ let | ||||||
|   inherit (config.networking) domain; |   inherit (config.networking) domain; | ||||||
| 
 | 
 | ||||||
|   homeConfig = { |   homeConfig = { | ||||||
|     title = "Dashboard"; |  | ||||||
|     header = false; |     header = false; | ||||||
|     footer = false; |     footer = false; | ||||||
|     connectivityCheck = true; |  | ||||||
|     columns = "auto"; |     columns = "auto"; | ||||||
|     services = config.lib.webapps.homerServices; |     services = config.lib.webapps.homerServices; | ||||||
|   }; |   }; | ||||||
|  | @ -26,18 +24,11 @@ in | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   config = lib.mkIf cfg.enable { |   config = lib.mkIf cfg.enable { | ||||||
|     # TODO: 25.05 use stable |     services.homer = { | ||||||
|     services.caddy.virtualHosts.${domain} = { |       enable = true; | ||||||
|       extraConfig = '' |       virtualHost.caddy.enable = true; | ||||||
|         import common |       virtualHost.domain = domain; | ||||||
|         root * ${pkgs.unstable.homer} |       settings = homeConfig; | ||||||
|         file_server |  | ||||||
|         handle_path /assets/config.yml { |  | ||||||
|           root * ${pkgs.writeText "homerConfig.yml" (builtins.toJSON homeConfig)} |  | ||||||
|           file_server |  | ||||||
|         } |  | ||||||
|       ''; |  | ||||||
|       useACMEHost = domain; |  | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     webapps = { |     webapps = { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Felix Buehler
						Felix Buehler