Discussion:
error: cannot auto-call a function that has an argument without a default value (‘stdenv’)
(too old to reply)
tj5527 via nix-dev
2017-07-06 15:54:02 UTC
Permalink
Following the example at http://nixos.org/nix/manual/#chap-writing-nix-expressions to build hello package. But `nix-build -A hello` throws error "error: cannot auto-call a function that has an argument without a default value (‘stdenv’)"
How can I fix this problem?
My nix-build (Nix) is 1.11.11
Thanks
Vladimír Čunát via nix-dev
2017-07-07 06:07:34 UTC
Permalink
Post by tj5527 via nix-dev
Following the example
at http://nixos.org/nix/manual/#chap-writing-nix-expressions to build
hello package. But `nix-build -A hello` throws error "error: cannot
auto-call a function that has an argument without a default value
(‘stdenv’)"
How can I fix this problem?
Well, apparently you try to evaluate a standalone file that specifies a
function but you don't specify how to fill its parameters. It should be
explained in the following section
http://nixos.org/nix/manual/#sec-arguments

That's how it's commonly done in nixpkgs. If you want a *separate*
expression that depends on nixpkgs, you may e.g. start by adding this
line to the beginning of the file:
with import <nixpkgs> {};
instead of
{ stdenv, something1, something2, ... }:

--Vladimir
Christian Kauhaus via nix-dev
2017-07-07 09:13:31 UTC
Permalink
Post by Vladimír Čunát via nix-dev
That's how it's commonly done in nixpkgs. If you want a *separate*
expression that depends on nixpkgs, you may e.g. start by adding this
with import <nixpkgs> {};
instead of
Another solution (at least commonly used here at Flying Circus IO):

* leave the package expr as-is
* call it with the idiom

nix-build -E 'with import <nixpkgs> {}; callPackage ./hello.nix {}'


HTH

Christian
--
Dipl-Inf. Christian Kauhaus <>< · ***@flyingcircus.io · +49 345 219401-0
Flying Circus Internet Operations GmbH · http://flyingcircus.io
Forsterstraße 29 · 06112 Halle (Saale) · Deutschland
HR Stendal 21169 · GeschÀftsfÌhrer: Christian Theune, Christian Zagrodnick
Loading...