From 74b8e0598bbd2ec834ea3073ac5b8485e2779706 Mon Sep 17 00:00:00 2001 From: mib Date: Wed, 25 Feb 2026 15:47:04 +0100 Subject: [PATCH] add nix support Signed-off-by: mib --- .gitignore | 4 ++ flake.lock | 27 ++++++++++++ flake.nix | 17 ++++++++ nix/package.nix | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 162 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/package.nix diff --git a/.gitignore b/.gitignore index f806d0a2..0b429d23 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,7 @@ whipper.egg-info/ # From coverage report .coverage + +# nix +result +result-man diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..85f840a3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1771923393, + "narHash": "sha256-Fy0+UXELv9hOE8WjYhJt8fMDLYTU2Dqn3cX4BwoGBos=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ea7f1f06811ce7fcc81d6c6fd4213150c23edcf2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..0ecb2333 --- /dev/null +++ b/flake.nix @@ -0,0 +1,17 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + }; + + outputs = + { self, nixpkgs }: + let + inherit (nixpkgs) lib; + in + { + packages = lib.genAttrs lib.systems.flakeExposed (system: rec { + default = whipper; + whipper = nixpkgs.legacyPackages.${system}.callPackage ./nix/package.nix { }; + }); + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 00000000..723363be --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,114 @@ +{ + lib, + python3, + fetchFromGitHub, + fetchpatch, + installShellFiles, + wrapGAppsNoGuiHook, + gobject-introspection, + libcdio-paranoia, + cdrdao, + libsndfile, + glib, + flac, + sox, + util-linux, + testers, + whipper, +}: +let + bins = [ + libcdio-paranoia + cdrdao + flac + sox + util-linux + ]; +in +python3.pkgs.buildPythonApplication rec { + pname = "whipper"; + version = "0.10.0"; + pyproject = true; + + src = ./..; + + nativeBuildInputs = [ + gobject-introspection + installShellFiles + wrapGAppsNoGuiHook + ]; + + build-system = with python3.pkgs; [ + docutils + setuptools-scm + ]; + + propagatedBuildInputs = with python3.pkgs; [ + discid + musicbrainzngs + mutagen + packaging + pillow + pycdio + pygobject3 + ruamel-yaml + setuptools + ]; + + buildInputs = [ + libsndfile + glib + ]; + + nativeCheckInputs = + with python3.pkgs; + [ + pytestCheckHook + twisted + ] + ++ bins; + + makeWrapperArgs = [ + "--prefix" + "PATH" + ":" + (lib.makeBinPath bins) + "\${gappsWrapperArgs[@]}" + ]; + + dontWrapGApps = true; + + outputs = [ + "out" + "man" + ]; + postBuild = '' + make -C man + ''; + + preCheck = '' + # disable tests that require internet access + # https://github.com/JoeLametta/whipper/issues/291 + substituteInPlace whipper/test/test_common_accurip.py \ + --replace "test_AccurateRipResponse" "dont_test_AccurateRipResponse" + export HOME=$TMPDIR + ''; + + postInstall = '' + installManPage man/*.1 + ''; + + passthru.tests.version = testers.testVersion { + package = whipper; + command = "HOME=$TMPDIR whipper --version"; + }; + + meta = { + homepage = "https://github.com/whipper-team/whipper"; + description = "CD ripper aiming for accuracy over speed"; + maintainers = with lib.maintainers; [ mib ]; + license = lib.licenses.gpl3Plus; + platforms = lib.platforms.unix; + mainProgram = "whipper"; + }; +}