Skip to content

buildEnv: build the whole tree of directories to pathsToLink - #16828

Closed
rasendubi wants to merge 1 commit into
NixOS:stagingfrom
rasendubi:staging-buildenv
Closed

rasendubi wants to merge 1 commit into
NixOS:stagingfrom
rasendubi:staging-buildenv

Conversation

@rasendubi

Copy link
Copy Markdown
Member
Things done
  • Tested using sandboxing
    (nix.useChroot on NixOS,
    or option build-use-chroot in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • OS X
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

This patch fixes #16614 and #16741.

The first issue was caused by the fact that both /share and
/share/fish/vendor_completions.d end in the pathsToLink. The
pkgs/build-support/buildenv/builder.pl creates /share, then links
/share/fish under /share and then tries to create the directory
/share/fish/vendor_completions.d and fails because it already exists.

The simplest way to reproduce the issue is to build the next Nix
expression:

let pkgs = import <nixpkgs> { };
in pkgs.buildEnv {
  name = "buildenv-issue";

  paths = [
    pkgs.fish
    pkgs.vim
  ];

  pathsToLink = [
    "/share"
    "/share/fish/vendor_completions.d"
  ];
}

The second issue is more critical and was caused by the fact findFiles
doesn't recurse deep enough. It stops at first unique directory for the
package (e.g., "/share" or even "/") and later the scripts decides it
shouldn't link it as it doesn't match pathsToLink (e.g., "/share/fish"),
so the result is empty.

The test:

let pkgs = import <nixpkgs> { };
in pkgs.buildEnv {
  name = "buildenv-issue";

  paths = [
    pkgs.fish
    pkgs.vim
  ];

  pathsToLink = [
    "/share/fish/functions"
  ];
}

or

let pkgs = import <nixpkgs> { };
in pkgs.buildEnv {
  name = "buildenv-issue";

  paths = [
    pkgs.vim
  ];

  pathsToLink = [
    "/share"
  ];
}

@mention-bot

Copy link
Copy Markdown

@rasendubi, thanks for your PR! By analyzing the annotation information on this pull request, we identified @edolstra, @aszlig and @abbradar to be potential reviewers

This patch fixes NixOS#16614 and NixOS#16741.

The first issue was caused by the fact that both `/share` and
`/share/fish/vendor_completions.d` end in the `pathsToLink`. The
`pkgs/build-support/buildenv/builder.pl` creates `/share`, then links
`/share/fish` under `/share` and then tries to create the directory
`/share/fish/vendor_completions.d` and fails because it already exists.

The simplest way to reproduce the issue is to build the next Nix
expression:

```nix
let pkgs = import <nixpkgs> { };
in pkgs.buildEnv {
  name = "buildenv-issue";

  paths = [
    pkgs.fish
    pkgs.vim
  ];

  pathsToLink = [
    "/share"
    "/share/fish/vendor_completions.d"
  ];
}
```

The second issue is more critical and was caused by the fact findFiles
doesn't recurse deep enough. It stops at first unique directory for the
package (e.g., "/share" or even "/") and later the scripts decides it
shouldn't link it as it doesn't match pathsToLink (e.g., "/share/fish"),
so the result is empty.

The test:
```nix
let pkgs = import <nixpkgs> { };
in pkgs.buildEnv {
  name = "buildenv-issue";

  paths = [
    pkgs.fish
    pkgs.vim
  ];

  pathsToLink = [
    "/share/fish/functions"
  ];
}
```

or

```nix
let pkgs = import <nixpkgs> { };
in pkgs.buildEnv {
  name = "buildenv-issue";

  paths = [
    pkgs.vim
  ];

  pathsToLink = [
    "/share"
  ];
}
```
@abbradar

Copy link
Copy Markdown
Member

Awesome! buildEnv was in dire need of several fixes IMO. Thanks @rasendubi.

@abbradar

Copy link
Copy Markdown
Member

I have tested this on current staging -- it results in a working system with no regression visible. I think we can merge this, but I'm not sure whether we want it in the current pack of staging patches or should wait till the next.

cc @vcunat as one who'll most likely start staging evaluation and looked through recent patches.

@Profpatsch

Copy link
Copy Markdown
Member

Thanks for fixing the bug after discovering it, and even going way further. I must admit, my motivation to do it myself was rather low, so thank you sir!

@vcunat

vcunat commented Jul 12, 2016

Copy link
Copy Markdown
Member

@abbradar: you can merge immediately, if you feel confident it's OK. I can't get staging to re-evaluate now anyway, probably due to out-of-disk problem.

@abbradar

Copy link
Copy Markdown
Member

@vcunat I did just that after yet one more testing, and also merged in #16763 and #16801 -- I figured out if they are dependent on staging patches but otherwise ready we can as well just merge them there.

@abbradar

Copy link
Copy Markdown
Member

Closed by 0172558

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.kind: bug Something is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants