Derivation fails when using ./builder.sh - bash - no such file or directory

First you can post code in this way to avoid mangling formatting:

```nix
nix code here (you can also use other languages after top ```)
```

Secondly, you probably didn’t want to replace builder in the first place, as you can just replace the phases such as buildPhase as shown in https://nixos.org/nixpkgs/manual/#sec-using-stdenv, like this:

stdenv.mkDerivation {
  name = "fnord-4.5";
  ...
  buildPhase = ''
    gcc foo.c -o foo
  '';
  installPhase = ''
    mkdir -p $out/bin
    cp foo $out/bin
  '';
}

So you might want something like buildPhase = "${./builder.sh} force nixos". You need to make it build and install into $out (an environment variable containing the build destination).


If you want us to help, it would be very helpful if you could provide your builder script and Nix expression so that we can try out exactly what you have and fix exactly the problems, not having to rely on guesswork. If we can recreate exactly the problems you are having, it will be more efficient to find what the problem is and to fix it.

Of course, if for some reason you cannot provide those it’s okay too, but we’ll have to rely on communication.

Now for some other problems I noticed:

  1. ‘Force full code fetch from SVN’: This will not work. You are not allowed network access in regular builders because it breaks. You’ll want to use a fetcher, specifically fetchsvn. See here: https://nixos.org/nixpkgs/manual/#chap-pkgs-fetchers, then when you assign it to src as shown in the link, your buildPhase etc. will run in the directory of a writable copy of the downloaded source.
  2. ‘Ensure we use script via NIX’: It’s a bit suspicious. If by ‘we use script via NIX’ you mean you change some stuff in the build process to make it work with Nix then it’s fine and right, but if you run the nix or nix-* programs, it’s probably not what you want. Just build it normally and put it in $out. (By the way Nix isn’t normally spelt all capitalized.)

As of why everything got screwed up when you tried using builder, I think it’s probably args not doing what you think it does, but I’m not sure why or if it’s the reason.