Skip to content

Instantly share code, notes, and snippets.

@LnL7

LnL7/foo.nix Secret

Last active October 12, 2017 22:26
Show Gist options
  • 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