This makes things a little bit more convenient. Just pass in like:
$ nix-build ’<nixpkgs>’ -A hello --argstr localSystem x86_64-linux --argstr crossSystem aarch64-linux
If we passed a localSystem in, we don’t want the current system to
override it. Now we check for localSystem first to avoid getting
"mixed" localSystem values from commands like this:
nix-build --arg localSystem '{config="x86_64-unknown-linux-musl";}' -A hello
Which would eventually evaluate localSystem to this:
{
config = "x86_64-unknown-linux-musl";
system = "x86_64-darwin";
}
& Nix would not be able to run it correctly.
Fixes #41599
/cc @Ericson2314
If impure.nix gets the path from NIX_PATH, the type is `path`, and `path+"/."` is a no-op. Stringify it first so `isDir` will return false if it's not, in fact, a dir. This way, single files can be specified with nixpkgs-overlays in the NIX_PATH.
Note that ${} substitution doesn't work because of the "cannot refer
to other paths" constraint. The paranthesis are needed to enforce
right-first evaluation.
The Nix search path is the established mechanism for specifying the
location of Nix expressions, so let's use it instead of adding another
environment variable.
This patch add a new argument to Nixpkgs default expression named "overlays".
By default, the value of the argument is either taken from the environment variable `NIXPKGS_OVERLAYS`,
or from the directory `~/.nixpkgs/overlays/`. If the environment variable does not name a valid directory
then this mechanism would fallback on the home directory. If the home directory does not exists it will
fallback on an empty list of overlays.
The overlays directory should contain the list of extra Nixpkgs stages which would be used to extend the
content of Nixpkgs, with additional set of packages. The overlays, i-e directory, files, symbolic links
are used in alphabetical order.
The simplest overlay which extends Nixpkgs with nothing looks like:
```nix
self: super: {
}
```
More refined overlays can use `super` as the basis for building new packages, and `self` as a way to query
the final result of the fix-point.
An example of overlay which extends Nixpkgs with a small set of packages can be found at:
https://github.com/nbp/nixpkgs-mozilla/blob/nixpkgs-overlay/moz-overlay.nix
To use this file, checkout the repository and add a symbolic link to
the `moz-overlay.nix` file in `~/.nixpkgs/overlays` directory.