How to build nixpkgs packages?

What’s the best workflow?

I want to build nixpkgs/pkgs/applications/science/math/lp_solve/default.nix at 9fa3b1ec2a7760c3ca69eebcff4485b1d03bb434 · NixOS/nixpkgs · GitHub. I downloaded the file, renamed it from default.nix to lp_solve.nix and tried building like this:

nix-build -I nixpkgs=channel:nixos-unstable -E 'with import <nixpkgs> {}; callPackage /path/to/lp_solve.nix {}'

Unfortunately, I get an erorr:

error: evaluation aborted with the following error message:
'lib.customisation.callPackageWith: Function called without required argument "autoSignDarwinBinariesHook" at /path/to/lp_solve.nix:7'

Is this the right way to build packages manually or am I doing it wrong?

My system
  • system: "x86_64-linux"
  • host os: Linux 6.15.1, NixOS, 25.05 (Warbler), 25.05.803579.70c74b02eac4
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.28.3
  • channels(root): "nixos-25.05, nixos-hardware"
  • nixpkgs: /nix/store/gdz4yp5sjq3b1q0g9ad9hicqsx1alvif-nixos-25.05/nixos

You also need to look at the callsite to see what args are passed to callPackage and even see which callPackage was used.

1 Like

Is this the most optimal way to build a package locally?

nom-build -I nixpkgs=channel:nixos-unstable \
-E 'let pkgs = import <nixpkgs> { crossSystem = { config = "aarch64-unknown-linux-gnu"; }; }; in pkgs.callPackage ./default.nix { inherit (pkgs.darwin) autoSignDarwinBinariesHook; }'

The command is so long I am no forced to rename downloaded default.nix files into lp_solve.nix. Is there nothing I can do to make this workflows simpler?

It’s not that bad, I just wonder if I am doing something wrong.

You can change the file so that it takes darwin as an arg instead of autoSignDarwinBinariesHook, then use darwin.autoSignDarwinBinariesHook in the file where needed. That would allow you to shorten the command.

Also you can use ./. instead of ./default.nix.

1 Like