It looks like there are two mostly-distinct use cases for default.nix: the file that nix-build
looks for, and the default file in a directory that import
or callPackage
will find if passed the directory name, but the required preamble is different in each case
Either I write something like
with import <nixpkgs> {} ;
stdenv.mkDerivation {
...
that I can use standalone, or I write
{ stdenv, someInput, someOtherInput }:
stdenv.mkDerivation {
...
that I can refer to elsewhere using callPackage
Is there some way to get the same default.nix to serve both purposes? I’ve taken to writing the latter form and then having a separate build.nix
which callPackages it, but it’s more typing for nix-build and nix-shell and I wonder if I’m missing a trick