Ricky Kresslein

Audiobookshelf On NixOS With Docker

2022-10-05

There is no need for a long introduction here. This is the contents of my audiobookshelf.nix file. All of the data is saved on an external (encrypted) SSD, called /media.

{ config, pkgs, ... }:
			
{                          
  # Audiobookshelf
  virtualisation.oci-containers.containers."audiobookshelf" = {
	autoStart = true;
	image = "ghcr.io/advplyr/audiobookshelf:latest";
	environment = {
	  AUDIOBOOKSHELF_UID = "99";
	  AUDIOBOOKSHELF_GID = "100";
	};
	ports = [ "13378:80" ];
	volumes = [
	  "/media/Audiobooks:/audiobooks"
	  "/media/Podcasts:/podcasts"
	  "/media/Containers/Audiobookshelf/config:/config"
	  "/media/Containers/Audiobookshelf/audiobooks:/metadata"
	];
  };
}

Since that's in its own .nix file, we need to add it to the imports section of the /etc/nixos/configuration.nix, like so:

imports = [
  ./hardware-configuration.nix
  # Docker containers
  ./containers/audiobookshelf.nix
];

That's it! Run sudo nixos-rebuild switch and, once it downloads and starts, you should have a running Audiobookshelf container on your NixOS box!