68 lines
1.7 KiB
Nix
68 lines
1.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let cfg = config.sydnix.deertopia.beets;
|
|
in {
|
|
options.sydnix.deertopia.beets = {
|
|
enable = lib.mkEnableOption "Beets";
|
|
user = lib.mkOption {
|
|
default = "beets";
|
|
type = lib.types.str;
|
|
description = ''
|
|
Name of the user which owns the Beets database.
|
|
'';
|
|
};
|
|
group = lib.mkOption {
|
|
default = "beets";
|
|
type = lib.types.str;
|
|
description = ''
|
|
Name of the group which owns the Beets database.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
users.users.${cfg.user} = {
|
|
description = "Beets";
|
|
isSystemUser = true;
|
|
inherit (cfg) group;
|
|
};
|
|
|
|
users.groups.${cfg.group} = {};
|
|
|
|
# Persist allowed directories.
|
|
sydnix.impermanence.directories = [
|
|
{
|
|
directory = "/var/lib/beets";
|
|
inherit (cfg) user group;
|
|
mode = "u=rwx,g=rwx,o=";
|
|
}
|
|
];
|
|
|
|
environment.systemPackages = [
|
|
pkgs.beets
|
|
];
|
|
|
|
environment.sessionVariables.BEETSDIR = "/var/lib/beets";
|
|
systemd.tmpfiles.settings."50-var-lib-beets-beets-yaml" = {
|
|
"/var/lib/beets/beets.yaml"."L+".argument =
|
|
lib.toString
|
|
(pkgs.writeText
|
|
"beets.yaml"
|
|
(lib.toJSON {
|
|
directory = "/media/library/music";
|
|
library = "/var/lib/beets/beets.db";
|
|
import = {
|
|
copy = true;
|
|
write = true;
|
|
incremental = true;
|
|
};
|
|
paths = {
|
|
default = "$albumartist/$album%aunique{} ($year)/$track $title";
|
|
singleton = "Non-Album/$artist/$title";
|
|
comp = "Compilations/$album%aunique{} ($year)/$title";
|
|
};
|
|
}));
|
|
};
|
|
};
|
|
}
|