forked from jan-leila/nix-config
		
	added acme to impermanence
This commit is contained in:
		
							parent
							
								
									b02bd1a5e2
								
							
						
					
					
						commit
						6ab64fafe1
					
				
					 2 changed files with 44 additions and 26 deletions
				
			
		|  | @ -135,11 +135,6 @@ in { | ||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     security.acme = { |  | ||||||
|       acceptTerms = true; |  | ||||||
|       defaults.email = "jan-leila@protonmail.com"; |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     networking.firewall.allowedTCPPorts = |     networking.firewall.allowedTCPPorts = | ||||||
|       [ |       [ | ||||||
|         httpPort |         httpPort | ||||||
|  |  | ||||||
|  | @ -2,7 +2,9 @@ | ||||||
|   lib, |   lib, | ||||||
|   config, |   config, | ||||||
|   ... |   ... | ||||||
| }: { | }: let | ||||||
|  |   dataDir = "/var/lib/acme"; | ||||||
|  | in { | ||||||
|   options.host.reverse_proxy = { |   options.host.reverse_proxy = { | ||||||
|     enable = lib.mkEnableOption "turn on the reverse proxy"; |     enable = lib.mkEnableOption "turn on the reverse proxy"; | ||||||
|     hostname = lib.mkOption { |     hostname = lib.mkOption { | ||||||
|  | @ -32,15 +34,15 @@ | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   # TODO: impermanence for ACME keys |   config = lib.mkIf config.host.reverse_proxy.enable (lib.mkMerge [ | ||||||
|   config = { |     { | ||||||
|       security.acme = lib.mkIf config.host.reverse_proxy.enableACME { |       security.acme = lib.mkIf config.host.reverse_proxy.enableACME { | ||||||
|         acceptTerms = true; |         acceptTerms = true; | ||||||
|         defaults.email = "jan-leila@protonmail.com"; |         defaults.email = "jan-leila@protonmail.com"; | ||||||
|       }; |       }; | ||||||
| 
 | 
 | ||||||
|       services.nginx = { |       services.nginx = { | ||||||
|       enable = config.host.reverse_proxy.enable; |         enable = true; | ||||||
|         virtualHosts = lib.attrsets.mapAttrs' (name: value: |         virtualHosts = lib.attrsets.mapAttrs' (name: value: | ||||||
|           lib.attrsets.nameValuePair "${name}.${config.host.reverse_proxy.hostname}" { |           lib.attrsets.nameValuePair "${name}.${config.host.reverse_proxy.hostname}" { | ||||||
|             forceSSL = config.host.reverse_proxy.forceSSL; |             forceSSL = config.host.reverse_proxy.forceSSL; | ||||||
|  | @ -52,5 +54,26 @@ | ||||||
|           }) |           }) | ||||||
|         config.host.reverse_proxy.subdomains; |         config.host.reverse_proxy.subdomains; | ||||||
|       }; |       }; | ||||||
|   }; |     } | ||||||
|  |     (lib.mkIf config.host.impermanence.enable { | ||||||
|  |       # TODO: figure out how to write an assertion for this | ||||||
|  |       # assertions = [ | ||||||
|  |       #   { | ||||||
|  |       #     assertion = security.acme.certs.<name>.directory == dataDir; | ||||||
|  |       #     message = "postgres data directory does not match persistence"; | ||||||
|  |       #   } | ||||||
|  |       # ]; | ||||||
|  |       environment.persistence."/persist/system/root" = { | ||||||
|  |         enable = true; | ||||||
|  |         hideMounts = true; | ||||||
|  |         directories = [ | ||||||
|  |           { | ||||||
|  |             directory = dataDir; | ||||||
|  |             user = "acme"; | ||||||
|  |             group = "acme"; | ||||||
|  |           } | ||||||
|  |         ]; | ||||||
|  |       }; | ||||||
|  |     }) | ||||||
|  |   ]); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue