Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upManual's build example doesn't build #2259
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
vaibhavsagar
Jun 29, 2018
It is frustrating that the example in the manual doesn't build, especially when only small changes are required to default.nix:
let
pkgs = import <nixpkgs> {};
in
pkgs.stdenv.mkDerivation {
name = "hello-2.1.1";
builder = ./builder.sh;
src = pkgs.fetchurl {
url = ftp://ftp.nluug.nl/pub/gnu/hello/hello-2.1.1.tar.gz;
sha256 = "1md7jsfd8pa45z73bz1kszpp01yw6x5ljkjk2hx7wl800any6465";
};
perl = pkgs.perl;
}
vaibhavsagar
commented
Jun 29, 2018
|
It is frustrating that the example in the manual doesn't build, especially when only small changes are required to let
pkgs = import <nixpkgs> {};
in
pkgs.stdenv.mkDerivation {
name = "hello-2.1.1";
builder = ./builder.sh;
src = pkgs.fetchurl {
url = ftp://ftp.nluug.nl/pub/gnu/hello/hello-2.1.1.tar.gz;
sha256 = "1md7jsfd8pa45z73bz1kszpp01yw6x5ljkjk2hx7wl800any6465";
};
perl = pkgs.perl;
} |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pushcx
Jul 4, 2018
Thanks very much for the improvement, @vaibhavsagar, I can see how this looks more like a complete example. What command are you using to build? Do you have it in a hello directory? Are you running nix-build from within that directory, or a parent? Are you able to run nix-shell or nix-env?
(Asking because I've tried a bunch of variations like nix-build -A hello and nix-build -A . with no luck.)
pushcx
commented
Jul 4, 2018
|
Thanks very much for the improvement, @vaibhavsagar, I can see how this looks more like a complete example. What command are you using to build? Do you have it in a (Asking because I've tried a bunch of variations like |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pushcx
Jul 4, 2018
I sort of got it to start a build, but got a strange failure out of configure. I tried to run nix-shell because that seemed like the right tool but it also lacks newbie docs. There's a section over in the "nixpkgs" manual (though I'm not trying to contribute to a public package so I don't understand why it's there) but its description of "phases" don't at all match what's present in the shell and lead to a whole 'nother set of bugs and underdocumented topics. One again, I don't see any way forward with building a package.
I appreciate the folks who've tried to help, but I've reached my limit of time and frustration on this experiment. I'm unsubscribing from this issue; I don't know what your project standards are around closing or keeping issues open, so I'll leave it to a contributor to handle.
pushcx
commented
Jul 4, 2018
|
I sort of got it to start a build, but got a strange failure out of I appreciate the folks who've tried to help, but I've reached my limit of time and frustration on this experiment. I'm unsubscribing from this issue; I don't know what your project standards are around closing or keeping issues open, so I'll leave it to a contributor to handle. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
vaibhavsagar
Jul 10, 2018
Oops, that's meant to go in a default.nix file that you then run by executing nix-build default.nix or just nix-build (which looks for a default.nix if no filename is provided).
vaibhavsagar
commented
Jul 10, 2018
|
Oops, that's meant to go in a |
pushcx commentedJun 27, 2018
Chapter 13. A Simple Nix Expression (from
doc/manual/expressions/simple-expression.xml) introduces building packages with a worked example of building GNU hello. I attempted to use this to learn to build nix packages and was unable to build the package. I don't know where I went wrong, so this bug report is something of a step-by-step. (For context, I'm a longtime professional linux sysadmin and developer who's totally new to nix. I was able to set up a NixOS box from its manual to play around with.)The chapter is structured around three steps: writing a nix expression (13.1), writing a build script (13.2), and adding the package (13.3).
13.1 doesn't explain where to create
default.nix, but from the note "It is customary to place each package in a separate directory" I figured I should create atestdirectory with thisdefault.nixin it. In 13.2 I also putbuilder.shin this directory.Then instead of the section heading for 13.3 ("Arguments and Variables") matching the third bullet point in the intro, it's kind of a random name. It talks about editing
all-packages.nixbut the syntax is invalid. As a newbie, I don't have the experience to fill in...so the example is unusable. Additionally it talks about editingpkgs/top-level/all-packages.nixlike that directory already exists, and the only file by that name thatfindturned up is/nix/store/ilagh0i1vxhp68hd9r73lh0f2mjqbj5x-nixos-18.09pre143771.a8c71037e04/nixos/pkgs/top-level/all-packages.nix. The description of the nix store in 5.3 has a wishy-washy warning against editing files in/nix/storeand I don't see any way to regenerate that hash (or maybe I don't need to? The introduction to the hash at the top of chapter 1 says it's only based on dependencies, not contents). Still, it isn't clear at all what I'm supposed to be doing to what file, or why this is required for building hello.Then section 13.4 starts "You can now try to build Hello." and
nix-build -A hellolooks like it's assuming I put those files in a directory namedhello, though after renaming my directory I got the errorerror: getting status of '/home/pushcx/default.nix': No such file or directoryfrom outside the directory and from inside I goterror: cannot auto-call a function that has an argument without a default value ('stdenv')(with no file name or line-number). The error message is useless because I'm trying to build a package, not auto-call a function, and "auto-call" does not appear in the manual. I don't see anything more to experiment with to try to fix this.After chatting with infinisil in #nixos, I think the two causes of my confusion are:
He suggested (via the bot, so is this a frequent problem?), "If a Nix file ./foo.nix starts with something like
{ bar, baz }:, you can build it withnix-build -E '(import <nixpkgs> {}).callPackage ./foo.nix {}'" This doesn't match the description ofcallPackagein the manual, which only explainscallPackageas something you'd write inall-packages.nixrather than a command-line tool. And it doesn't account for writing abuilder.sh.Additionally, it would probably be worthwhile for someone on the team to watch a newbie try to work through the doc without answering any questions, because this wasn't the first issue I had to puzzle out, just the issue I couldn't puzzle out.