Skip to content

Commit 4c60fbd

Browse files
authored
ledger: fix cmake 4 compatibility (NixOS#449829)
2 parents 429f496 + 4913d1c commit 4c60fbd

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

pkgs/by-name/le/ledger-autosync/package.nix

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
lib,
3+
stdenv,
34
python3Packages,
45
fetchFromGitHub,
56
ledger,
@@ -11,11 +12,10 @@ python3Packages.buildPythonApplication rec {
1112
version = "1.2.0";
1213
pyproject = true;
1314

14-
# no tests included in PyPI tarball
1515
src = fetchFromGitHub {
1616
owner = "egh";
1717
repo = "ledger-autosync";
18-
rev = "v${version}";
18+
tag = "v${version}";
1919
hash = "sha256-bbFjDdxYr85OPjdvY3JYtCe/8Epwi+8JN60PKVKbqe0=";
2020
};
2121

@@ -33,6 +33,13 @@ python3Packages.buildPythonApplication rec {
3333
python3Packages.pytestCheckHook
3434
];
3535

36+
disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
37+
# keyring.errors.KeyringError: Can't get password from keychain: (-50, 'Unknown Error')
38+
# keyring.backends.macOS.api.Error: (-50, 'Unknown Error')
39+
"tests/test_cli.py"
40+
"tests/test_weird_ofx.py"
41+
];
42+
3643
meta = {
3744
homepage = "https://github.com/egh/ledger-autosync";
3845
changelog = "https://github.com/egh/ledger-autosync/releases/tag/v${version}";

pkgs/by-name/le/ledger/package.nix

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,30 @@
1313
installShellFiles,
1414
texinfo,
1515
gnused,
16+
versionCheckHook,
17+
nix-update-script,
1618
usePython ? false,
1719
gpgmeSupport ? false,
1820
}:
1921

20-
stdenv.mkDerivation rec {
22+
stdenv.mkDerivation (finalAttrs: {
2123
pname = "ledger";
2224
version = "3.3.2";
2325

2426
src = fetchFromGitHub {
2527
owner = "ledger";
2628
repo = "ledger";
27-
rev = "v${version}";
29+
tag = "v${finalAttrs.version}";
2830
hash = "sha256-Uym4s8EyzXHlISZqThcb6P1H5bdgD9vmdIOLkk5ikG0=";
2931
};
3032

33+
# by default, it will query the python interpreter for it's sitepackages location
34+
# however, that would write to a different nixstore path, pass our own sitePackages location
35+
prePatch = lib.optionalString usePython ''
36+
substituteInPlace src/CMakeLists.txt \
37+
--replace-fail 'DESTINATION ''${Python_SITEARCH}' 'DESTINATION "${placeholder "py"}/${python3.sitePackages}"'
38+
'';
39+
3140
patches = [
3241
(fetchpatch2 {
3342
name = "ledger-boost-1.85-compat.patch";
@@ -86,18 +95,15 @@ stdenv.mkDerivation rec {
8695
];
8796

8897
cmakeFlags = [
89-
"-DCMAKE_INSTALL_LIBDIR=lib"
90-
"-DBUILD_DOCS:BOOL=ON"
91-
"-DUSE_PYTHON:BOOL=${if usePython then "ON" else "OFF"}"
92-
"-DUSE_GPGME:BOOL=${if gpgmeSupport then "ON" else "OFF"}"
93-
];
98+
(lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib")
99+
(lib.cmakeBool "BUILD_DOCS" true)
100+
(lib.cmakeBool "USE_PYTHON" usePython)
101+
(lib.cmakeBool "USE_GPGME" gpgmeSupport)
94102

95-
# by default, it will query the python interpreter for it's sitepackages location
96-
# however, that would write to a different nixstore path, pass our own sitePackages location
97-
prePatch = lib.optionalString usePython ''
98-
substituteInPlace src/CMakeLists.txt \
99-
--replace 'DESTINATION ''${Python_SITEARCH}' 'DESTINATION "${placeholder "py"}/${python3.sitePackages}"'
100-
'';
103+
# CMake 4 dropped support of versions lower than 3.5, and versions
104+
# lower than 3.10 are deprecated.
105+
(lib.cmakeFeature "CMAKE_POLICY_VERSION_MINIMUM" "3.10")
106+
];
101107

102108
installTargets = [
103109
"doc"
@@ -108,11 +114,19 @@ stdenv.mkDerivation rec {
108114
installShellCompletion --cmd ledger --bash $src/contrib/ledger-completion.bash
109115
'';
110116

117+
nativeInstallCheckInputs = [
118+
versionCheckHook
119+
];
120+
versionCheckProgramArg = "--version";
121+
doInstallCheck = true;
122+
123+
passthru.updateScript = nix-update-script { };
124+
111125
meta = {
112126
description = "Double-entry accounting system with a command-line reporting interface";
113127
mainProgram = "ledger";
114128
homepage = "https://www.ledger-cli.org/";
115-
changelog = "https://github.com/ledger/ledger/raw/v${version}/NEWS.md";
129+
changelog = "https://github.com/ledger/ledger/raw/v${finalAttrs.version}/NEWS.md";
116130
license = lib.licenses.bsd3;
117131
longDescription = ''
118132
Ledger is a powerful, double-entry accounting system that is accessed
@@ -123,4 +137,4 @@ stdenv.mkDerivation rec {
123137
platforms = lib.platforms.all;
124138
maintainers = with lib.maintainers; [ jwiegley ];
125139
};
126-
}
140+
})

0 commit comments

Comments
 (0)