Move non-upstreamed NixNG modules into this repo

This commit is contained in:
Pim Kunis 2025-01-04 11:22:05 +01:00
parent 4503a8f541
commit 3b0a54581d
10 changed files with 265 additions and 3 deletions

View file

@ -688,11 +688,11 @@
"treefmt-nix": "treefmt-nix_2"
},
"locked": {
"lastModified": 1735551011,
"narHash": "sha256-rp26PcdLjfgxsCeaSeZ0K1rGPN1Ap7YCy1UVuo9gRJA=",
"lastModified": 1735985475,
"narHash": "sha256-7blkWqfcvYKfaL2hpy/nWTooHRfJSqaO0a2+XWccqkE=",
"owner": "pizzapim",
"repo": "NixNG",
"rev": "aa35f7a3d426e906b15e3083c90bf2972bcfb4b4",
"rev": "dea65c6a83945c755b9d0097aa2535991daeb907",
"type": "github"
},
"original": {

View file

@ -60,5 +60,6 @@
./formatter.nix
./shell.nix
./nixng-configurations
./nixng-modules
];
}

View file

@ -37,6 +37,12 @@ in {
};
extraModules = [
self.nixngModules.bazarr
self.nixngModules.radicale
self.nixngModules.jellyseerr
self.nixngModules.radarr
self.nixngModules.sonarr
self.nixngModules.prowlarr
{
nixpkgs.overlays = [
(final: _prev: {

29
nixng-modules/bazarr.nix Normal file
View file

@ -0,0 +1,29 @@
{
lib,
config,
pkgs,
...
}: let
cfg = config.services.bazarr;
in {
options.services.bazarr = {
enable = lib.mkEnableOption "bazarr";
package = lib.mkPackageOption pkgs "bazarr" {};
configDir = lib.mkOption {
description = "Where Bazarr's configuration files are stored.";
type = lib.types.str;
default = "/config";
};
};
config = lib.mkIf cfg.enable {
init.services.bazarr = {
enabled = true;
script = pkgs.writeShellScript "bazarr-run" ''
${lib.getExe cfg.package} \
--no-update \
--config '${cfg.configDir}'
'';
};
environment.systemPackages = [cfg.package];
};
}

10
nixng-modules/default.nix Normal file
View file

@ -0,0 +1,10 @@
{...}: {
nixngModules = {
bazarr = import ./bazarr.nix;
radicale = import ./radicale.nix;
jellyseerr = import ./jellyseerr.nix;
radarr = import ./radarr.nix;
sonarr = import ./sonarr.nix;
prowlarr = import ./prowlarr.nix;
};
}

View file

@ -0,0 +1,46 @@
{
lib,
pkgs,
config,
...
}: let
cfg = config.services.jellyseerr;
in {
options.services.jellyseerr = {
enable = lib.mkEnableOption "jellyseerr";
package = lib.mkPackageOption pkgs "jellyseerr" {};
port = lib.mkOption {
description = ''
The port Jellyseerr should listen on.
'';
type = lib.types.port;
example = 8080;
default = 5055;
};
configDir = lib.mkOption {
description = ''
The directory to save run-time configuration.
'';
type = lib.types.str;
example = "/jellyseerr";
default = "/var/lib/jellyseerr";
};
};
config = lib.mkIf cfg.enable {
init.services.jellyseerr = {
enabled = true;
script = lib.getExe cfg.package;
};
environment = {
systemPackages = [cfg.package];
variables = {
PORT = builtins.toString cfg.port;
CONFIG_DIRECTORY = cfg.configDir;
};
};
};
}

View file

@ -0,0 +1,33 @@
{
pkgs,
lib,
config,
...
}: let
cfg = config.services.prowlarr;
in {
options.services.prowlarr = {
enable = lib.mkEnableOption "prowlarr";
package = lib.mkPackageOption pkgs "prowlarr" {};
dataDir = lib.mkOption {
description = "Directory to store Prowlarr's data";
type = lib.types.str;
default = "/config";
};
};
config = lib.mkIf cfg.enable {
init.services.prowlarr = {
enabled = true;
script = pkgs.writeShellScript "prowlarr-run" ''
${lib.getExe cfg.package} \
-nobrowser \
-data=${cfg.dataDir}
'';
};
environment.systemPackages = [cfg.package];
};
}

31
nixng-modules/radarr.nix Normal file
View file

@ -0,0 +1,31 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.services.radarr;
in {
options.services.radarr = {
enable = lib.mkEnableOption "radarr";
package = lib.mkPackageOption pkgs "radarr" {};
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/radarr/.config/Radarr";
description = "The directory where Radarr stores its data files.";
};
};
config = lib.mkIf cfg.enable {
init.services.radarr = {
enabled = true;
script = pkgs.writeShellScript "radarr-run.sh" ''
${lib.getExe cfg.package} -nobrowser -data='${cfg.dataDir}'
'';
};
environment.systemPackages = [cfg.package];
};
}

View file

@ -0,0 +1,75 @@
{
lib,
pkgs,
config,
nglib,
...
}: let
cfg = config.services.radicale;
settingsFormat = pkgs.formats.ini {
listToValue = lib.concatMapStringsSep ", " (lib.generators.mkValueStringDefault {});
};
in {
options.services.radicale = {
enable = lib.mkEnableOption "radicale";
package = lib.mkPackageOption pkgs "radicale" {};
user = lib.mkOption {
description = "radicale user";
type = lib.types.str;
default = "radicale";
};
group = lib.mkOption {
description = "radicale group";
type = lib.types.str;
default = "radicale";
};
settings = lib.mkOption {
type = settingsFormat.type;
default = {};
description = ''
Configuration for Radicale. See
<https://radicale.org/v3.html#configuration>.
'';
example = lib.literalExpression ''
server = {
hosts = [ "0.0.0.0:5232" "[::]:5232" ];
};
auth = {
type = "htpasswd";
htpasswd_filename = "/etc/radicale/users";
htpasswd_encryption = "bcrypt";
};
storage = {
filesystem_folder = "/var/lib/radicale/collections";
};
'';
};
};
config = lib.mkIf cfg.enable (let
configFile = settingsFormat.generate "radicale.ini" cfg.settings;
in {
init.services.radicale = {
enabled = true;
script = pkgs.writeShellScript "radicale-run" ''
chpst -u ${cfg.user}:${cfg.group} ${cfg.package}/bin/radicale \
--config ${configFile}
'';
};
environment.systemPackages = [cfg.package];
users.users.${cfg.user} = nglib.mkDefaultRec {
description = "radicale";
group = cfg.group;
createHome = false;
home = "/var/empty";
useDefaultShell = true;
uid = config.ids.uids.radicale;
};
users.groups.${cfg.group} = nglib.mkDefaultRec {gid = config.ids.gids.radicale;};
ids = {
uids.radicale = 408;
gids.radicale = 408;
};
});
}

31
nixng-modules/sonarr.nix Normal file
View file

@ -0,0 +1,31 @@
{
lib,
config,
pkgs,
...
}: let
cfg = config.services.sonarr;
in {
options.services.sonarr = {
enable = lib.mkEnableOption "sonarr";
package = lib.mkPackageOption pkgs "sonarr" {};
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/sonarr/.config/NzbDrone";
description = "The directory where Sonarr stores its data files.";
};
};
config = lib.mkIf cfg.enable {
init.services.sonarr = {
enabled = true;
script = pkgs.writeShellScript "sonarr-run" ''
${lib.getExe cfg.package} -nobrowser -data=${cfg.dataDir}
'';
};
environment.systemPackages = [cfg.package];
};
}