Unverified Commit 4c60fbd0 authored by kirillrdy's avatar kirillrdy Committed by GitHub
Browse files

ledger: fix cmake 4 compatibility (#449829)

parents 429f4963 4913d1c0
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
{
  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}";
+29 −15
Original line number Diff line number Diff line
@@ -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,18 +95,15 @@ 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}"'
  '';
    # 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 = [
    "doc"
@@ -108,11 +114,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 +137,4 @@ stdenv.mkDerivation rec {
    platforms = lib.platforms.all;
    maintainers = with lib.maintainers; [ jwiegley ];
  };
}
})