anchor.diff:      services.plex-media-server = {
         enable = mkEnableOption "Plex Media Server";
   
  -      # FIXME: In order for this config option to work, symlinks in the Plex
  -      # package in the Nix store have to be changed to point to this directory.
  -      dataDir = mkOption {
  -        type = types.str;
  -        default = "/var/lib/plex";
  -        description = "The directory where Plex stores its data files.";
  -      };
  -
         user = mkOption {
           type = types.str;
           default = "plex";
  
positive.code:         ExecStart = "/bin/sh -c '${cfg.package}/lib/plexmediaserver/Plex\\ Media\\ Server'";
        };
        environment = {
          PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=cfg.dataDir;
          PLEX_MEDIA_SERVER_HOME="${cfg.package}/lib/plexmediaserver";
          PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6";
          PLEX_MEDIA_SERVER_TMPDIR="/tmp";
          LD_LIBRARY_PATH = "${plex.plexLibraryPath}:${cfg.dataDir}";
          LC_ALL="en_US.UTF-8";
          LANG="en_US.UTF-8";
        };
  
negative.code:       after = [ "network.target" ];
        wantedBy = [ "multi-user.target" ];
        preStart = ''
          if [ ! -d "${cfg.package.dataDir}" ] ; then
            mkdir -pv '${cfg.package.dataDir}/Plex Media Server'
            chown -R ${cfg.user}:${cfg.group} '${cfg.package.dataDir}'
          fi
  
          # Copy the database skeleton files to /var/lib/plex/.skeleton
          plexDb='com.plexapp.plugins.library.db'
          plexDbBase="${cfg.package}/lib/plexmediaserver/Resources/base_$plexDb"
          plexDbTargetDir="${cfg.package.dataDir}/.skeleton"
          plexDbTarget="$plexDbTargetDir/$plexDb"
          if [ ! -f "$plexDbTarget" ] ; then
            if [ ! -d "#plexDbTargetDir" ] ; then
              mkdir -pv "$plexDbTargetDir"
            fi
            cp -v "$plexDbBase" "$plexDbTarget"
            chmod u+w "${cfg.package.dataDir}/.skeleton/$db"
            chown ${cfg.user}:${cfg.group} "$plexDbTarget"
          fi
        '' /* If managePlugins is enabled, setup symlinks for plugins. */
          + optionalString cfg.managePlugins ''
          echo "Preparing plugin directory."
          PLUGINDIR="${cfg.package.dataDir}/Plex Media Server/Plug-ins"
          test -d "$PLUGINDIR" || {
            mkdir -p "$PLUGINDIR";
            chown ${cfg.user}:${cfg.group} "$PLUGINDIR";
          }
  
          echo "Removing old symlinks."
          # First, remove all of the symlinks in the directory.
          for f in `ls "$PLUGINDIR/"` ; do
            if [ -L "$PLUGINDIR/$f" ] ; then
              rm -v "$PLUGINDIR/$f"
            fi
          done
  
          echo "Symlinking plugins."
          for path in ${toString cfg.extraPlugins} ; do
            dest="$PLUGINDIR/$(basename $path)"
            if [ ! -d "$path" ] ; then
              echo "Error symlinking plugin from $path: no such directory."
            elif [ -d "$dest" ] || [ -L "$dest" ] ; then
              echo "Error symlinking plugin from $path to $dest: file or directory already exists."
            else
              echo "Symlinking plugin at $path..."
              ln -sv "$path" "$dest"
            fi
          done
        '';
        serviceConfig = {
          Type = "simple";
          User = cfg.user;
  