I have a local file, default.nix
that I want to use to build a nix derivation. The file builds a finite element library called Firedrake. This is a large library with many dependencies. The inputs to my nix expression are:
{
lib,
pkgs,
buildPythonPackage,
callPackage,
substituteAll,
fetchFromGitHub,
mpich,
petsc,
hdf5-mpi,
openssh,
mpiCheckPhaseHook,
libspatialindex,
setuptools,
cython_0,
cached-property,
cachetools,
packaging,
progress,
requests,
rtree,
scipy,
sympy,
vtk,
mpi4py,
h5py-mpi,
pytestCheckHook,
pytest-xdist,
pylit,
}:
Where some of these correspond to other .nix
files in the same directory.
Before, when I’ve built smaller projects, I would just run something like nix-build -A firedrake
in the directory. However, when I do that I get errors for each input like:
error: cannot evaluate a function that has an argument without a value ('buildPythonPackage')
Nix attempted to evaluate a function as a top level expression; in
this case it must have its arguments supplied either by default
values, or passed explicitly with '--arg' or '--argstr'. See
https://nixos.org/manual/nix/stable/language/constructs.html#functions.
So I can start passing arguments like the error suggests:
nix-build -A firedrake --arg lib '<nixpkgs/lib>' --arg pkgs '<nixpkgs>' --arg buildPythonPackage '<nixpkgs/buildPythonPackage>'
But this can’t be the right way to go about it.
I think there is a way to do this where use a flake.nix
file that takes nixpkgs unstable as the input and tries to build firedrake as the output, but I cannot figure out how to do this.
Could you help me figure out how to achieve this? The question boils down to:
What directory structure, and what nix build
type command do I need, in order to attempt to build local nix derivations I am currently working on, so I can see the errors that still exist, and debug the building process.
Thank you!