I’m trying to debug a package that is breaking and would like to run the build tools manually from within the cntr container. I have added the breakpointHook
and have attached to the container, but I can’t seem to run make or any of the other build tools. Am I missing a step?
You should just use nix-shell
. You’ll be in an environment where you can execute the build steps as your own user in your own directories, exactly as they’d be done in the proper nix-build. The shell will include some handy shell functions, like genericBuild
will just do the entire build as your user in the current directory, or you can pick a phase to run like unpackPhase
to ready the sources, configurePhase
, buildPhase
, etc…
Is it possible to do it as you suggest for a single .nix
package without going through the full package addition process (as outlined here Nixpkgs/Create and debug packages - NixOS Wiki)? For example, I have tried: nix-shell '<nixkgs>' -A ./mypkg.nix
and a couple of other permutations that I though may work, without success.
You probably mean something like this: nix-shell ./mypkg.nix
. The positional argument to nix-shell
is the file you’d like to evaluate, and -A
says you’d like to evaluate a specific attribute of that file. So nix-shell "<nixpkgs>" -A hello
will evaluate the expression in the file pointed to by <nixpkgs>
(angle brackets are special syntax for finding files on NIX_PATH), select the hello
attribute from the returned expression, and put you in a shell very much like the build environment for building the hello
package. And nix-shell ./mypkg.nix
says to evaluate the ./mypkg.nix
file and put you in a shell for building the package returned by it.
Thank you, really appreciate you taking the time to explain that. Once I worked out what to set the arguments too, was able to get it running.