We cannot pass `overlays = ...` to `nixpkgs` directly because by default
overlays from `~/.config/nixpkgs` are loaded in there. This doesn't
happen by default, but when using `--impure`.
Explicitly specifying that ignores these overlays. By using `pkgs.extend`
the old behavior can be kept and the new overlay can be applied.
Co-authored-by: Silvan Mosberger <contact@infinisil.com>
* Improves the comments of `lib/flake-version-info.nix` and drops the
`__`-prefix from the filename.
* `lib'` -> `lib0` in `nixpkgs/lib`.
* Drop the declaration of `trivial.version` in the overlay because this
declaration already uses the final expressions of `versionSuffix` and
`release` now.
* No need to fall back to `self.lastModified` anymore, this was a
workaround for pre2.4 Nix.
Co-authored-by: Robert Hensing <robert@roberthensing.nl>
Co-authored-by: Silvan Mosberger <contact@infinisil.com>
That way each expression uses the final version of other lib.trivial
declarations.
For instance, when replacing `versionSuffix` with the string `"fnord"`
in a lib overlay, `trivial.version` uses `"fnord"` as suffix now rather
than `pre-git`.
A lot of fetchers from Nix's own `libfetchers` also provide the
information that `lib.trivial` aims to expose with
`version`/`versionSuffix`/`revision`. In fact you don't even need a
`nixpkgs` channel to get a proper version suffix because of that!
Unfortunately this isn't used currently. When using the
nixpkgs flake, but not `nixpkgs.lib.nixosSystem` to build a NixOS
configuration, the version will always be `YY.MMpre-git`. One example is
e.g. `colmena` which evaluates configurations via
`import (npkgs.path + "/nixos/lib/eval-config.nix")`.
This patch ensures that the version suffix (i.e. the normalized last
modified date + git revision) is correctly exposed in `lib.trivial`.
Additionally, the change is injected into the following locations:
* `lib`: with that, something like
$ nix eval nixpkgs#lib.trivial.version
23.05.20230921.cf8bf79
is working fine (i.e. rather than `23.05pre-git`).
* `legacyPackages` to make sure that e.g. `legacyPackages.<system>.nixos`
has correct version info. This also applies to everything else using
`pkgs.lib.trivial` for that purpose.
* `overlays.default` which can be applied to a `nixpkgs` and changes the
previous `pkgs.lib` from said `nixpkgs` to also contain the correct
`version`/`revision`/etc..
This is useful for people using `nixpkgs` as flake input, but
importing it manually with
import inputs.nixpkgs { }
Co-authored-by: Linus Heckemann <git@sphalerite.org>