Get the package build log when the build succeeds

I am trying to build a package that’s not in nixpkgs. I have it building successfully. However, I want to check something from the build log (e.g. if tests were run or something along those lines). When the build fails, the output has something like:

       For full logs, run 'nix log /nix/store/....drv'.

However, when the build succeeds, it doesn’t show the derivation. I found one way to get the derivation from this post How to find derivations that have already been built by various nix commands? - #5 by NobbZ, i.e. using:

$ nix eval .#package.drvPath

Is that the correct way to get the derivation?

Assuming it is, after a successful build, it only shows this on subsequent invocations:

$ nix log /nix/store/....drv
created 275 symlinks in user environment

Is there a way to get the full build logs for a successful build somehow?

nix log $(realpath result)

(if you use bash/zsh)
or

nix log <installable>

(assuming you built the package with nix build <installable>)

That results in the same output

created 275 symlinks in user environment

It doesn’t show what happened during the build phase that succeeded in one of the previous runs, since it doesn’t rebuild it as it has it in built in the /nix/store.

If that’s what you get then those are the logs.
You might be looking for logs for a dependency, hard to say if you don’t provide an example.

I’m guessing you’re using a buildEnv here based on those logs, so there aren’t going to be more logs than that really. You have to identify which dependency you want to get logs for.

1 Like

Ah, I wrongly assumed nix log will show the full log of the latest build for that package. Thanks for clearing that up.

It does, that was my point.
You aren’t looking for logs for that package, you’re looking for logs for a dependency, and you need to provide that dependency as the arg to nix log.

Agreed. What I meant when I said “the full log” is “the log for everything that it says it’s building by briefly printing on stdout”, which includes all the dependencies.

In my case, it’s a new python package. So let’s assume this is the first time I am installing python as well. It would fetch whatever it needs to build python and all the specified packages. I thought nix log will show the logs for that whole build “session”.

Instead, it shows the build log for a particular derivation (so excludes the dependent derivations) - which makes sense in hindsight.

Now I just need to figure out why:

$ nix eval .#python.pkgs.apyanki
error: flake 'git+file:///home/icyrockcom/nix/apyanki' does not provide attribute 'packages.x86_64-linux.python.pkgs.apyanki', 'legacyPackages.x86_64-linux.python.pkgs.apyanki' or 'python.pkgs.apyanki'

even though:

$ nix run .#python -- -c 'import apyanki; print(apyanki)'
<module 'apyanki' from '/nix/store/2s0ccg4bzp1viacw8dc0625v9l1l9skp-python3-3.12.9-env/lib/python3.12/site-packages/apyanki/__init__.py'>

so I can provide that to nix log.