Skip to content

Commit

Permalink
Cleaned mkEnableOption mess
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus-kirk committed Feb 26, 2024
1 parent b49cae6 commit 0c61369
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 93 deletions.
6 changes: 4 additions & 2 deletions mkDocs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ in
buildInputs = with pkgs; [pandoc];
phases = ["unpackPhase" "buildPhase"];
buildPhase = ''
tmpdir=$(mktemp -d)
#tmpdir=$(mktemp -d)
tmpdir="$out/debug"
mkdir -p $out
cp -r docs/pandoc/style.css docs $out
mkdir -p $tmpdir
cp -r docs $out
# Generate md docs
cat ${optionsDocNixos.optionsCommonMark} | tail -n +58 >> "$tmpdir"/nixos.md
Expand Down
69 changes: 46 additions & 23 deletions nixarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,39 @@ in {
];

options.nixarr = {
enable = mkEnableOption ''
Primarily, lets you host the "*Arrs" services optionally through a VPN.
It is possible, _but not recommended_, to have
prowlarr/sonarr/radarr/readarr/lidarr behind a VPN, because it can cause
rate limiting issues. Generally, you should use VPN on transmission
and maybe jellyfin, depending on your setup. Also sets permissions
and creates directories.
- Jellyfin
- Lidarr
- Prowlarr
- Radarr
- Readarr
- Sonarr
- Transmission
Remember to read the options.
'';
enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether or not to enable the nixarr module. Has the following features:
- **Run services through a VPN:** You can run any service that this module
supports through a VPN, fx `nixarr.transmission.vpn.enable = true;`
- **Automatic Directories, Users and Permissions:** The module automatically
creates directories and users for your media library. It also sets sane
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.
It is possible, _but not recommended_, to run the "*Arrs" behind a VPN,
because it can cause rate limiting issues. Generally, you should use
VPN on transmission and maybe jellyfin, depending on your setup.
The following services are supported:
- Jellyfin
- Lidarr
- Prowlarr
- Radarr
- Readarr
- Sonarr
- Transmission
Remember to read the options.
'';
};

mediaDir = mkOption {
type = types.path;
Expand All @@ -55,12 +69,21 @@ in {
};

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 {
type = types.nullOr types.path;
default = null;
description = "REQUIRED! The path to the wireguard configuration file.";
description = "The path to the wireguard configuration file.";
};

dnsServers = mkOption {
Expand All @@ -75,8 +98,8 @@ in {

vpnTestService = {
enable = mkEnableOption ''
Enable the vpn test service. Useful for testing DNS leaks or VPN
port forwarding.
the vpn test service. Useful for testing DNS leaks or if the VPN
port forwarding works correctly.
'';

port = mkOption {
Expand Down
67 changes: 38 additions & 29 deletions nixarr/jellyfin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,43 @@ with lib; let
dnsServers = config.lib.vpn.dnsServers;
in {
options.nixarr.jellyfin = {
enable = mkEnableOption "Enable the Jellyfin service.";
enable = mkEnableOption "the Jellyfin service.";

stateDir = mkOption {
type = types.path;
default = "${nixarr.stateDir}/nixarr/jellyfin";
description = "The state directory for Jellyfin.";
};

vpn.enable = mkEnableOption ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
vpn.enable = mkOption {
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 = {
vpn = {
enable = mkEnableOption ''
**Required options:**
enable = mkOption {
type = types.bool;
default = false;
description = ''
**Required options:**
- [`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.accessibleFrom`](/options.html#nixarr.jellyfin.expose.vpn.accessibleFrom)
- [`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.accessibleFrom`](/options.html#nixarr.jellyfin.expose.vpn.accessibleFrom)
Expose the Jellyfin web service to the internet, allowing anyone to
access it.
Expose the Jellyfin web service to the internet, allowing anyone to
access it.
**Important:** Do _not_ enable this without setting up Jellyfin
authentication through localhost first!
'';
**Important:** Do _not_ enable this without setting up Jellyfin
authentication through localhost first!
'';
};

port = mkOption {
type = with types; nullOr port;
Expand All @@ -60,25 +68,26 @@ in {
};

https = {
enable = mkEnableOption ''
**Required options:**
enable = mkOption {
type = types.bool;
default = false;
description = ''
**Required options:**
- [`nixarr.jellyfin.expose.https.acmeMail`](/options.html#nixarr.jellyfin.expose.https.acmeMail)
- [`nixarr.jellyfin.expose.https.domainName`](/options.html#nixarr.jellyfin.expose.https.domainName)
**Conflicting options:** [`nixarr.jellyfin.vpn.enable`](/options.html#nixarr.jellyfin.vpn.enable)
- [`nixarr.jellyfin.expose.https.acmeMail`](/options.html#nixarr.jellyfin.expose.https.acmeMail)
- [`nixarr.jellyfin.expose.https.domainName`](/options.html#nixarr.jellyfin.expose.https.domainName)
Expose the Jellyfin web service to the internet with https support,
allowing anyone to access it.
**Conflicting options:** [`nixarr.jellyfin.vpn.enable`](/options.html#nixarr.jellyfin.vpn.enable)
**Important:** Do _not_ enable this without setting up Jellyfin
authentication through localhost first!
'';
Expose the Jellyfin web service to the internet with https support,
allowing anyone to access it.
**Important:** Do _not_ enable this without setting up Jellyfin
authentication through localhost first!
'';
};

upnp.enable = mkEnableOption ''
Use UPNP to try to open ports 80 and 443 on your router.
'';
upnp.enable = mkEnableOption "UPNP to try to open ports 80 and 443 on your router.";

domainName = mkOption {
type = types.nullOr types.str;
Expand Down
14 changes: 9 additions & 5 deletions nixarr/lidarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@ with lib; let
nixarr = config.nixarr;
in {
options.nixarr.lidarr = {
enable = mkEnableOption "Enable the Lidarr service.";
enable = mkEnableOption "the Lidarr service.";

stateDir = mkOption {
type = types.path;
default = "${nixarr.stateDir}/nixarr/lidarr";
description = "The state directory for Lidarr";
};

vpn.enable = mkEnableOption ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
vpn.enable = mkOption {
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 {
Expand Down
14 changes: 9 additions & 5 deletions nixarr/prowlarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ in {
];

options.nixarr.prowlarr = {
enable = mkEnableOption "Enable the Prowlarr service.";
enable = mkEnableOption "the Prowlarr service.";

stateDir = mkOption {
type = types.path;
default = "${nixarr.stateDir}/nixarr/prowlarr";
description = "The state directory for Prowlarr.";
};

vpn.enable = mkEnableOption ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
vpn.enable = mkOption {
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 {
Expand Down
14 changes: 9 additions & 5 deletions nixarr/radarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ in {
description = "The state directory for radarr.";
};

vpn.enable = mkEnableOption ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
Route Radarr traffic through the VPN.
'';
vpn.enable = mkOption {
type = types.bool;
default = false;
description = ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
Route Radarr traffic through the VPN.
'';
};
};

config = mkIf cfg.enable {
Expand Down
14 changes: 9 additions & 5 deletions nixarr/readarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ in {
description = "The state directory for Readarr";
};

vpn.enable = mkEnableOption ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
Route Readarr traffic through the VPN.
'';
vpn.enable = mkOption {
type = types.bool;
default = false;
description = ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
Route Readarr traffic through the VPN.
'';
};
};

config = mkIf cfg.enable {
Expand Down
12 changes: 8 additions & 4 deletions nixarr/sonarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ in {
description = "The state directory for Sonarr.";
};

vpn.enable = mkEnableOption ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
vpn.enable = mkOption {
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 {
Expand Down
38 changes: 23 additions & 15 deletions nixarr/transmission/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with lib; let
dnsServers = config.lib.vpn.dnsServers;
in {
options.nixarr.transmission = {
enable = mkEnableOption "Enable the Transmission service.";
enable = mkEnableOption "the Transmission service.";

stateDir = mkOption {
type = types.path;
Expand All @@ -29,23 +29,31 @@ in {
'';
};

vpn.enable = mkEnableOption ''
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
vpn.enable = mkOption {
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 ''
Disable pex and dht, which is required for some private trackers.
privateTrackers = mkOption {
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
to, and some don't. All torrents from private trackers are set as
"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
their rules ¯\_(ツ)_/¯.
'';
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
"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
their rules ¯\_(ツ)_/¯.
'';
};

messageLevel = mkOption {
type = types.enum [
Expand All @@ -58,7 +66,7 @@ in {
"trace"
];
default = "warn";
description = "Sets the message level of transmission";
description = "Sets the message level of transmission.";
};

peerPort = mkOption {
Expand Down

0 comments on commit 0c61369

Please sign in to comment.