Skip to content

Commit

Permalink
feat: add navidrome
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgon committed Oct 27, 2024
1 parent 2ba8dce commit 2863a0a
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 4 deletions.
16 changes: 13 additions & 3 deletions machines/deedee/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _: rec {
};
};

mySystem = rec {
mySystem = {
purpose = "Homelab";
filesystem = "zfs";
primaryUser = "ajgon";
Expand Down Expand Up @@ -77,8 +77,14 @@ _: rec {
mounts = [
{
type = "nfs";
src = "${nasIP}:/volume2/backup/deedee";
dest = backup.local.location;
src = "${mySystem.nasIP}:/volume2/backup/deedee";
dest = mySystem.backup.local.location;
}
{
type = "nfs";
src = "${mySystem.nasIP}:/volume1/media/music";
dest = mySystemApps.navidrome.musicPath;
opts = "ro";
}
];

Expand Down Expand Up @@ -148,6 +154,10 @@ _: rec {
lldap.enable = true;
maddy.enable = true;
miniflux.enable = true;
navidrome = {
enable = true;
musicPath = "/mnt/music";
};
paperless-ngx.enable = true;
piped.enable = true;
redlib.enable = true;
Expand Down
1 change: 1 addition & 0 deletions modules/system/containers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ _: {
./lldap
./maddy
./miniflux
./navidrome
./paperless-ngx
./piped
./redlib
Expand Down
72 changes: 72 additions & 0 deletions modules/system/containers/navidrome/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
config,
lib,
svc,
...
}:
let
cfg = config.mySystemApps.navidrome;
in
{
options.mySystemApps.navidrome = {
enable = lib.mkEnableOption "navidrome container";
backup = lib.mkEnableOption "data backup" // {
default = true;
};
dataDir = lib.mkOption {
type = lib.types.str;
description = "Path to directory containing data.";
default = "/var/lib/navidrome";
};
musicPath = lib.mkOption {
type = lib.types.str;
description = "Path to directory containing music.";
};
};

config = lib.mkIf cfg.enable {
warnings = [ (lib.mkIf (!cfg.backup) "WARNING: Backups for navidrome are disabled!") ];

virtualisation.oci-containers.containers.navidrome = svc.mkContainer {
cfg = {
image = "ghcr.io/deedee-ops/navidrome:0.53.3@sha256:9869852f68d4ed6b8dd9cfc751f3a3bd6b43b4d10fdbdeda2b44edc117c13434";
environment = {
ND_BASEURL = "/";
ND_COVERARTPRIORITY = "folder.*, cover.*, front.*";
ND_DEFAULTLANGUAGE = "en";
ND_REVERSEPROXYUSERHEADER = "Remote-User";
ND_REVERSEPROXYWHITELIST = "172.16.0.0/12";
ND_SCANNER_GROUPALBUMRELEASES = "true";
};
volumes = [
"${cfg.dataDir}/config:/config"
"${cfg.musicPath}:/data:ro"
];
};
};

services = {
nginx.virtualHosts.navidrome = svc.mkNginxVHost {
host = "navidrome";
proxyPass = "http://navidrome.docker:3000";
};
restic.backups = lib.mkIf cfg.backup (
svc.mkRestic {
name = "navidrome";
paths = [ cfg.dataDir ];
}
);
};

systemd.services.docker-navidrome = {
preStart = lib.mkAfter ''
mkdir -p "${cfg.dataDir}/config"
chown -R 65000:65000 "${cfg.dataDir}/config"
'';
};

environment.persistence."${config.mySystem.impermanence.persistPath}" =
lib.mkIf config.mySystem.impermanence.enable
{ directories = [ cfg.dataDir ]; };
};
}
9 changes: 8 additions & 1 deletion modules/system/mounts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ in
type = lib.types.str;
description = "Mount desctination.";
};
opts = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = "Extra mount options";
example = "ro";
default = null;
};
};
}
);
Expand All @@ -37,6 +43,7 @@ in
{
environment.systemPackages = lib.optionals withNFS [ pkgs.nfs-utils ];
services.rpcbind.enable = withNFS;
boot.kernelModules = lib.optionals withNFS [ "nfs" ];

systemd.mounts = builtins.map (
mount:
Expand All @@ -46,7 +53,7 @@ in
what = mount.src;
where = mount.dest;
mountConfig = {
Options = "noatime";
Options = "noatime" + (lib.optionalString (mount.opts != null) ",${mount.opts}");
};
}
else
Expand Down

0 comments on commit 2863a0a

Please sign in to comment.