lib/images: import proper version of nixpkgs library

This eliminates subtle problems for haphazardly using the same nixpkgs
library for all configurations especially those with different nixpkgs
channels.
This commit is contained in:
Gabriel Arazas 2023-12-15 22:05:49 +08:00
parent ba8338ad55
commit 1f74f96fc4
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC

View File

@ -2,26 +2,33 @@
# for use in flake.nix and nowhere else. # for use in flake.nix and nowhere else.
{ inputs, lib }: { inputs, lib }:
let
extendLib = self: super:
import ./. { lib = super; }
// import ./private.nix { lib = self; };
in
{ {
# A wrapper around the NixOS configuration function. # A wrapper around the NixOS configuration function.
mkHost = { system, extraModules ? [ ], nixpkgs-channel ? "nixpkgs" }: mkHost = { system, extraModules ? [ ], nixpkgs-channel ? "nixpkgs" }:
(lib.makeOverridable inputs."${nixpkgs-channel}".lib.nixosSystem) { let lib' = inputs.${nixpkgs-channel}.lib.extend extendLib; in
(lib'.makeOverridable lib'.nixosSystem) {
# The system of the NixOS system. # The system of the NixOS system.
inherit lib;
modules = extraModules ++ [{ nixpkgs.hostPlatform = system; }]; modules = extraModules ++ [{ nixpkgs.hostPlatform = system; }];
}; };
# A wrapper around the home-manager configuration function. # A wrapper around the home-manager configuration function.
mkHome = { pkgs, extraModules ? [ ], home-manager-channel ? "home-manager" }: mkHome = { pkgs, extraModules ? [ ], home-manager-channel ? "home-manager" }:
inputs."${home-manager-channel}".lib.homeManagerConfiguration { inputs.${home-manager-channel}.lib.homeManagerConfiguration {
inherit lib pkgs; inherit pkgs;
lib = pkgs.lib.extend extendLib;
modules = extraModules; modules = extraModules;
}; };
# A wrapper around the nixos-generators `nixosGenerate` function. # A wrapper around the nixos-generators `nixosGenerate` function.
mkImage = { system, pkgs ? null, extraModules ? [ ], format ? "iso" }: mkImage = { system, pkgs ? null, extraModules ? [ ], format ? "iso" }:
inputs.nixos-generators.nixosGenerate { inputs.nixos-generators.nixosGenerate {
inherit pkgs system format lib; inherit pkgs system format;
lib = pkgs.lib.extend extendLib;
modules = extraModules; modules = extraModules;
}; };