nixos/installer/cd-dvd: use filtered nixpkgs source

Pin the `nixpkgs` registry entry to the *filtered* nixpkgs source to
avoid copying the entire `.git` directory to the ISO when building
from a local checkout.

Also set `to` directly instead of the `flake.outPath` hack.
This commit is contained in:
Naïm Favier 2022-12-02 22:09:49 +01:00
parent 3dc19ce82d
commit 364d3609cd
No known key found for this signature in database
GPG key ID: 95AFCE8211908325

View file

@ -6,6 +6,12 @@
with lib;
let
# This is copied into the installer image, so it's important that it is filtered
# to avoid including a large .git directory.
# We also want the source name to be normalised to "source" to avoid depending on the
# location of nixpkgs.
# In the future we might want to expose the ISO image from the flake and use
# `self.outPath` directly instead.
nixpkgs = lib.cleanSource pkgs.path;
# We need a copy of the Nix expressions for Nixpkgs and NixOS on the
@ -31,7 +37,14 @@ let
in
{
nix.registry.nixpkgs.flake.outPath = builtins.path { name = "source"; path = pkgs.path; };
# Pin the nixpkgs flake in the installer to our cleaned up nixpkgs source.
# FIXME: this might be surprising and is really only needed for offline installations,
# see discussion in https://github.com/NixOS/nixpkgs/pull/204178#issuecomment-1336289021
nix.registry.nixpkgs.to = {
type = "path";
path = nixpkgs;
};
# Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required
# for nixos-install.
boot.postBootCommands = mkAfter