Cleaned mkEnableOption mess

This commit is contained in:
rasmus-kirk
2024-02-26 17:57:01 +01:00
parent b49cae6b20
commit 0c61369307
9 changed files with 150 additions and 88 deletions
+4 -2
View File
@@ -24,9 +24,11 @@ in
buildInputs = with pkgs; [pandoc]; buildInputs = with pkgs; [pandoc];
phases = ["unpackPhase" "buildPhase"]; phases = ["unpackPhase" "buildPhase"];
buildPhase = '' buildPhase = ''
tmpdir=$(mktemp -d) #tmpdir=$(mktemp -d)
tmpdir="$out/debug"
mkdir -p $out mkdir -p $out
cp -r docs/pandoc/style.css docs $out mkdir -p $tmpdir
cp -r docs $out
# Generate md docs # Generate md docs
cat ${optionsDocNixos.optionsCommonMark} | tail -n +58 >> "$tmpdir"/nixos.md cat ${optionsDocNixos.optionsCommonMark} | tail -n +58 >> "$tmpdir"/nixos.md
+43 -20
View File
@@ -18,25 +18,39 @@ in {
]; ];
options.nixarr = { options.nixarr = {
enable = mkEnableOption '' enable = mkOption {
Primarily, lets you host the "*Arrs" services optionally through a VPN. type = types.bool;
default = false;
description = ''
Whether or not to enable the nixarr module. Has the following features:
It is possible, _but not recommended_, to have - **Run services through a VPN:** You can run any service that this module
prowlarr/sonarr/radarr/readarr/lidarr behind a VPN, because it can cause supports through a VPN, fx `nixarr.transmission.vpn.enable = true;`
rate limiting issues. Generally, you should use VPN on transmission - **Automatic Directories, Users and Permissions:** The module automatically
and maybe jellyfin, depending on your setup. Also sets permissions creates directories and users for your media library. It also sets sane
and creates directories. permissions.
- **State Management:** All services support state management and all state
that they manage is located by default in `/data/.state/nixarr/*`
- **Optional Automatic Port Forwarding:** This module has a UPNP module that
lets services request ports from your router automatically, if you enable it.
- Jellyfin It is possible, _but not recommended_, to run the "*Arrs" behind a VPN,
- Lidarr because it can cause rate limiting issues. Generally, you should use
- Prowlarr VPN on transmission and maybe jellyfin, depending on your setup.
- Radarr
- Readarr
- Sonarr
- Transmission
Remember to read the options. The following services are supported:
'';
- Jellyfin
- Lidarr
- Prowlarr
- Radarr
- Readarr
- Sonarr
- Transmission
Remember to read the options.
'';
};
mediaDir = mkOption { mediaDir = mkOption {
type = types.path; type = types.path;
@@ -55,12 +69,21 @@ in {
}; };
vpn = { vpn = {
enable = mkEnableOption "Enable vpn"; enable = mkOption {
type = types.bool;
default = false;
description = ''
**Required options:** [`nixarr.vpn.wgConf`](/options.html#nixarr.vpn.wgConf)
Whether or not to enable VPN support for the services that nixarr
supports.
'';
};
wgConf = mkOption { wgConf = mkOption {
type = types.nullOr types.path; type = types.nullOr types.path;
default = null; default = null;
description = "REQUIRED! The path to the wireguard configuration file."; description = "The path to the wireguard configuration file.";
}; };
dnsServers = mkOption { dnsServers = mkOption {
@@ -75,8 +98,8 @@ in {
vpnTestService = { vpnTestService = {
enable = mkEnableOption '' enable = mkEnableOption ''
Enable the vpn test service. Useful for testing DNS leaks or VPN the vpn test service. Useful for testing DNS leaks or if the VPN
port forwarding. port forwarding works correctly.
''; '';
port = mkOption { port = mkOption {
+38 -29
View File
@@ -10,7 +10,7 @@ with lib; let
dnsServers = config.lib.vpn.dnsServers; dnsServers = config.lib.vpn.dnsServers;
in { in {
options.nixarr.jellyfin = { options.nixarr.jellyfin = {
enable = mkEnableOption "Enable the Jellyfin service."; enable = mkEnableOption "the Jellyfin service.";
stateDir = mkOption { stateDir = mkOption {
type = types.path; type = types.path;
@@ -18,27 +18,35 @@ in {
description = "The state directory for Jellyfin."; description = "The state directory for Jellyfin.";
}; };
vpn.enable = mkEnableOption '' vpn.enable = mkOption {
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable) type = types.bool;
default = false;
description = ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
Route Jellyfin traffic through the VPN. Route Jellyfin traffic through the VPN.
''; '';
};
expose = { expose = {
vpn = { vpn = {
enable = mkEnableOption '' enable = mkOption {
**Required options:** type = types.bool;
default = false;
description = ''
**Required options:**
- [`nixarr.jellyfin.vpn.enable`](/options.html#nixarr.jellyfin.vpn.enable) - [`nixarr.jellyfin.vpn.enable`](/options.html#nixarr.jellyfin.vpn.enable)
- [`nixarr.jellyfin.expose.vpn.port`](/options.html#nixarr.jellyfin.expose.vpn.port) - [`nixarr.jellyfin.expose.vpn.port`](/options.html#nixarr.jellyfin.expose.vpn.port)
- [`nixarr.jellyfin.expose.vpn.accessibleFrom`](/options.html#nixarr.jellyfin.expose.vpn.accessibleFrom) - [`nixarr.jellyfin.expose.vpn.accessibleFrom`](/options.html#nixarr.jellyfin.expose.vpn.accessibleFrom)
Expose the Jellyfin web service to the internet, allowing anyone to Expose the Jellyfin web service to the internet, allowing anyone to
access it. access it.
**Important:** Do _not_ enable this without setting up Jellyfin **Important:** Do _not_ enable this without setting up Jellyfin
authentication through localhost first! authentication through localhost first!
''; '';
};
port = mkOption { port = mkOption {
type = with types; nullOr port; type = with types; nullOr port;
@@ -60,25 +68,26 @@ in {
}; };
https = { https = {
enable = mkEnableOption '' enable = mkOption {
**Required options:** type = types.bool;
default = false;
description = ''
**Required options:**
- [`nixarr.jellyfin.expose.https.acmeMail`](/options.html#nixarr.jellyfin.expose.https.acmeMail) - [`nixarr.jellyfin.expose.https.acmeMail`](/options.html#nixarr.jellyfin.expose.https.acmeMail)
- [`nixarr.jellyfin.expose.https.domainName`](/options.html#nixarr.jellyfin.expose.https.domainName) - [`nixarr.jellyfin.expose.https.domainName`](/options.html#nixarr.jellyfin.expose.https.domainName)
**Conflicting options:** [`nixarr.jellyfin.vpn.enable`](/options.html#nixarr.jellyfin.vpn.enable) **Conflicting options:** [`nixarr.jellyfin.vpn.enable`](/options.html#nixarr.jellyfin.vpn.enable)
Expose the Jellyfin web service to the internet with https support, Expose the Jellyfin web service to the internet with https support,
allowing anyone to access it. allowing anyone to access it.
**Important:** Do _not_ enable this without setting up Jellyfin **Important:** Do _not_ enable this without setting up Jellyfin
authentication through localhost first! authentication through localhost first!
''; '';
};
upnp.enable = mkEnableOption "UPNP to try to open ports 80 and 443 on your router.";
upnp.enable = mkEnableOption ''
Use UPNP to try to open ports 80 and 443 on your router.
'';
domainName = mkOption { domainName = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
+9 -5
View File
@@ -9,7 +9,7 @@ with lib; let
nixarr = config.nixarr; nixarr = config.nixarr;
in { in {
options.nixarr.lidarr = { options.nixarr.lidarr = {
enable = mkEnableOption "Enable the Lidarr service."; enable = mkEnableOption "the Lidarr service.";
stateDir = mkOption { stateDir = mkOption {
type = types.path; type = types.path;
@@ -17,11 +17,15 @@ in {
description = "The state directory for Lidarr"; description = "The state directory for Lidarr";
}; };
vpn.enable = mkEnableOption '' vpn.enable = mkOption {
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable) type = types.bool;
default = false;
description = ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
Route Lidarr traffic through the VPN. Route Lidarr traffic through the VPN.
''; '';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
+9 -5
View File
@@ -15,7 +15,7 @@ in {
]; ];
options.nixarr.prowlarr = { options.nixarr.prowlarr = {
enable = mkEnableOption "Enable the Prowlarr service."; enable = mkEnableOption "the Prowlarr service.";
stateDir = mkOption { stateDir = mkOption {
type = types.path; type = types.path;
@@ -23,11 +23,15 @@ in {
description = "The state directory for Prowlarr."; description = "The state directory for Prowlarr.";
}; };
vpn.enable = mkEnableOption '' vpn.enable = mkOption {
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable) type = types.bool;
default = false;
description = ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
Route Prowlarr traffic through the VPN. Route Prowlarr traffic through the VPN.
''; '';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
+8 -4
View File
@@ -19,11 +19,15 @@ in {
description = "The state directory for radarr."; description = "The state directory for radarr.";
}; };
vpn.enable = mkEnableOption '' vpn.enable = mkOption {
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable) type = types.bool;
default = false;
description = ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
Route Radarr traffic through the VPN. Route Radarr traffic through the VPN.
''; '';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
+8 -4
View File
@@ -17,11 +17,15 @@ in {
description = "The state directory for Readarr"; description = "The state directory for Readarr";
}; };
vpn.enable = mkEnableOption '' vpn.enable = mkOption {
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable) type = types.bool;
default = false;
description = ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
Route Readarr traffic through the VPN. Route Readarr traffic through the VPN.
''; '';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
+8 -4
View File
@@ -23,11 +23,15 @@ in {
description = "The state directory for Sonarr."; description = "The state directory for Sonarr.";
}; };
vpn.enable = mkEnableOption '' vpn.enable = mkOption {
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable) type = types.bool;
default = false;
description = ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
Route Sonarr traffic through the VPN. Route Sonarr traffic through the VPN.
''; '';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
+23 -15
View File
@@ -11,7 +11,7 @@ with lib; let
dnsServers = config.lib.vpn.dnsServers; dnsServers = config.lib.vpn.dnsServers;
in { in {
options.nixarr.transmission = { options.nixarr.transmission = {
enable = mkEnableOption "Enable the Transmission service."; enable = mkEnableOption "the Transmission service.";
stateDir = mkOption { stateDir = mkOption {
type = types.path; type = types.path;
@@ -29,23 +29,31 @@ in {
''; '';
}; };
vpn.enable = mkEnableOption '' vpn.enable = mkOption {
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable) type = types.bool;
default = false;
description = ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
**Recommended:** Route Transmission traffic through the VPN. **Recommended:** Route Transmission traffic through the VPN.
''; '';
};
flood.enable = mkEnableOption "Use the flood web-UI"; flood.enable = mkEnableOption "the flood web-UI for the transmission web-UI.";
privateTrackers = mkEnableOption '' privateTrackers = mkOption {
Disable pex and dht, which is required for some private trackers. type = types.bool;
default = false;
description = ''
Disable pex and dht, which is required for some private trackers.
You don't want to enable this unless a private tracker requires you You don't want to enable this unless a private tracker requires you
to, and some don't. All torrents from private trackers are set as to, and some don't. All torrents from private trackers are set as
"private", and this automatically disables dht and pex for that torrent, "private", and this automatically disables dht and pex for that torrent,
so it shouldn't even be a necessary rule to have, but I don't make so it shouldn't even be a necessary rule to have, but I don't make
their rules ¯\_()_/¯. their rules ¯\_()_/¯.
''; '';
};
messageLevel = mkOption { messageLevel = mkOption {
type = types.enum [ type = types.enum [
@@ -58,7 +66,7 @@ in {
"trace" "trace"
]; ];
default = "warn"; default = "warn";
description = "Sets the message level of transmission"; description = "Sets the message level of transmission.";
}; };
peerPort = mkOption { peerPort = mkOption {