Skip to content

Instantly share code, notes, and snippets.

@LnL7

LnL7/foo.nix Secret

Last active October 12, 2017 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LnL7/264d3730ddc5c57cfdf7b4b0c1185e7e to your computer and use it in GitHub Desktop.
Save LnL7/264d3730ddc5c57cfdf7b4b0c1185e7e to your computer and use it in GitHub Desktop.
{ pkgs ? import <nixpkgs> {} }:
let
callPackage = pkgs.lib.callPackageWith { foo = 1; };
bar = 2;
baz = 3;
in
{
x = callPackage ({ foo }: foo) {};
y = callPackage ({ bar }: bar) { bar = bar; };
z = callPackage ({ baz }: baz) {};
}
# nix-instantiate --eval foo.nix -A x
# 1
# nix-instantiate --eval foo.nix -A y
# 2
# nix-instantiate --eval foo.nix -A z
# error: anonymous function at foo.nix:12:20 called without required argument 'baz'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment