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