Hi, I’m using home-manager, and the version of ledger I get when I do nix-env -iA nixpkgs.ledger is 3.1.3. I also get the same thing if I just add it to home.packages like so:
home.packages = with pkgs; [
...
ledger
...
];
...
I think that might be because it’s set to that version here?
If that’s so, how can I ensure I get version 3.2.1 on my machine?
I know I can do something with either overlays, or packaging it myself, and I’m certain there might be an option I haven’t even thought of as yet.
Running home-manager switch just gives me this error:
error: anonymous function at /nix/store/.../nixpkgs/pkgs/applications/office/ledger/default.nix:1:1 called with unexpected argument 'version', at /nix/store/.../nixpkgs/lib/customisation.nix:69:16
This seems like it should be super trivial if I correctly understand the way nix works, but I can’t figure it out. Any help would be fantastic, thanks.
The best way is to submit a PR to nixpkgs updating the package since it’s out of date.
But for personal use, you can use an overlay, but you’re doing it slightly wrong. You probably want overrideAttrs to update what gets passed to mkDerivation rather than override, and you’ll need to update the src attribute too, to update both its rev and its sha256.
Don’t forget that overrideAttrs takes a function with one argument (the original attributes).
I wouldn’t mind doing a PR myself once I’ve got this working.
I was totally confused here wondering how I’d get the original attributes to pass them to overrideAttrs, until I realized I could just pass them as old. I ended up with this below, which seems to work, but I’m not sure how to get the sha256 value as yet.
let
ledger = pkgs.ledger.overrideAttrs (old: rec {
version = "3.2.1";
src = old.src.override {
rev = "v${version}";
sha256 = "new hash";
};
};
in
This should work because fetchFromGitHub supports override to modify its arguments, so we can override rev and sha256 here. As with regular packages, pass a dummy hash (like pkgs.lib.fakeSha256) and the build error will tell you what the real hash should be.
error: attempt to call something which is not a function but a set, at /nix/store/...-nixpkgs-20.09pre232906.57568628bef/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:339:55
I tried fetchFromGitHub instead of old.src.override, and that seemed to work, but eventually gave me this error:
these derivations will be built:
/nix/store/2vimc42irj9yps5wg2wg1laycg7cpim6-ledger-3.2.1.drv
/nix/store/6bfa0a3sfnay8cfb9jx7lywpv4hgmdyb-home-manager-path.drv
/nix/store/lpmhk8q4a6srpjchibbvs3k1chf13gbc-activation-script.drv
/nix/store/smax3v4vp2warsb6p94q1flvarp9wm7b-home-manager-generation.drv
building '/nix/store/2vimc42irj9yps5wg2wg1laycg7cpim6-ledger-3.2.1.drv'...
unpacking sources
unpacking source archive /nix/store/vd5vjh5gy6gmbdv5kfq1x99j1g0ddryh-source
source root is source
patching sources
configuring
fixing cmake files...
cmake flags: -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_BUILD_RPATH=ON -DBUILD_TESTING=OFF -DCMAKE_INSTALL_LOCALEDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/share/locale -DCMAKE_INSTALL_LIBEXECDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/libexec -DCMAKE_INSTALL_LIBDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/lib -DCMAKE_INSTALL_DOCDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/share/doc/ -DCMAKE_INSTALL_INFODIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/share/info -DCMAKE_INSTALL_MANDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/share/man -DCMAKE_INSTALL_OLDINCLUDEDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/include -DCMAKE_INSTALL_INCLUDEDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/include -DCMAKE_INSTALL_SBINDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/sbin -DCMAKE_INSTALL_BINDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/bin -DCMAKE_INSTALL_NAME_DIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/lib -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_OSX_SYSROOT= -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_FIND_FRAMEWORK=last -DCMAKE_STRIP=/nix/store/ydk00ssq4fyx78rpmdmq1hcmz0iw575f-binutils-2.31.1/bin/strip -DCMAKE_RANLIB=/nix/store/ydk00ssq4fyx78rpmdmq1hcmz0iw575f-binutils-2.31.1/bin/ranlib -DCMAKE_AR=/nix/store/ydk00ssq4fyx78rpmdmq1hcmz0iw575f-binutils-2.31.1/bin/ar -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1 -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_DOCS:BOOL=ON -DUSE_PYTHON=true
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /nix/store/x45gpnpvbq0l3b933k187qh53y1fg7ll-gcc-wrapper-9.3.0/bin/gcc
-- Check for working C compiler: /nix/store/x45gpnpvbq0l3b933k187qh53y1fg7ll-gcc-wrapper-9.3.0/bin/gcc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /nix/store/x45gpnpvbq0l3b933k187qh53y1fg7ll-gcc-wrapper-9.3.0/bin/g++
-- Check for working CXX compiler: /nix/store/x45gpnpvbq0l3b933k187qh53y1fg7ll-gcc-wrapper-9.3.0/bin/g++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at /nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython/Support.cmake:909 (message):
FindPython: last: invalid value for 'CMAKE_FIND_FRAMEWORK'. 'FIRST',
'LAST' or 'NEVER' expected. 'FIRST' will be used instead.
Call Stack (most recent call first):
/nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython.cmake:335 (include)
CMakeLists.txt:61 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at /nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython/Support.cmake:909 (message):
FindPython: last: invalid value for 'CMAKE_FIND_FRAMEWORK'. 'FIRST',
'LAST' or 'NEVER' expected. 'FIRST' will be used instead.
Call Stack (most recent call first):
/nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython.cmake:335 (include)
CMakeLists.txt:61 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found Python: /nix/store/l7qqqls96q6x7wgvii6p0chin5ni74yz-python-2.7.18/bin/python2.7 (found version "2.7.18") found components: Interpreter
CMake Warning (dev) at /nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython/Support.cmake:909 (message):
FindPython: last: invalid value for 'CMAKE_FIND_FRAMEWORK'. 'FIRST',
'LAST' or 'NEVER' expected. 'FIRST' will be used instead.
Call Stack (most recent call first):
/nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython.cmake:335 (include)
CMakeLists.txt:68 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found Python: /nix/store/l7qqqls96q6x7wgvii6p0chin5ni74yz-python-2.7.18/bin/python2.7 (found version "2.7.18") found components: Interpreter Development
CMake Error at /nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find Boost (missing: python27) (found suitable version "1.59.0",
minimum required is "1.49.0")
Call Stack (most recent call first):
/nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
/nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindBoost.cmake:2166 (find_package_handle_standard_args)
CMakeLists.txt:82 (find_package)
-- Configuring incomplete, errors occurred!
See also "/build/source/build/CMakeFiles/CMakeOutput.log".
builder for '/nix/store/2vimc42irj9yps5wg2wg1laycg7cpim6-ledger-3.2.1.drv' failed with exit code 1
cannot build derivation '/nix/store/6bfa0a3sfnay8cfb9jx7lywpv4hgmdyb-home-manager-path.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/smax3v4vp2warsb6p94q1flvarp9wm7b-home-manager-generation.drv': 1 dependencies couldn't be built
error: build of '/nix/store/smax3v4vp2warsb6p94q1flvarp9wm7b-home-manager-generation.drv' failed
Hi again! I tried the two solutions below, and both seem to work, but I still end up with ledger 3.1.3. I’m not sure what I’m doing wrong here. I don’t get an error here at all.
these derivations will be built:
/nix/store/ij731ssjqia5xqwi204b7x081qadw22x-ledger-3.2.1.drv
/nix/store/4mrkmy8w3cf3862jmj6fj1zdv2gf5ly5-home-manager-path.drv
/nix/store/2i9i2g4v7g6n9cb6y5vw6qfhz7qcwxbi-activation-script.drv
/nix/store/ll92ng32x4lgbk9iwl94bf1gdwl1j9kk-home-manager-generation.drv
building '/nix/store/ij731ssjqia5xqwi204b7x081qadw22x-ledger-3.2.1.drv'...
unpacking sources
unpacking source archive /nix/store/vd5vjh5gy6gmbdv5kfq1x99j1g0ddryh-source
source root is source
patching sources
configuring
fixing cmake files...
cmake flags: -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_BUILD_RPATH=ON -DBUILD_TESTING=OFF -DCMAKE_INSTALL_LOCALEDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/share/locale -DCMAKE_INSTALL_LIBEXECDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/libexec -DCMAKE_INSTALL_LIBDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/lib -DCMAKE_INSTALL_DOCDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/share/doc/ -DCMAKE_INSTALL_INFODIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/share/info -DCMAKE_INSTALL_MANDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/share/man -DCMAKE_INSTALL_OLDINCLUDEDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/include -DCMAKE_INSTALL_INCLUDEDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/include -DCMAKE_INSTALL_SBINDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/sbin -DCMAKE_INSTALL_BINDIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/bin -DCMAKE_INSTALL_NAME_DIR=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1/lib -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_OSX_SYSROOT= -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_FIND_FRAMEWORK=last -DCMAKE_STRIP=/nix/store/ydk00ssq4fyx78rpmdmq1hcmz0iw575f-binutils-2.31.1/bin/strip -DCMAKE_RANLIB=/nix/store/ydk00ssq4fyx78rpmdmq1hcmz0iw575f-binutils-2.31.1/bin/ranlib -DCMAKE_AR=/nix/store/ydk00ssq4fyx78rpmdmq1hcmz0iw575f-binutils-2.31.1/bin/ar -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=/nix/store/dih30xw5vf6d8mdk1pvrhklwibl6crx4-ledger-3.2.1 -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_DOCS:BOOL=ON -DUSE_PYTHON=true
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /nix/store/x45gpnpvbq0l3b933k187qh53y1fg7ll-gcc-wrapper-9.3.0/bin/gcc
-- Check for working C compiler: /nix/store/x45gpnpvbq0l3b933k187qh53y1fg7ll-gcc-wrapper-9.3.0/bin/gcc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /nix/store/x45gpnpvbq0l3b933k187qh53y1fg7ll-gcc-wrapper-9.3.0/bin/g++
-- Check for working CXX compiler: /nix/store/x45gpnpvbq0l3b933k187qh53y1fg7ll-gcc-wrapper-9.3.0/bin/g++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at /nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython/Support.cmake:909 (message):
FindPython: last: invalid value for 'CMAKE_FIND_FRAMEWORK'. 'FIRST',
'LAST' or 'NEVER' expected. 'FIRST' will be used instead.
Call Stack (most recent call first):
/nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython.cmake:335 (include)
CMakeLists.txt:61 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at /nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython/Support.cmake:909 (message):
FindPython: last: invalid value for 'CMAKE_FIND_FRAMEWORK'. 'FIRST',
'LAST' or 'NEVER' expected. 'FIRST' will be used instead.
Call Stack (most recent call first):
/nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython.cmake:335 (include)
CMakeLists.txt:61 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found Python: /nix/store/l7qqqls96q6x7wgvii6p0chin5ni74yz-python-2.7.18/bin/python2.7 (found version "2.7.18") found components: Interpreter
CMake Warning (dev) at /nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython/Support.cmake:909 (message):
FindPython: last: invalid value for 'CMAKE_FIND_FRAMEWORK'. 'FIRST',
'LAST' or 'NEVER' expected. 'FIRST' will be used instead.
Call Stack (most recent call first):
/nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPython.cmake:335 (include)
CMakeLists.txt:68 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found Python: /nix/store/l7qqqls96q6x7wgvii6p0chin5ni74yz-python-2.7.18/bin/python2.7 (found version "2.7.18") found components: Interpreter Development
CMake Error at /nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find Boost (missing: python27) (found suitable version "1.59.0",
minimum required is "1.49.0")
Call Stack (most recent call first):
/nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
/nix/store/chym796aj801mr50hy0yy0cjqljsyrm3-cmake-3.17.3/share/cmake-3.17/Modules/FindBoost.cmake:2166 (find_package_handle_standard_args)
CMakeLists.txt:82 (find_package)
-- Configuring incomplete, errors occurred!
See also "/build/source/build/CMakeFiles/CMakeOutput.log".
builder for '/nix/store/ij731ssjqia5xqwi204b7x081qadw22x-ledger-3.2.1.drv' failed with exit code 1
cannot build derivation '/nix/store/4mrkmy8w3cf3862jmj6fj1zdv2gf5ly5-home-manager-path.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/ll92ng32x4lgbk9iwl94bf1gdwl1j9kk-home-manager-generation.drv': 1 dependencies couldn't be built
error: build of '/nix/store/ll92ng32x4lgbk9iwl94bf1gdwl1j9kk-home-manager-generation.drv' failed
There’s a note in all-packages.nix that an older version of boost was needed because ledger used the old boost_python look up conventions:
ledger = callPackage ../applications/office/ledger {
# Boost >= 1.67 changed the name of boost python; ledger's cmake build needs
# an update to find it:
# https://www.boost.org/doc/libs/1_68_0/libs/python/doc/html/rn.html
boost = boost15x;
changing the version boost fixes issue above, however, it then tries to install the compiled python module at the python interpreter’s store path.
Anyway, you can review a PR I did to do the bump, the python module isn’t really usable through nixpkgs. But it’s also hard to overwrite the python version, as it pulls the python info from boost, so you would need to recompile a new version of boost to reflect the correct python version.