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; | ||||
|           calibre.enable = true; | ||||
|           obsidian.enable = true; | ||||
|           jetbrains.idea-community.enable = true; | ||||
|           jetbrains.idea-community.enable = false; | ||||
|           vscode.enable = true; | ||||
|           firefox.enable = true; | ||||
|           steam.enable = true; | ||||
|  |  | |||
|  | @ -304,7 +304,7 @@ | |||
|       enable = true; | ||||
|       mediaDir = "/srv/qbittorent"; | ||||
|       openFirewall = true; | ||||
|       webPort = 8084; | ||||
|       webuiPort = 8084; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										62
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										62
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							|  | @ -7,11 +7,11 @@ | |||
|         ] | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1752113600, | ||||
|         "narHash": "sha256-7LYDxKxZgBQ8LZUuolAQ8UkIB+jb4A2UmiR+kzY9CLI=", | ||||
|         "lastModified": 1753140376, | ||||
|         "narHash": "sha256-7lrVrE0jSvZHrxEzvnfHFE/Wkk9DDqb+mYCodI5uuB8=", | ||||
|         "owner": "nix-community", | ||||
|         "repo": "disko", | ||||
|         "rev": "79264292b7e3482e5702932949de9cbb69fedf6d", | ||||
|         "rev": "545aba02960caa78a31bd9a8709a0ad4b6320a5c", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|  | @ -28,11 +28,11 @@ | |||
|       }, | ||||
|       "locked": { | ||||
|         "dir": "pkgs/firefox-addons", | ||||
|         "lastModified": 1752379414, | ||||
|         "narHash": "sha256-0R3slhrjrnzyxR/fAYy5UliZvSgaVS38YCESBdH5RJw=", | ||||
|         "lastModified": 1753416229, | ||||
|         "narHash": "sha256-45s1L4h/6t3M+/ppqow1OFUgfk9jZHsR4jxNgxIWWmM=", | ||||
|         "owner": "rycee", | ||||
|         "repo": "nur-expressions", | ||||
|         "rev": "51e77bb95540b7dd6c60f8fd65a0c472a2c9c3b7", | ||||
|         "rev": "553afee4efb5a7dea03cf654deafacd8fa1004f9", | ||||
|         "type": "gitlab" | ||||
|       }, | ||||
|       "original": { | ||||
|  | @ -115,11 +115,11 @@ | |||
|         ] | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1752467539, | ||||
|         "narHash": "sha256-4kaR+xmng9YPASckfvIgl5flF/1nAZOplM+Wp9I5SMI=", | ||||
|         "lastModified": 1753470191, | ||||
|         "narHash": "sha256-hOUWU5L62G9sm8NxdiLWlLIJZz9H52VuFiDllHdwmVA=", | ||||
|         "owner": "nix-community", | ||||
|         "repo": "home-manager", | ||||
|         "rev": "1e54837569e0b80797c47be4720fab19e0db1616", | ||||
|         "rev": "a1817d1c0e5eabe7dfdfe4caa46c94d9d8f3fdb6", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|  | @ -146,15 +146,15 @@ | |||
|     "lix": { | ||||
|       "flake": false, | ||||
|       "locked": { | ||||
|         "lastModified": 1746827285, | ||||
|         "narHash": "sha256-hsFe4Tsqqg4l+FfQWphDtjC79WzNCZbEFhHI8j2KJzw=", | ||||
|         "rev": "47aad376c87e2e65967f17099277428e4b3f8e5a", | ||||
|         "lastModified": 1753306924, | ||||
|         "narHash": "sha256-jLCEW0FvjFhC+c4RHzH+xbkSOxrnpFHnhjOw6sudhx0=", | ||||
|         "rev": "1a4393d0aac31aba21f5737ede1b171e11336d77", | ||||
|         "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": { | ||||
|         "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": { | ||||
|  | @ -167,15 +167,15 @@ | |||
|         ] | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1746838955, | ||||
|         "narHash": "sha256-11R4K3iAx4tLXjUs+hQ5K90JwDABD/XHhsM9nkeS5N8=", | ||||
|         "rev": "cd2a9c028df820a83ca2807dc6c6e7abc3dfa7fc", | ||||
|         "lastModified": 1753282722, | ||||
|         "narHash": "sha256-KYMUrTV7H/RR5/HRnjV5R3rRIuBXMemyJzTLi50NFTs=", | ||||
|         "rev": "46a9e8fcfe4be72b4c7c8082ee11d2c42da1e873", | ||||
|         "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": { | ||||
|         "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": { | ||||
|  | @ -227,11 +227,11 @@ | |||
|         ] | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1752459325, | ||||
|         "narHash": "sha256-46TgjdxT02a4nFd9HCXCf8kK5ZSH7r9gYROLtc8zVOg=", | ||||
|         "lastModified": 1753409666, | ||||
|         "narHash": "sha256-bFjln7BkIGOlLHeUzUxfEho2GnrIrQE6O59plpvPiYY=", | ||||
|         "owner": "nix-community", | ||||
|         "repo": "nix-vscode-extensions", | ||||
|         "rev": "61c2e99ebd586f463a6c0ebe3d931e74883b163d", | ||||
|         "rev": "38a251b6e95659b12dfb3b9fdc237d1ba2ac3786", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|  | @ -242,11 +242,11 @@ | |||
|     }, | ||||
|     "nixos-hardware": { | ||||
|       "locked": { | ||||
|         "lastModified": 1752048960, | ||||
|         "narHash": "sha256-gATnkOe37eeVwKKYCsL+OnS2gU4MmLuZFzzWCtaKLI8=", | ||||
|         "lastModified": 1753122741, | ||||
|         "narHash": "sha256-nFxE8lk9JvGelxClCmwuJYftbHqwnc01dRN4DVLUroM=", | ||||
|         "owner": "NixOS", | ||||
|         "repo": "nixos-hardware", | ||||
|         "rev": "7ced9122cff2163c6a0212b8d1ec8c33a1660806", | ||||
|         "rev": "cc66fddc6cb04ab479a1bb062f4d4da27c936a22", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|  | @ -258,11 +258,11 @@ | |||
|     }, | ||||
|     "nixpkgs": { | ||||
|       "locked": { | ||||
|         "lastModified": 1751984180, | ||||
|         "narHash": "sha256-LwWRsENAZJKUdD3SpLluwDmdXY9F45ZEgCb0X+xgOL0=", | ||||
|         "lastModified": 1753250450, | ||||
|         "narHash": "sha256-i+CQV2rPmP8wHxj0aq4siYyohHwVlsh40kV89f3nw1s=", | ||||
|         "owner": "nixos", | ||||
|         "repo": "nixpkgs", | ||||
|         "rev": "9807714d6944a957c2e036f84b0ff8caf9930bc0", | ||||
|         "rev": "fc02ee70efb805d3b2865908a13ddd4474557ecf", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|  | @ -313,11 +313,11 @@ | |||
|         ] | ||||
|       }, | ||||
|       "locked": { | ||||
|         "lastModified": 1751606940, | ||||
|         "narHash": "sha256-KrDPXobG7DFKTOteqdSVeL1bMVitDcy7otpVZWDE6MA=", | ||||
|         "lastModified": 1752544651, | ||||
|         "narHash": "sha256-GllP7cmQu7zLZTs9z0J2gIL42IZHa9CBEXwBY9szT0U=", | ||||
|         "owner": "Mic92", | ||||
|         "repo": "sops-nix", | ||||
|         "rev": "3633fc4acf03f43b260244d94c71e9e14a2f6e0d", | ||||
|         "rev": "2c8def626f54708a9c38a5861866660395bb3461", | ||||
|         "type": "github" | ||||
|       }, | ||||
|       "original": { | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ | |||
|     nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||||
| 
 | ||||
|     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"; | ||||
|     }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,115 +1,20 @@ | |||
| { | ||||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   ... | ||||
| }: let | ||||
|   qbittorent_data_directory = "/var/lib/qbittorrent"; | ||||
|   qbittorent_profile_directory = "/var/lib/qBittorrent/"; | ||||
| in { | ||||
|   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 { | ||||
|       type = lib.types.path; | ||||
|       description = lib.mdDoc '' | ||||
|         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 [ | ||||
|     { | ||||
|       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 { | ||||
|       fileSystems."/persist/system/qbittorrent".neededForBoot = true; | ||||
| 
 | ||||
|  | @ -126,7 +31,7 @@ in { | |||
| 
 | ||||
|       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"; | ||||
|         } | ||||
|       ]; | ||||
|  | @ -135,7 +40,7 @@ in { | |||
|         "/persist/system/root" = { | ||||
|           directories = [ | ||||
|             { | ||||
|               directory = qbittorent_data_directory; | ||||
|               directory = qbittorent_profile_directory; | ||||
|               user = "qbittorrent"; | ||||
|               group = "qbittorrent"; | ||||
|             } | ||||
|  |  | |||
|  | @ -160,7 +160,7 @@ in { | |||
| 
 | ||||
|           qbittorrent = { | ||||
|             uid = lib.mkForce uids.qbittorrent; | ||||
|             isNormalUser = true; | ||||
|             isSystemUser = true; | ||||
|             group = config.users.users.qbittorrent.name; | ||||
|           }; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue