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
Manual's build example doesn't build #2259
Comments
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;
} |
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 |
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. |
Oops, that's meant to go in a |
@vaibhavsagar Hi, Thanks for your fix. I am stepping over the errors mentioned by the original author. I am using
How can I fix this?
|
These look like macOS-specific issues with |
Out of curiosity I tried to reproduce this by building with @cmal Could you try with this line inside the mkDerivation?
Relevant links I found: |
I also have problems just at this very basic point of trying to learn how to write packages. I was following the manual with the same problems as the original author of this issue. Indeed it is very frustrating if even the hello world example in the documentation cannot be build. With the changes in
Maybe I should also mention, that I changed the hash value in I'm trying this on NixOS 19.03. |
Okay, finally I got it building. I needed to make the file 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 = "c510e3ad0200517e3a14534e494b37dc0770efd733fc35ce2f445dd49c96a7d5";
};
perl = pkgs.perl;
help2man = pkgs.help2man;
} file source $stdenv/setup
PATH=$perl/bin/:$help2man/bin/:$PATH
tar xvfz $src
cd hello-*
./configure --prefix=$out
make
make install And building this with |
Following documentation further
this is just building fine for me using |
Ok I found a relevant stackoverflow for this. A quote:
Sure enough, with the original default.nix and builder.sh in a directory, I can make it work:
|
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nixos-on-prgmr-and-failing-to-learn-nix-push-cx/9672/3 |
I marked this as stale due to inactivity. → More info |
Thanks for this thread, it fixed that problem with the documentation for me. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/who-uses-nixos-who-are-you-people-and-good-bye/16507/15 |
nix-build fails with a builder.sh file not found error... maybe these can help... see NixOS/nix#2259 see https://stackoverflow.com/questions/44088192/when-and-how-should-default-nix-shell-nix-and-release-nix-be-used see https://discourse.nixos.org/t/nixos-on-prgmr-and-failing-to-learn-nix-push-cx/9672/4
nix-build fails with a builder.sh file not found error... maybe these can help... see NixOS/nix#2259 see https://stackoverflow.com/questions/44088192/when-and-how-should-default-nix-shell-nix-and-release-nix-be-used see https://discourse.nixos.org/t/nixos-on-prgmr-and-failing-to-learn-nix-push-cx/9672/4
I built nix from source on Linux Mint 20.3 (based on Ubuntu 20.04, based on Debian 11), and I get a different error with the
Looks like I need to setup my NIX_PATH (I keep my nixpkgs git repo in
After that, it looks like it gets going, but only to fail with:
Finally ran after I did this (fix is from NixOS/nixpkgs#123970 (comment)):
|
@cstroe you probably need to run:
This puts
For a longer explanation (as to https://nixos.org/manual/nix/stable/command-ref/env-common.html |
@rgoulter, thanks, that seems to have helped:
I don't have to set |
Closing this as the section was removed from the manual. |
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 atest
directory with thisdefault.nix
in it. In 13.2 I also putbuilder.sh
in 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.nix
but 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.nix
like that directory already exists, and the only file by that name thatfind
turned 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/store
and 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 hello
looks 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 directory
from 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 ofcallPackage
in the manual, which only explainscallPackage
as something you'd write inall-packages.nix
rather 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.
The text was updated successfully, but these errors were encountered: