Search code examples
nix

What does a question mark mean in the head of a Nix function definition?


For example in:

{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc7102" }:
nixpkgs.pkgs.haskell.packages.${compiler}.callPackage ./foo.nix { }

What does compiler ? "ghc7102" indicate? I assume a conditional - but can't find this mentioned under https://nixos.org/nix/manual/#sec-constructs


Solution

  • Your example is a function with a set pattern and default values. Everything before : is the pattern and the expressions after ? are default values.