Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pill 7.2: declare -xp shows no ouput in nix repl #106

Closed
willbush opened this issue Feb 8, 2019 · 11 comments · Fixed by #174
Closed

pill 7.2: declare -xp shows no ouput in nix repl #106

willbush opened this issue Feb 8, 2019 · 11 comments · Fixed by #174

Comments

@willbush
Copy link
Member

willbush commented Feb 8, 2019

7.2. Using a script as a builder

The above pill references output made by declare -xp in the nix repl. However, I'm not getting any. The following shows my output:

> cat builder.sh
declare -xp
echo foo > $out
> nix repl
Welcome to Nix version 2.2. Type :? for help.

nix-repl> :l <nixpkgs>
Added 9889 variables.

nix-repl> "${bash}"
"/nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23"

nix-repl> d = derivation { name = "foo"; builder = "${bash}/bin/bash"; args = [ ./builder.sh ]; system = builtins.currentSystem; }

nix-repl> :b d

this derivation produced the following outputs:
  out -> /nix/store/1vx0mr2ahappwh04m4af3q18llhrr48x-foo

nix-repl>

version info:

>cat /etc/issue; uname -r

<<< Welcome to NixOS 19.03pre166987.bc41317e243 (\m) - \l >>>

Run `nixos-help` for the NixOS manual.

4.19.16
> nix --version
nix (Nix) 2.2
@philipstears
Copy link

For what it's worth, nix-store -r <derivation path> does show the debugging output, so I ended up using that instead.

@acarrico
Copy link

acarrico commented Dec 5, 2019

Thanks for the question. I found some notes about the logs in the nix manual. They are (normally) stored in /nix/var/log. You can you nix-store --read-log to see them.

nix-store --read-log /nix/store /nix/store/i76pr1cz0za3i9r6xq518bqqvd2raspw-foo.drv

or

nix-store --read-log /nix/store /nix/store/gczb4qrag22harvv693wwnflqy7lx5pb-foo

I agree that nix-store --read-log should be mentioned in this pill, and it would be nice if there were repl commands for showing derivations and logs.

@acarrico
Copy link

acarrico commented Dec 5, 2019

... and here is a way to do it without typing the hash explicitly:

$ nix build --file ./pill7.nix
$ nix-store --read-log result

declare -x HOME="/homeless-shelter"
declare -x NIX_BUILD_CORES="4"
declare -x NIX_BUILD_TOP="/build"
declare -x NIX_LOG_FD="2"
declare -x NIX_STORE="/nix/store"
declare -x OLDPWD
declare -x PATH="/path-not-set"
declare -x PWD="/build"
declare -x SHLVL="1"
declare -x TEMP="/build"
declare -x TEMPDIR="/build"
declare -x TMP="/build"
declare -x TMPDIR="/build"
declare -x builder="/nix/store/l6h4ya0wzb4b8mr0y58k2gh2nhfql4sn-bash-4.4-p23/bin/bash"
declare -x coreutils="/nix/store/kx56d14p0qm2awn0qrqrv4rb8xdhvhpi-coreutils-8.31"
declare -x name="foo"
declare -x out="/nix/store/zc0g804ydw8z4y8wj0vqjb86525ah1j8-foo"
declare -x system="x86_64-linux"

@acarrico
Copy link

acarrico commented Dec 5, 2019

Digging deeper nix log also exists.

Assuming default.nix is in the current directory, then:

nix build
nix log ./result

will show the log (but nix log result will not).

Unfortunately, it doesn't seem like nix build has any option to show the log as it builds. Or does someone know a way? It seems like showing the log as it builds would be a useful developer option for the nix command and the repl.

Here is an issue that talks about the behavior of nix log:

NixOS/nix#2066

@dschrempf
Copy link

I also bumped into this issue. It should be stated that the debug output is not printed (or a way to get the debug output) in the main text of the nix pill.

@nielsegberts
Copy link
Contributor

I've created a pull request to add that nix-store --read-log can be used to see the builder logs.

#174

@tfc
Copy link
Contributor

tfc commented Dec 2, 2021

It becomes visible when running nix -L repl.

@paulmattei
Copy link

It becomes visible when running nix -L repl.

Which version of Nix are you running?

$ nix -L repl
Welcome to Nix version 2.3.16. Type :? for help.

$ nix -L repl
Welcome to Nix version 2.3.16. Type :? for help.

nix-repl> :l <nixpkgs>                                                                                 Added 15438 variables.      

nix-repl> d = derivation { name = "foo"; builder = "${bash}/bin/bash"; args = [ ./builder.sh ]; system = builtins.currentSystem; }

nix-repl> :b d                                                                                         
this derivation produced the following outputs:
  out -> /nix/store/i6xkvhaj58nr0s0038x32h42g7nx1fjk-foo

nix-repl> 

@tfc
Copy link
Contributor

tfc commented Jan 3, 2022

oh, it's 2.5.0pre...

@m0ar
Copy link

m0ar commented Aug 23, 2022

Meanwhile, one can execute :log d after the build to see the log output :)

@trofi
Copy link
Contributor

trofi commented Aug 23, 2022

+1 for $ nix repl -L

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants