diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 6c46201..bec6184 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -4,6 +4,4 @@ { # List your module files here # my-module = import ./my-module.nix; - qbittorrent = import ./qbittorrent.nix; - jellyfin-rpc = import ./jellyfin-rpc.nix; } diff --git a/modules/nixos/jellyfin-rpc.nix b/modules/nixos/jellyfin-rpc.nix deleted file mode 100644 index f7615b4..0000000 --- a/modules/nixos/jellyfin-rpc.nix +++ /dev/null @@ -1,131 +0,0 @@ -{ lib, pkgs, config, ... }: - -with lib; - -let - cfg = config.services.jellyfin-rpc; - UID = 999; - GID = 999; -in -{ - options.services.jellyfin-rpc = { - enable = mkEnableOption "jellyfin-rpc service"; - - user = mkOption { - type = types.str; - default = "jellyfin-rpc"; - description = lib.mdDoc '' - User account under which jellyfin-rpc runs. - ''; - }; - - group = mkOption { - type = types.str; - default = "jellyfin-rpc"; - description = lib.mdDoc '' - Group under which jellyfin-rpc runs. - ''; - }; - - jellyfin.url = mkOption { - type = types.str; - default = "https://example.com"; - description = '' - Url to jellyfin server. - ''; - }; - - jellyfin.apiKey = mkOption { - type = types.str; - default = "sadasodsapasdskd"; - description = '' - Jellyfin API key, you can get one at http(s)://your_jellyfin_url/web/#!/apikeys.html - ''; - }; - - jellyfin.username = mkOption { - type = types.str; - default = "my_user"; - description = '' - Username used to log in to jellyfin. - ''; - }; - - discordApplicationID = mkOption { - type = types.str; - default = "1053747938519679018"; - description = '' - Discord application ID, you can make one here https://discord.com/developers/applications - ''; - }; - - imgurClientID = mkOption { - type = types.str; - default = "asdjdjdg394209fdjs093"; - description = '' - Imgur Client ID, goto https://api.imgur.com/oauth2/addclient - ''; - }; - - package = mkOption { - type = types.package; - default = pkgs.jellyfin-rpc; - defaultText = literalExpression "pkgs.jellyfin-rpc"; - example = literalExpression "pkgs.jellyfin-rpc"; - description = '' - Jellyfin-RPC derivation to use. - ''; - }; - }; - - config = mkIf cfg.enable { - - systemd.services.jellyfin-rpc = { - description = "jellyfin-rpc service"; - wantedBy = [ "multi-user.target" ]; - - serviceConfig = { - Type = "simple"; - User = cfg.user; - Group = cfg.group; - - ExecStart = "${cfg.package}/bin/jellyfin-rpc --config /etc/jellyfin-rpc/main.json"; - }; - }; - - environment.etc."jellyfin-rpc/main.json".text = '' - { - "jellyfin": { - "url": "${cfg.jellyfin.url}", - "api_key": "${cfg.jellyfin.apiKey}", - "username": ["${cfg.jellyfin.username}"], - "music": { - "display": ["year", "album"] - } - }, - "discord": { - "application_id": "${cfg.discordApplicationID}" - }, - "imgur": { - "client_id": "${cfg.imgurClientID}" - }, - "images": { - "enable_images": true, - "imgur_images": true - } - } - ''; - - users.users = mkIf (cfg.user == "jellyfin-rpc") { - jellyfin-rpc = { - group = cfg.group; - uid = UID; - }; - }; - - users.groups = mkIf (cfg.group == "jellyfin-rpc") { - jellyfin-rpc = { gid = GID; }; - }; - }; - } - diff --git a/modules/nixos/qbittorrent.nix b/modules/nixos/qbittorrent.nix deleted file mode 100644 index 2842bbd..0000000 --- a/modules/nixos/qbittorrent.nix +++ /dev/null @@ -1,124 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - cfg = config.services.qbittorrent; - UID = 888; - GID = 888; -in -{ - options.services.qbittorrent = { - enable = mkEnableOption (lib.mdDoc "qBittorrent headless"); - - dataDir = mkOption { - type = types.path; - default = "/var/lib/qbittorrent"; - description = lib.mdDoc '' - The directory where qBittorrent stores its data files. - ''; - }; - - user = mkOption { - type = types.str; - default = "qbittorrent"; - description = lib.mdDoc '' - User account under which qBittorrent runs. - ''; - }; - - group = mkOption { - type = types.str; - default = "qbittorrent"; - description = lib.mdDoc '' - Group under which qBittorrent runs. - ''; - }; - - port = mkOption { - type = types.port; - default = 8080; - description = lib.mdDoc '' - qBittorrent web UI port. - ''; - }; - - openFirewall = mkOption { - type = types.bool; - default = false; - description = lib.mdDoc '' - Open services.qBittorrent.port to the outside network. - ''; - }; - - package = mkOption { - type = types.package; - default = pkgs.qbittorrent-nox; - defaultText = literalExpression "pkgs.qbittorrent-nox"; - description = lib.mdDoc '' - The qbittorrent package to use. - ''; - }; - }; - - config = mkIf cfg.enable { - networking.firewall = mkIf cfg.openFirewall { - allowedTCPPorts = [ cfg.port ]; - }; - - 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 = cfg.user; - Group = cfg.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 "${cfg.user}" -g "${cfg.group}" "$QBT_PROFILE" - fi - ''; - in - "!${preStartScript}"; - - #ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox"; - ExecStart = "${cfg.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=cfg.dataDir; - QBT_WEBUI_PORT=toString cfg.port; - }; - }; - - users.users = mkIf (cfg.user == "qbittorrent") { - qbittorrent = { - group = cfg.group; - uid = UID; - }; - }; - - users.groups = mkIf (cfg.group == "qbittorrent") { - qbittorrent = { gid = GID; }; - }; - }; -} -