Skip to content

Add NixOS module with library deployment support#6

Open
csingley wants to merge 2 commits into
PandorasFox:primaryfrom
csingley:primary
Open

Add NixOS module with library deployment support#6
csingley wants to merge 2 commits into
PandorasFox:primaryfrom
csingley:primary

Conversation

@csingley

@csingley csingley commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Factors the NixOS module out of flake.nix into nix/module.nix, adds nix/lib.nix with a typed path schema DSL
  • New module options: srcRoot, librariesDir, stashDir, autoDeploy, libraries
  • The libraries attrset is keyed by library name (subdirectory under librariesDir); each entry specifies an optional src corpus subpath prefix (defaults to "" = entire corpus) and a pathSchema
  • Path schemas are typed lists of tag references and string literals via music-magic.lib.tags, giving Nix-level tag name validation rather than untyped template strings
  • Also includes: lofty 0.23.2 → 0.24 upgrade, transcode stash location fix, git commit guidance in CLAUDE.md

Example configuration

{ inputs, pkgs, ... }:
let inherit (inputs.music-magic.lib) tags; in {
  services.music-magic = {
    enable       = true;
    srcRoot      = "/srv/media/audio/inbox";
    librariesDir = "/srv/media/audio";
    stashDir     = "/srv/media/audio/stash";
    autoDeploy   = true;

    libraries."music" = {
      pathSchema = with tags; [ ARTIST ALBUM [ TRACKNUMBER " - " TITLE ] ];
    };
  };
}

Multi-library example:

libraries = {
  "music" = {
    pathSchema = with tags; [ ARTIST ALBUM [ TRACKNUMBER " - " TITLE ] ];
  };
  "audiophile" = {
    src        = "vinyl-rips";
    pathSchema = with tags; [ ARTIST ALBUM [ TRACKNUMBER " - " TITLE ] ];
  };
};

Test plan

  • nixos-rebuild switch with the example configuration
  • Verify config.kdl and dirs.kdl are generated correctly in /var/lib/mm/
  • Verify corpus deploys to librariesDir/<library-name>/ with correct path schema
  • Verify autoDeploy triggers deployment on corpus changes

csingley added 2 commits June 17, 2026 07:58
Factor the NixOS module out of flake.nix into nix/module.nix, and add
nix/lib.nix with a typed path schema DSL using tag attrsets instead of
untyped template strings.

New module options: librariesDir, stashDir, autoDeploy, libraries.
The libraries attrset is keyed by library name (subdirectory under
librariesDir); each entry has an optional src (corpus subpath prefix,
defaults to "" = entire corpus) and pathSchema.

Path schemas are expressed as ordered lists of tag references and string
literals rather than raw template strings, giving Nix-level tag name
validation via attribute lookup on music-magic.lib.tags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant