63 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
| { config, lib, ... }:
 | |
| 
 | |
| with lib;
 | |
| 
 | |
| let
 | |
|   cfg = homelab.services.paperless;
 | |
|   homelab = config.homelab;
 | |
|   service = "paperless";
 | |
| in
 | |
| {
 | |
|   options.homelab.services.${service} = {
 | |
|     enable = mkEnableOption "Enable ${service}";
 | |
| 
 | |
|     url = mkOption {
 | |
|       default = "${service}.${homelab.domain}";
 | |
|       type = types.str;
 | |
|     };
 | |
| 
 | |
|     homepage.name = mkOption {
 | |
|       default = "Paperless-ngx";
 | |
|       type = types.str;
 | |
|     };
 | |
| 
 | |
|     homepage.description = mkOption {
 | |
|       default = "Document management system";
 | |
|       type = types.str;
 | |
|     };
 | |
| 
 | |
|     homepage.icon = mkOption {
 | |
|       default = "paperless";
 | |
|       type = types.str;
 | |
|     };
 | |
| 
 | |
|     homepage.category = mkOption {
 | |
|       default = "Services";
 | |
|       type = types.str;
 | |
|     };
 | |
|   };
 | |
| 
 | |
|   config = mkIf cfg.enable {
 | |
|     services = {
 | |
|       ${service} = {
 | |
|         enable = true;
 | |
| 
 | |
|         dataDir = "/mnt/media/${service}";
 | |
| 
 | |
|         settings = {
 | |
|           PAPERLESS_URL = "https://${cfg.url}";
 | |
|         };
 | |
|       };
 | |
| 
 | |
|       nginx.virtualHosts."${cfg.url}" = {
 | |
|         forceSSL = true;
 | |
|         useACMEHost = homelab.domain;
 | |
| 
 | |
|         locations."/" = {
 | |
|           proxyPass = "http://localhost:${toString config.services.${service}.port}";
 | |
|           recommendedProxySettings = true;
 | |
|         };
 | |
|       };
 | |
|     };
 | |
|   };
 | |
| }
 |