forked from jan-leila/nix-config
		
	main #5
					 6 changed files with 38 additions and 133 deletions
				
			
		|  | @ -44,7 +44,7 @@ in { | ||||||
|           signal-desktop-bin.enable = true; |           signal-desktop-bin.enable = true; | ||||||
|           calibre.enable = true; |           calibre.enable = true; | ||||||
|           obsidian.enable = true; |           obsidian.enable = true; | ||||||
|           jetbrains.idea-community.enable = true; |           jetbrains.idea-community.enable = false; | ||||||
|           vscode.enable = true; |           vscode.enable = true; | ||||||
|           firefox.enable = true; |           firefox.enable = true; | ||||||
|           steam.enable = true; |           steam.enable = true; | ||||||
|  |  | ||||||
|  | @ -304,7 +304,7 @@ | ||||||
|       enable = true; |       enable = true; | ||||||
|       mediaDir = "/srv/qbittorent"; |       mediaDir = "/srv/qbittorent"; | ||||||
|       openFirewall = true; |       openFirewall = true; | ||||||
|       webPort = 8084; |       webuiPort = 8084; | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										62
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										62
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							|  | @ -7,11 +7,11 @@ | ||||||
|         ] |         ] | ||||||
|       }, |       }, | ||||||
|       "locked": { |       "locked": { | ||||||
|         "lastModified": 1752113600, |         "lastModified": 1753140376, | ||||||
|         "narHash": "sha256-7LYDxKxZgBQ8LZUuolAQ8UkIB+jb4A2UmiR+kzY9CLI=", |         "narHash": "sha256-7lrVrE0jSvZHrxEzvnfHFE/Wkk9DDqb+mYCodI5uuB8=", | ||||||
|         "owner": "nix-community", |         "owner": "nix-community", | ||||||
|         "repo": "disko", |         "repo": "disko", | ||||||
|         "rev": "79264292b7e3482e5702932949de9cbb69fedf6d", |         "rev": "545aba02960caa78a31bd9a8709a0ad4b6320a5c", | ||||||
|         "type": "github" |         "type": "github" | ||||||
|       }, |       }, | ||||||
|       "original": { |       "original": { | ||||||
|  | @ -28,11 +28,11 @@ | ||||||
|       }, |       }, | ||||||
|       "locked": { |       "locked": { | ||||||
|         "dir": "pkgs/firefox-addons", |         "dir": "pkgs/firefox-addons", | ||||||
|         "lastModified": 1752379414, |         "lastModified": 1753416229, | ||||||
|         "narHash": "sha256-0R3slhrjrnzyxR/fAYy5UliZvSgaVS38YCESBdH5RJw=", |         "narHash": "sha256-45s1L4h/6t3M+/ppqow1OFUgfk9jZHsR4jxNgxIWWmM=", | ||||||
|         "owner": "rycee", |         "owner": "rycee", | ||||||
|         "repo": "nur-expressions", |         "repo": "nur-expressions", | ||||||
|         "rev": "51e77bb95540b7dd6c60f8fd65a0c472a2c9c3b7", |         "rev": "553afee4efb5a7dea03cf654deafacd8fa1004f9", | ||||||
|         "type": "gitlab" |         "type": "gitlab" | ||||||
|       }, |       }, | ||||||
|       "original": { |       "original": { | ||||||
|  | @ -115,11 +115,11 @@ | ||||||
|         ] |         ] | ||||||
|       }, |       }, | ||||||
|       "locked": { |       "locked": { | ||||||
|         "lastModified": 1752467539, |         "lastModified": 1753470191, | ||||||
|         "narHash": "sha256-4kaR+xmng9YPASckfvIgl5flF/1nAZOplM+Wp9I5SMI=", |         "narHash": "sha256-hOUWU5L62G9sm8NxdiLWlLIJZz9H52VuFiDllHdwmVA=", | ||||||
|         "owner": "nix-community", |         "owner": "nix-community", | ||||||
|         "repo": "home-manager", |         "repo": "home-manager", | ||||||
|         "rev": "1e54837569e0b80797c47be4720fab19e0db1616", |         "rev": "a1817d1c0e5eabe7dfdfe4caa46c94d9d8f3fdb6", | ||||||
|         "type": "github" |         "type": "github" | ||||||
|       }, |       }, | ||||||
|       "original": { |       "original": { | ||||||
|  | @ -146,15 +146,15 @@ | ||||||
|     "lix": { |     "lix": { | ||||||
|       "flake": false, |       "flake": false, | ||||||
|       "locked": { |       "locked": { | ||||||
|         "lastModified": 1746827285, |         "lastModified": 1753306924, | ||||||
|         "narHash": "sha256-hsFe4Tsqqg4l+FfQWphDtjC79WzNCZbEFhHI8j2KJzw=", |         "narHash": "sha256-jLCEW0FvjFhC+c4RHzH+xbkSOxrnpFHnhjOw6sudhx0=", | ||||||
|         "rev": "47aad376c87e2e65967f17099277428e4b3f8e5a", |         "rev": "1a4393d0aac31aba21f5737ede1b171e11336d77", | ||||||
|         "type": "tarball", |         "type": "tarball", | ||||||
|         "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/47aad376c87e2e65967f17099277428e4b3f8e5a.tar.gz?rev=47aad376c87e2e65967f17099277428e4b3f8e5a" |         "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/1a4393d0aac31aba21f5737ede1b171e11336d77.tar.gz?rev=1a4393d0aac31aba21f5737ede1b171e11336d77" | ||||||
|       }, |       }, | ||||||
|       "original": { |       "original": { | ||||||
|         "type": "tarball", |         "type": "tarball", | ||||||
|         "url": "https://git.lix.systems/lix-project/lix/archive/2.93.0.tar.gz" |         "url": "https://git.lix.systems/lix-project/lix/archive/release-2.93.tar.gz" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "lix-module": { |     "lix-module": { | ||||||
|  | @ -167,15 +167,15 @@ | ||||||
|         ] |         ] | ||||||
|       }, |       }, | ||||||
|       "locked": { |       "locked": { | ||||||
|         "lastModified": 1746838955, |         "lastModified": 1753282722, | ||||||
|         "narHash": "sha256-11R4K3iAx4tLXjUs+hQ5K90JwDABD/XHhsM9nkeS5N8=", |         "narHash": "sha256-KYMUrTV7H/RR5/HRnjV5R3rRIuBXMemyJzTLi50NFTs=", | ||||||
|         "rev": "cd2a9c028df820a83ca2807dc6c6e7abc3dfa7fc", |         "rev": "46a9e8fcfe4be72b4c7c8082ee11d2c42da1e873", | ||||||
|         "type": "tarball", |         "type": "tarball", | ||||||
|         "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/cd2a9c028df820a83ca2807dc6c6e7abc3dfa7fc.tar.gz?rev=cd2a9c028df820a83ca2807dc6c6e7abc3dfa7fc" |         "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/46a9e8fcfe4be72b4c7c8082ee11d2c42da1e873.tar.gz?rev=46a9e8fcfe4be72b4c7c8082ee11d2c42da1e873" | ||||||
|       }, |       }, | ||||||
|       "original": { |       "original": { | ||||||
|         "type": "tarball", |         "type": "tarball", | ||||||
|         "url": "https://git.lix.systems/lix-project/nixos-module/archive/2.93.0.tar.gz" |         "url": "https://git.lix.systems/lix-project/nixos-module/archive/2.93.3-1.tar.gz" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "nix-darwin": { |     "nix-darwin": { | ||||||
|  | @ -227,11 +227,11 @@ | ||||||
|         ] |         ] | ||||||
|       }, |       }, | ||||||
|       "locked": { |       "locked": { | ||||||
|         "lastModified": 1752459325, |         "lastModified": 1753409666, | ||||||
|         "narHash": "sha256-46TgjdxT02a4nFd9HCXCf8kK5ZSH7r9gYROLtc8zVOg=", |         "narHash": "sha256-bFjln7BkIGOlLHeUzUxfEho2GnrIrQE6O59plpvPiYY=", | ||||||
|         "owner": "nix-community", |         "owner": "nix-community", | ||||||
|         "repo": "nix-vscode-extensions", |         "repo": "nix-vscode-extensions", | ||||||
|         "rev": "61c2e99ebd586f463a6c0ebe3d931e74883b163d", |         "rev": "38a251b6e95659b12dfb3b9fdc237d1ba2ac3786", | ||||||
|         "type": "github" |         "type": "github" | ||||||
|       }, |       }, | ||||||
|       "original": { |       "original": { | ||||||
|  | @ -242,11 +242,11 @@ | ||||||
|     }, |     }, | ||||||
|     "nixos-hardware": { |     "nixos-hardware": { | ||||||
|       "locked": { |       "locked": { | ||||||
|         "lastModified": 1752048960, |         "lastModified": 1753122741, | ||||||
|         "narHash": "sha256-gATnkOe37eeVwKKYCsL+OnS2gU4MmLuZFzzWCtaKLI8=", |         "narHash": "sha256-nFxE8lk9JvGelxClCmwuJYftbHqwnc01dRN4DVLUroM=", | ||||||
|         "owner": "NixOS", |         "owner": "NixOS", | ||||||
|         "repo": "nixos-hardware", |         "repo": "nixos-hardware", | ||||||
|         "rev": "7ced9122cff2163c6a0212b8d1ec8c33a1660806", |         "rev": "cc66fddc6cb04ab479a1bb062f4d4da27c936a22", | ||||||
|         "type": "github" |         "type": "github" | ||||||
|       }, |       }, | ||||||
|       "original": { |       "original": { | ||||||
|  | @ -258,11 +258,11 @@ | ||||||
|     }, |     }, | ||||||
|     "nixpkgs": { |     "nixpkgs": { | ||||||
|       "locked": { |       "locked": { | ||||||
|         "lastModified": 1751984180, |         "lastModified": 1753250450, | ||||||
|         "narHash": "sha256-LwWRsENAZJKUdD3SpLluwDmdXY9F45ZEgCb0X+xgOL0=", |         "narHash": "sha256-i+CQV2rPmP8wHxj0aq4siYyohHwVlsh40kV89f3nw1s=", | ||||||
|         "owner": "nixos", |         "owner": "nixos", | ||||||
|         "repo": "nixpkgs", |         "repo": "nixpkgs", | ||||||
|         "rev": "9807714d6944a957c2e036f84b0ff8caf9930bc0", |         "rev": "fc02ee70efb805d3b2865908a13ddd4474557ecf", | ||||||
|         "type": "github" |         "type": "github" | ||||||
|       }, |       }, | ||||||
|       "original": { |       "original": { | ||||||
|  | @ -313,11 +313,11 @@ | ||||||
|         ] |         ] | ||||||
|       }, |       }, | ||||||
|       "locked": { |       "locked": { | ||||||
|         "lastModified": 1751606940, |         "lastModified": 1752544651, | ||||||
|         "narHash": "sha256-KrDPXobG7DFKTOteqdSVeL1bMVitDcy7otpVZWDE6MA=", |         "narHash": "sha256-GllP7cmQu7zLZTs9z0J2gIL42IZHa9CBEXwBY9szT0U=", | ||||||
|         "owner": "Mic92", |         "owner": "Mic92", | ||||||
|         "repo": "sops-nix", |         "repo": "sops-nix", | ||||||
|         "rev": "3633fc4acf03f43b260244d94c71e9e14a2f6e0d", |         "rev": "2c8def626f54708a9c38a5861866660395bb3461", | ||||||
|         "type": "github" |         "type": "github" | ||||||
|       }, |       }, | ||||||
|       "original": { |       "original": { | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ | ||||||
|     nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; |     nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||||||
| 
 | 
 | ||||||
|     lix-module = { |     lix-module = { | ||||||
|       url = "https://git.lix.systems/lix-project/nixos-module/archive/2.93.0.tar.gz"; |       url = "https://git.lix.systems/lix-project/nixos-module/archive/2.93.3-1.tar.gz"; | ||||||
|       inputs.nixpkgs.follows = "nixpkgs"; |       inputs.nixpkgs.follows = "nixpkgs"; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,115 +1,20 @@ | ||||||
| { | { | ||||||
|   lib, |   lib, | ||||||
|   pkgs, |  | ||||||
|   config, |   config, | ||||||
|   ... |   ... | ||||||
| }: let | }: let | ||||||
|   qbittorent_data_directory = "/var/lib/qbittorrent"; |   qbittorent_profile_directory = "/var/lib/qBittorrent/"; | ||||||
| in { | in { | ||||||
|   options.services.qbittorrent = { |   options.services.qbittorrent = { | ||||||
|     enable = lib.mkEnableOption "should the headless qbittorrent service be enabled"; |  | ||||||
| 
 |  | ||||||
|     dataDir = lib.mkOption { |  | ||||||
|       type = lib.types.path; |  | ||||||
|       default = "/var/lib/qbittorrent"; |  | ||||||
|       description = lib.mdDoc '' |  | ||||||
|         The directory where qBittorrent stores its data files. |  | ||||||
|       ''; |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     mediaDir = lib.mkOption { |     mediaDir = lib.mkOption { | ||||||
|       type = lib.types.path; |       type = lib.types.path; | ||||||
|       description = lib.mdDoc '' |       description = lib.mdDoc '' | ||||||
|         The directory to create to store qbittorrent media. |         The directory to create to store qbittorrent media. | ||||||
|       ''; |       ''; | ||||||
|     }; |     }; | ||||||
| 
 |  | ||||||
|     user = lib.mkOption { |  | ||||||
|       type = lib.types.str; |  | ||||||
|       default = "qbittorrent"; |  | ||||||
|       description = lib.mdDoc '' |  | ||||||
|         User account under which qBittorrent runs. |  | ||||||
|       ''; |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     group = lib.mkOption { |  | ||||||
|       type = lib.types.str; |  | ||||||
|       default = "qbittorrent"; |  | ||||||
|       description = lib.mdDoc '' |  | ||||||
|         Group under which qBittorrent runs. |  | ||||||
|       ''; |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     webPort = lib.mkOption { |  | ||||||
|       type = lib.types.port; |  | ||||||
|       default = 8080; |  | ||||||
|       description = lib.mdDoc '' |  | ||||||
|         qBittorrent web UI port. |  | ||||||
|       ''; |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     openFirewall = lib.mkOption { |  | ||||||
|       type = lib.types.bool; |  | ||||||
|       default = false; |  | ||||||
|       description = "Open services.qBittorrent.webPort to the outside network."; |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     package = lib.mkOption { |  | ||||||
|       type = lib.types.package; |  | ||||||
|       default = pkgs.qbittorrent-nox; |  | ||||||
|       defaultText = lib.literalExpression "pkgs.qbittorrent-nox"; |  | ||||||
|       description = "The qbittorrent package to use."; |  | ||||||
|     }; |  | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   config = lib.mkIf config.services.qbittorrent.enable (lib.mkMerge [ |   config = lib.mkIf config.services.qbittorrent.enable (lib.mkMerge [ | ||||||
|     { |  | ||||||
|       networking.firewall = lib.mkIf config.services.qbittorrent.openFirewall { |  | ||||||
|         allowedTCPPorts = [config.services.qbittorrent.webPort]; |  | ||||||
|       }; |  | ||||||
| 
 |  | ||||||
|       systemd.services.qbittorrent = { |  | ||||||
|         # based on the plex.nix service module and |  | ||||||
|         # https://github.com/qbittorrent/qBittorrent/blob/master/dist/unix/systemd/qbittorrent-nox%40.service.in |  | ||||||
|         description = "qBittorrent-nox service"; |  | ||||||
|         documentation = ["man:qbittorrent-nox(1)"]; |  | ||||||
|         after = ["network.target"]; |  | ||||||
|         wantedBy = ["multi-user.target"]; |  | ||||||
| 
 |  | ||||||
|         serviceConfig = { |  | ||||||
|           Type = "simple"; |  | ||||||
|           User = config.services.qbittorrent.user; |  | ||||||
|           Group = config.services.qbittorrent.group; |  | ||||||
| 
 |  | ||||||
|           # Run the pre-start script with full permissions (the "!" prefix) so it |  | ||||||
|           # can create the data directory if necessary. |  | ||||||
|           ExecStartPre = let |  | ||||||
|             preStartScript = pkgs.writeScript "qbittorrent-run-prestart" '' |  | ||||||
|               #!${pkgs.bash}/bin/bash |  | ||||||
| 
 |  | ||||||
|               # Create data directory if it doesn't exist |  | ||||||
|               if ! test -d "$QBT_PROFILE"; then |  | ||||||
|                 echo "Creating initial qBittorrent data directory in: $QBT_PROFILE" |  | ||||||
|                 install -d -m 0755 -o "${config.services.qbittorrent.user}" -g "${config.services.qbittorrent.group}" "$QBT_PROFILE" |  | ||||||
|               fi |  | ||||||
|             ''; |  | ||||||
|           in "!${preStartScript}"; |  | ||||||
| 
 |  | ||||||
|           #ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox"; |  | ||||||
|           ExecStart = "${config.services.qbittorrent.package}/bin/qbittorrent-nox"; |  | ||||||
|           # To prevent "Quit & shutdown daemon" from working; we want systemd to |  | ||||||
|           # manage it! |  | ||||||
|           #Restart = "on-success"; |  | ||||||
|           #UMask = "0002"; |  | ||||||
|           #LimitNOFILE = cfg.openFilesLimit; |  | ||||||
|         }; |  | ||||||
| 
 |  | ||||||
|         environment = { |  | ||||||
|           QBT_PROFILE = config.services.qbittorrent.dataDir; |  | ||||||
|           QBT_WEBUI_PORT = toString config.services.qbittorrent.webPort; |  | ||||||
|         }; |  | ||||||
|       }; |  | ||||||
|     } |  | ||||||
|     (lib.mkIf config.host.impermanence.enable { |     (lib.mkIf config.host.impermanence.enable { | ||||||
|       fileSystems."/persist/system/qbittorrent".neededForBoot = true; |       fileSystems."/persist/system/qbittorrent".neededForBoot = true; | ||||||
| 
 | 
 | ||||||
|  | @ -126,7 +31,7 @@ in { | ||||||
| 
 | 
 | ||||||
|       assertions = [ |       assertions = [ | ||||||
|         { |         { | ||||||
|           assertion = config.services.qbittorrent.dataDir == qbittorent_data_directory; |           assertion = config.services.qbittorrent.profileDir == qbittorent_profile_directory; | ||||||
|           message = "qbittorrent data directory does not match persistence"; |           message = "qbittorrent data directory does not match persistence"; | ||||||
|         } |         } | ||||||
|       ]; |       ]; | ||||||
|  | @ -135,7 +40,7 @@ in { | ||||||
|         "/persist/system/root" = { |         "/persist/system/root" = { | ||||||
|           directories = [ |           directories = [ | ||||||
|             { |             { | ||||||
|               directory = qbittorent_data_directory; |               directory = qbittorent_profile_directory; | ||||||
|               user = "qbittorrent"; |               user = "qbittorrent"; | ||||||
|               group = "qbittorrent"; |               group = "qbittorrent"; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  | @ -160,7 +160,7 @@ in { | ||||||
| 
 | 
 | ||||||
|           qbittorrent = { |           qbittorrent = { | ||||||
|             uid = lib.mkForce uids.qbittorrent; |             uid = lib.mkForce uids.qbittorrent; | ||||||
|             isNormalUser = true; |             isSystemUser = true; | ||||||
|             group = config.users.users.qbittorrent.name; |             group = config.users.users.qbittorrent.name; | ||||||
|           }; |           }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue