···6565 '';
6666 };
67676868+ extraScanners = mkOption {
6969+ type = types.listOf types.path;
7070+ default = [];
7171+ description = ''
7272+ A list of paths to extra scanners to install in Plex's scanners
7373+ directory.
7474+7575+ Every time the systemd unit for Plex starts up, all of the symlinks
7676+ in Plex's scanners directory will be cleared and this module will
7777+ symlink all of the paths specified here to that directory.
7878+ '';
7979+ example = literalExample ''
8080+ [
8181+ (fetchFromGitHub {
8282+ owner = "ZeroQI";
8383+ repo = "Absolute-Series-Scanner";
8484+ rev = "773a39f502a1204b0b0255903cee4ed02c46fde0";
8585+ sha256 = "4l+vpiDdC8L/EeJowUgYyB3JPNTZ1sauN8liFAcK+PY=";
8686+ })
8787+ ]
8888+ '';
8989+ };
9090+6891 package = mkOption {
6992 type = types.package;
7093 default = pkgs.plex;
···113136 # Configuration for our FHS userenv script
114137 PLEX_DATADIR=cfg.dataDir;
115138 PLEX_PLUGINS=concatMapStringsSep ":" builtins.toString cfg.extraPlugins;
139139+ PLEX_SCANNERS=concatMapStringsSep ":" builtins.toString cfg.extraScanners;
116140117141 # The following variables should be set by the FHS userenv script:
118142 # PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR
+36-7
pkgs/servers/plex/default.nix
···6363 test -d "$pluginDir" || mkdir -p "$pluginDir"
64646565 # First, remove all of the symlinks in the plugins directory.
6666- echo "Removing old symlinks"
6767- for f in $(ls "$pluginDir/"); do
6868- if [[ -L "$pluginDir/$f" ]]; then
6969- echo "Removing plugin symlink: $pluginDir/$f"
7070- rm "$pluginDir/$f"
7171- fi
7272- done
6666+ while IFS= read -r -d $'\0' f; do
6767+ echo "Removing plugin symlink: $f"
6868+ done < <(find "$pluginDir" -type l -print0)
73697470 echo "Symlinking plugins"
7571 IFS=':' read -ra pluginsArray <<< "$PLEX_PLUGINS"
···8480 echo "Symlinking plugin at: $path"
8581 ln -s "$path" "$dest"
8682 fi
8383+ done
8484+ fi
8585+8686+ if [[ -n "''${PLEX_SCANNERS:-}" ]]; then
8787+ for scannerType in Common Movies Music Series; do
8888+ echo "Preparing $scannerType scanners directory"
8989+9090+ scannerDir="$PLEX_DATADIR/Plex Media Server/Scanners/$scannerType"
9191+ test -d "$scannerDir" || mkdir -p "$scannerDir"
9292+9393+ # First, remove all of the symlinks in the scanners directory.
9494+ echo "Removing old symlinks"
9595+ while IFS= read -r -d $'\0' f; do
9696+ echo "Removing scanner symlink: $f"
9797+ done < <(find "$scannerDir" -type l -print0)
9898+9999+ echo "Symlinking scanners"
100100+ IFS=':' read -ra scannersArray <<< "$PLEX_SCANNERS"
101101+ for path in "''${scannersArray[@]}"; do
102102+ # The provided source should contain a 'Scanners' directory; symlink
103103+ # from inside that.
104104+ subpath="$path/Scanners/$scannerType"
105105+ while IFS= read -r -d $'\0' file; do
106106+ dest="$scannerDir/$(basename "$file")"
107107+108108+ if [[ -f "$dest" || -L "$dest" ]]; then
109109+ echo "Error symlinking scanner from $file to $dest: file or directory already exists"
110110+ else
111111+ echo "Symlinking scanner at: $file"
112112+ ln -s "$file" "$dest"
113113+ fi
114114+ done < <(find "$subpath" -type f -print0)
115115+ done
87116 done
88117 fi
89118