From b81a0d71cb5df24b85a72443ab8040e56887f7e8 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Wed, 8 Oct 2025 08:56:22 +0000 Subject: [PATCH 1/3] ledger: modernize --- pkgs/by-name/le/ledger/package.nix | 40 +++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/pkgs/by-name/le/ledger/package.nix b/pkgs/by-name/le/ledger/package.nix index 83968f43d1bd..76d8b4b81bab 100644 --- a/pkgs/by-name/le/ledger/package.nix +++ b/pkgs/by-name/le/ledger/package.nix @@ -13,21 +13,30 @@ installShellFiles, texinfo, gnused, + versionCheckHook, + nix-update-script, usePython ? false, gpgmeSupport ? false, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "ledger"; version = "3.3.2"; src = fetchFromGitHub { owner = "ledger"; repo = "ledger"; - rev = "v${version}"; + tag = "v${finalAttrs.version}"; hash = "sha256-Uym4s8EyzXHlISZqThcb6P1H5bdgD9vmdIOLkk5ikG0="; }; + # by default, it will query the python interpreter for it's sitepackages location + # however, that would write to a different nixstore path, pass our own sitePackages location + prePatch = lib.optionalString usePython '' + substituteInPlace src/CMakeLists.txt \ + --replace-fail 'DESTINATION ''${Python_SITEARCH}' 'DESTINATION "${placeholder "py"}/${python3.sitePackages}"' + ''; + patches = [ (fetchpatch2 { name = "ledger-boost-1.85-compat.patch"; @@ -86,19 +95,12 @@ stdenv.mkDerivation rec { ]; cmakeFlags = [ - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DBUILD_DOCS:BOOL=ON" - "-DUSE_PYTHON:BOOL=${if usePython then "ON" else "OFF"}" - "-DUSE_GPGME:BOOL=${if gpgmeSupport then "ON" else "OFF"}" + (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") + (lib.cmakeBool "BUILD_DOCS" true) + (lib.cmakeBool "USE_PYTHON" usePython) + (lib.cmakeBool "USE_GPGME" gpgmeSupport) ]; - # by default, it will query the python interpreter for it's sitepackages location - # however, that would write to a different nixstore path, pass our own sitePackages location - prePatch = lib.optionalString usePython '' - substituteInPlace src/CMakeLists.txt \ - --replace 'DESTINATION ''${Python_SITEARCH}' 'DESTINATION "${placeholder "py"}/${python3.sitePackages}"' - ''; - installTargets = [ "doc" "install" @@ -108,11 +110,19 @@ stdenv.mkDerivation rec { installShellCompletion --cmd ledger --bash $src/contrib/ledger-completion.bash ''; + nativeInstallCheckInputs = [ + versionCheckHook + ]; + versionCheckProgramArg = "--version"; + doInstallCheck = true; + + passthru.updateScript = nix-update-script { }; + meta = { description = "Double-entry accounting system with a command-line reporting interface"; mainProgram = "ledger"; homepage = "https://www.ledger-cli.org/"; - changelog = "https://github.com/ledger/ledger/raw/v${version}/NEWS.md"; + changelog = "https://github.com/ledger/ledger/raw/v${finalAttrs.version}/NEWS.md"; license = lib.licenses.bsd3; longDescription = '' Ledger is a powerful, double-entry accounting system that is accessed @@ -123,4 +133,4 @@ stdenv.mkDerivation rec { platforms = lib.platforms.all; maintainers = with lib.maintainers; [ jwiegley ]; }; -} +}) From 13a7680502ebe0b13d04da29ade93de161328b29 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Wed, 8 Oct 2025 08:58:26 +0000 Subject: [PATCH 2/3] ledger: fix cmake 4 compatibility --- pkgs/by-name/le/ledger/package.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/by-name/le/ledger/package.nix b/pkgs/by-name/le/ledger/package.nix index 76d8b4b81bab..94cd731c36ea 100644 --- a/pkgs/by-name/le/ledger/package.nix +++ b/pkgs/by-name/le/ledger/package.nix @@ -99,6 +99,10 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeBool "BUILD_DOCS" true) (lib.cmakeBool "USE_PYTHON" usePython) (lib.cmakeBool "USE_GPGME" gpgmeSupport) + + # CMake 4 dropped support of versions lower than 3.5, and versions + # lower than 3.10 are deprecated. + (lib.cmakeFeature "CMAKE_POLICY_VERSION_MINIMUM" "3.10") ]; installTargets = [ From 4913d1c002c42df90ee35bdf4a0611a60cf5c326 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Wed, 8 Oct 2025 09:43:32 +0000 Subject: [PATCH 3/3] ledger-autosync: skip failing tests on darwin --- pkgs/by-name/le/ledger-autosync/package.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/le/ledger-autosync/package.nix b/pkgs/by-name/le/ledger-autosync/package.nix index 4083a7cd6b46..6cc1bb122227 100644 --- a/pkgs/by-name/le/ledger-autosync/package.nix +++ b/pkgs/by-name/le/ledger-autosync/package.nix @@ -1,5 +1,6 @@ { lib, + stdenv, python3Packages, fetchFromGitHub, ledger, @@ -11,11 +12,10 @@ python3Packages.buildPythonApplication rec { version = "1.2.0"; pyproject = true; - # no tests included in PyPI tarball src = fetchFromGitHub { owner = "egh"; repo = "ledger-autosync"; - rev = "v${version}"; + tag = "v${version}"; hash = "sha256-bbFjDdxYr85OPjdvY3JYtCe/8Epwi+8JN60PKVKbqe0="; }; @@ -33,6 +33,13 @@ python3Packages.buildPythonApplication rec { python3Packages.pytestCheckHook ]; + disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [ + # keyring.errors.KeyringError: Can't get password from keychain: (-50, 'Unknown Error') + # keyring.backends.macOS.api.Error: (-50, 'Unknown Error') + "tests/test_cli.py" + "tests/test_weird_ofx.py" + ]; + meta = { homepage = "https://github.com/egh/ledger-autosync"; changelog = "https://github.com/egh/ledger-autosync/releases/tag/v${version}";