Inheriting a scoped package

EDIT: To frame my question differently, I would like to learn how to inherit a nix package that is not a top-level package, i. e. resides in haskellPackages or pythonPackages scope in the example listed in the OP.

Could this (answer to “Nix-shell build failure”) same (the part where it says inherit (arm) ...) be done when cross-building a haskell package, say hledger ?

NIX_PATH=nixpkgs=http://nixos.org/channels/nixpkgs-unstable/nixexprs.tar.xz nix-build --no-out-link -E 'let pkgsArm = import <nixpkgs> { config = {}; overlays = []; system = "aarch64-linux"; }; pkgsCross = import <nixpkgs> { overlays = [(self: super: { inherit (pkgsArm) hledger; })]; crossSystem = { config = "aarch64-unknown-linux-gnu"; }; }; in pkgsCross.hledger' --argstr system aarch64-linux --option sandbox false --builders 'ssh://nixos-shell aarch64-linux' -j0

When I’m trying

NIX_PATH=nixpkgs=http://nixos.org/channels/nixpkgs-unstable/nixexprs.tar.xz nix-build --no-out-link -E 'let pkgsArm = import <nixpkgs> { config = {}; overlays = []; system = "aarch64-linux"; }; pkgsCross = import <nixpkgs> { overlays = [(self: super: { inherit (pkgsArm) neuron; })]; crossSystem = { config = "aarch64-unknown-linux-gnu"; }; }; in pkgsCross.neuron' --argstr system aarch64-linux --option sandbox false --builders 'ssh://nixos-shell aarch64-linux' -j0

it is not the neuron package from haskellPackages but a different one.

How would I select from scope in the part where it says inherit (pkgsArm) neuron; ?
inherit (pkgsArm) haskellPackages.neuron; doesn’t seem to be valid syntax.

I think the correct syntax is:

{ inherit (pkgsArm.haskellPackages) neuron; }
2 Likes

This is the command I used to get a binary from haskell scope:

NIX_PATH=nixpkgs=http://nixos.org/channels/nixpkgs-unstable/nixexprs.tar.xz nix-build --no-out-link -E 'let pkgsArm = import <nixpkgs> { config = {}; overlays = []; system = "aarch64-linux"; }; pkgsCross = import <nixpkgs> { overlays = [(self: super: { inherit (pkgsArm.haskellPackages) neuron; })]; crossSystem = { config = "aarch64-unknown-linux-musl"; }; }; in pkgsCross.neuron'

$ file /nix/store/nmd49gnn3i0w2c7kny7ijhd3s7hci0ab-neuron-1.0.0.0/bin/neuron
/nix/store/nmd49gnn3i0w2c7kny7ijhd3s7hci0ab-neuron-1.0.0.0/bin/neuron: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /nix/store/gczfd68r4x736zvq7aafd56hhwp91pjp-glibc-2.32-40/lib/ld-linux-aarch64.so.1, for GNU/Linux 2.6.32, stripped