Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add nix support #209

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

feat: Add nix support #209

wants to merge 3 commits into from

Conversation

kai-tub
Copy link
Contributor

@kai-tub kai-tub commented Jun 5, 2024

TL;DR

  • Build audible-cli via nix including all plugins!
  • Added necessary code to create an AppImage for Linux + docker images via nix.
  • Also add GitHub action logic to check whether the package continues to build via nix, including the AppImage and docker image. Currently limiting code to Linux x86, as this is the only local machine.

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

  • Get feedback :D
  • Update README (I will update it once we have a better idea of what to include/exclude from the PR)
  • Automatically push the docker image to a docker registry when a release is tagged

Build `audible-cli` via nix _including_ all plugins!
Added necessary code to create an AppImage for Linux + docker images via
nix.
Also add GitHub action logic to check whether the package continues to
build via nix, including the AppImage and docker image.
Currently limiting support to Linux x86, as this is the only local
machine.
Take advantage of the TOML-like structure of `_version.py` file to
easily parse the given version string for the nix package version.
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