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

fix "nix build -f /dev/stdin" #2669

wants to merge 1 commit into
base: master
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+8 −1
Diff settings


Just for now

fix "nix build -f /dev/stdin"

The idea is to allow Nix code in heredoc


nix build -f /dev/stdin <<'EOF'
  inherit (import <nixpkgs> {}) lib buildGoPackage;
in buildGoPackage {

  • Loading branch information...
volth committed Feb 7, 2019
commit 61ad24b22dd063455a5ff89f684f6a954a2ffe86
Copy path View file
@@ -551,6 +551,10 @@ Path resolveExprPath(Path path)
assert(path[0] == '/');

// Do not follow symlink chain in /dev, it will be "/dev/stdin" -> "/proc/self/fd/0" -> "/tmp/sh-thd.PUK62Q (deleted)"
if (, 5, "/dev/") == 0)
return path;

/* If `path' is a symlink, follow it. This is so that relative
path references work. */
struct stat st;
@@ -577,7 +581,10 @@ Expr * EvalState::parseExprFromFile(const Path & path)

Expr * EvalState::parseExprFromFile(const Path & path, StaticEnv & staticEnv)
return parse(readFile(path).c_str(), path, dirOf(path), staticEnv);
if (path == "/dev/stdin")

This comment has been minimized.


aszlig Feb 9, 2019


This is already handled by nix-build -, so we don't need to special-case this, see EvalState::parseStdin and instead just use the same implementation for nix build.

This comment has been minimized.


volth Feb 9, 2019

Author Contributor

wow, nice find
nix build is less usable anyway, it does not print the results (#2622)

This comment has been minimized.


LnL7 Feb 9, 2019


#2583 does this for all commands that take the -f flag.

return parse(readFile(path).c_str(), path, absPath("."), staticEnv);
return parse(readFile(path).c_str(), path, dirOf(path), staticEnv);

ProTip! Use n and p to navigate between commits in a pull request.