mkb79 / audible-cli

A command line interface for audible package. With the cli you can download your Audible books, cover, chapter files.
GNU Affero General Public License v3.0
455 stars 46 forks source link

feat: Add nix support #209

Open kai-tub opened 4 months ago

kai-tub commented 4 months ago

TL;DR

Trying out nix

On a Linux x86 machine, install nix via the upstream installer and enable flake support or use the more popular nix-installer from DeterminateSystems that enables flake support out-of-the-box (recommended).

Move to the repository and build the desired artefact via:

nix build .#<package-name>

One can check the available packages via nix flake show and those under the packages entry:

[...]
└───packages
    └───x86_64-linux
        ├───audible-cli: package 'audible-cli-0.3.2b3+date=2024-06-05_defd5eb'
        ├───audible-cli-AppImage: package 'audible-cli-0.3.2b3+date=2024-06-05_defd5eb-x86_64.AppImage'
        ├───audible-cli-docker: package 'audible-cli.tar.gz'
        ├───audible-cli-full: package 'audible-cli-0.3.2b3+date=2024-06-05_defd5eb'
        ├───default: package 'audible-cli-0.3.2b3+date=2024-06-05_defd5eb'
        └───isbntools: package 'python3.11-isbntools-4.3.29'

On an x86_64-linux host, the system can be skipped, so to build audible-cli-AppImage run nix build .#audible-cli-AppImage.

All build outputs will be located locally inside of the repository with the name result and symbolically linked to the output path in the nix store.

./result -> '/nix/store/vvqhgaapi6kzjv8wdim85gd63jk3i2h8-audible-cli-0.3.2b3+date=2024-06-05_defd5eb-x86_64.AppImage'

AppImage

The resulting AppImage can then be used on all x86-Linux systems independent of the Distro (see #208). Even on systems with much older glibc versions thanks to the amazing work of ralismark in nix-appimage.

Docker

With little changes, the nix output can also be used to create a LayeredDocker image (see the nix-docker-or-both blog post from numtide and Nix is a better Docker image builder than Docker's image builder from xeiaso for details).

The OCI-Container can be built and executed via

nix build .#audible-cli-docker
docker load < ./result
docker run localhost/audible-cli:latest --help

Plugins

All packages (audible-cli-full, audible-cli-docker, audible-cli-AppImage) include all plugins except audible-cli, which includes none. Though, it is trivial to pick-and-choose which plugins should be included included by default if desired. For the decrypt plugin ffmpeg-7-headless is used.

Automation

I have also included a GitHub action automation that ensures that all nix artefacts can be build, that the nix source code is formatted correctly, and that the AppImage can be executed on the ubuntu runner. It also includes an automation that will add the AppImage to the GitHub release assets section (see https://github.com/kai-tub/audible-cli-appimage/releases/tag/audible-cli-b3adb9 for example).

TODO