nix-pills
nix-pills copied to clipboard
pill 7.7 fails on Darwin
Fails to build in OSX. Solution, inspired on #35:
with (import <nixpkgs> {});
let gcc = stdenv.cc;
in
derivation {
name = "simple";
builder = "${bash}/bin/bash";
args = [ ./simple_builder.sh ];
inherit gcc coreutils;
src = ./simple.c;
system = builtins.currentSystem;
}
What is the output?
copying path '/nix/store/il6yvbnfqgh4gmrx3kxnr9ggsmk26zyq-mpfr-3.1.6' from 'https://cache.nixos.org'...
copying path '/nix/store/r24xdkvwi3mx4lyaxzi1r1cdadifndim-pcre-8.41' from 'https://cache.nixos.org'...
copying path '/nix/store/wf58m510x6g6ik42pxi0ddbwyh3vxilx-libmpc-1.1.0' from 'https://cache.nixos.org'...
copying path '/nix/store/c3sa761qjcaa5rg0s8h8qxj0mghkidv5-gnugrep-3.1' from 'https://cache.nixos.org'...
copying path '/nix/store/hx3siphz67qji0ag17hnnblywi3136z2-gcc-7.3.0' from 'https://cache.nixos.org'...
copying path '/nix/store/7j56b0vlaw1klmvscjz7sgkaplah7dyn-gcc-wrapper-7.3.0' from 'https://cache.nixos.org'...
building '/nix/store/d58dk1vq84c6xap1x3xgsa4bg7iyx1ax-simple.drv'...
/nix/store/9nld1c5cfjlq0af0s2758vczfky5bq0z-simple.c: In function 'main':
/nix/store/9nld1c5cfjlq0af0s2758vczfky5bq0z-simple.c:2:3: warning: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
puts("SIMPLE!");
^~~~
/nix/store/7j56b0vlaw1klmvscjz7sgkaplah7dyn-gcc-wrapper-7.3.0/bin/as: assembler (clang) not installed
builder for '/nix/store/d58dk1vq84c6xap1x3xgsa4bg7iyx1ax-simple.drv' failed with exit code 1
error: build of '/nix/store/d58dk1vq84c6xap1x3xgsa4bg7iyx1ax-simple.drv' failed
I disagree with adding platform specific conditionals to the examples, they should be as straightforward as possible to avoid confusion. Adding a disclaimer that these are intentionally linux only and suggesting to use a docker container if they want to build the examples would be better IMHO.
eg. the stdenv has not been introduced at this point yet.
How about adding a second listing for macOS/clang?
Not sure, because the darwin stdenv has some impurities so I think it wouldn't be straightforward to make a proper example.
Wouldn’t using docker defeat the purpose of showing that Nix is a superior tool for this kind of job?
I want my software team at work to adopt Nix. If they needed Docker to do a simple “hello world”... That would make Nix redundant and further entrench their view that Docker is all they need.
-- Daniel Vianna
On 21 Aug 2018, at 3:53 am, Daiderd Jordan [email protected] wrote:
Not sure, because the darwin stdenv has some impurities so I think it wouldn't be straightforward to make a proper example.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Next thing we'd have to do for hello is introduce darwin.cctools and there are probably more cases like that.
The purpose of these examples is to explain the essentials of what the stdenv is and why it exists, not a walkthrough of the implementation with all it's quirks. The actual implementation is pretty complex and only a few people fully understand it. A section or pill on some the differences between different platforms and how the stdenv generalises these (eg. gcc/clang => stdenv.cc) is something that would make sense. Since in that case it's the actual subject.
FYI. I'm one of the active darwin maintainers. I do very much care about compatibility in nixpkgs, however reinventing the wheel in a tutorial seems pointless and confusing to me.
same problem:
nix-repl> :b simple
builder for '/nix/store/xggwdhl9mw8acgjidcvgsvj5qdxm3jb5-simple.drv' failed with exit code 1; last 1 log lines:
/nix/store/xs8x90rif8vp3ymhdyqpc66cx0l7s2c9-gcc-wrapper-7.3.0/bin/as: assembler (clang) not installed
[0 built (1 failed)]
error: build of '/nix/store/xggwdhl9mw8acgjidcvgsvj5qdxm3jb5-simple.drv' failed
An alternative would be to replace the current example with one that works equally well on both platforms. E.g., this OCaml equivalent:
simple.ml
print_string "Hello world!\n"
simpler_builder.sh
export PATH="$coreutils/bin:$ocaml/bin"
mkdir $out
ocamlc -o $out/simple $src
and the derivation
nix-repl> simple = derivation { name = "simple"; builder = "${bash}/bin/bash"; args = [ ./simple_builder.sh ]; ocaml = ocaml; coreutils = coreutils; src = ./simple.ml; system = builtins.currentSystem; }
This builds fine on my mac, and I expect it should do the same on linux.