forked from jan-leila/nix-config
		
	
		
			
				
	
	
		
			65 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
| {
 | |
|   lib,
 | |
|   config,
 | |
|   ...
 | |
| }: let
 | |
|   qbittorent_profile_directory = "/var/lib/qBittorrent/";
 | |
| in {
 | |
|   options.services.qbittorrent = {
 | |
|     mediaDir = lib.mkOption {
 | |
|       type = lib.types.path;
 | |
|       description = lib.mdDoc ''
 | |
|         The directory to create to store qbittorrent media.
 | |
|       '';
 | |
|     };
 | |
|   };
 | |
| 
 | |
|   config = lib.mkIf config.services.qbittorrent.enable (lib.mkMerge [
 | |
|     (lib.mkIf config.host.impermanence.enable {
 | |
|       fileSystems."/persist/system/qbittorrent".neededForBoot = true;
 | |
| 
 | |
|       host.storage.pool.extraDatasets = {
 | |
|         # sops age key needs to be available to pre persist for user generation
 | |
|         "persist/system/qbittorrent" = {
 | |
|           type = "zfs_fs";
 | |
|           mountpoint = "/persist/system/qbittorrent";
 | |
|           options = {
 | |
|             canmount = "on";
 | |
|           };
 | |
|         };
 | |
|       };
 | |
| 
 | |
|       assertions = [
 | |
|         {
 | |
|           assertion = config.services.qbittorrent.profileDir == qbittorent_profile_directory;
 | |
|           message = "qbittorrent data directory does not match persistence";
 | |
|         }
 | |
|       ];
 | |
| 
 | |
|       environment.persistence = {
 | |
|         "/persist/system/root" = {
 | |
|           directories = [
 | |
|             {
 | |
|               directory = qbittorent_profile_directory;
 | |
|               user = "qbittorrent";
 | |
|               group = "qbittorrent";
 | |
|             }
 | |
|           ];
 | |
|         };
 | |
| 
 | |
|         "/persist/system/qbittorrent" = {
 | |
|           enable = true;
 | |
|           hideMounts = true;
 | |
|           directories = [
 | |
|             {
 | |
|               directory = config.services.qbittorrent.mediaDir;
 | |
|               user = "qbittorrent";
 | |
|               group = "qbittorrent";
 | |
|               mode = "1775";
 | |
|             }
 | |
|           ];
 | |
|         };
 | |
|       };
 | |
|     })
 | |
|   ]);
 | |
| }
 |