The typical thing to do, if you want to expose something callPackageable, would be 2 have to files:
- A
foo.nix(whatever your package name is, for example), which is structured to becallPackaged. - A
default.nixwhich looks something like this:
{ pkgs ? import <nixpkgs> {} }:
pkgs.callPackage ./foo.nix {}
This way, the importer can choose whether to:
import (fetchGit {...}) {}import (fetchGit {...}) { inherit pkgs; }callPackage "${fetchGit {...}}/foo.nix" {}
It’s also possible to make a single file suitable for both nix-build/import and callPackage like this:
{
pkgs ? import <nixpkgs> {},
stdenv ? pkgs.stdenv,
foo ? pkgs.foo,
bar ? pkgs.bar
}:
stdenv.mkDerivation {
(and then don’t use pkgs in the rest of the file)
This form would be usable in any of these ways:
import (fetchGit {...}) {}import (fetchGit {...}) { inherit pkgs; }callPackage (fetchGit {...}) {}