Skip to content

Commit

Permalink
lib/images: print trace messages to show evaluation progress
Browse files Browse the repository at this point in the history
  • Loading branch information
aither64 committed Jun 19, 2023
1 parent f7625e5 commit 47e912f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cluster/cz.vpsfree/machines/brq/apu/config.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ config, pkgs, lib, confDir, confLib, confData, ... }:
{ config, pkgs, lib, confDir, confLib, confData, confMachine, ... }:
let
images = import ../../../../../lib/images.nix {
inherit config lib pkgs confDir confLib confData;
inherit config lib pkgs confDir confLib confData confMachine;
nixosModules = [
../../../../../environments/base.nix
];
Expand Down
4 changes: 2 additions & 2 deletions cluster/cz.vpsfree/machines/build/config.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ config, pkgs, lib, confDir, confLib, confData, ... }:
{ config, pkgs, lib, confDir, confLib, confData, confMachine, ... }:
let
images = import ../../../../lib/images.nix {
inherit config lib pkgs confDir confLib confData;
inherit config lib pkgs confDir confLib confData confMachine;
nixosModules = [
../../../../environments/base.nix
];
Expand Down
4 changes: 2 additions & 2 deletions cluster/cz.vpsfree/machines/prg/apu/config.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ config, pkgs, lib, confDir, confLib, confData, ... }:
{ config, pkgs, lib, confDir, confLib, confData, confMachine, ... }:
let
images = import ../../../../../lib/images.nix {
inherit config lib pkgs confDir confLib confData;
inherit config lib pkgs confDir confLib confData confMachine;
nixosModules = [
../../../../../environments/base.nix
];
Expand Down
26 changes: 16 additions & 10 deletions lib/images.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
, confDir
, confLib
, confData
, confMachine
, nixosModules ? [] }:
with lib;
let
selfName = confMachine.name;

machines = confLib.getClusterMachines config.cluster;

machineAttrs = listToAttrs (map (d: nameValuePair d.config.host.fqdn d) machines);
Expand All @@ -20,7 +23,7 @@ let
selectNodes = filter: mapAttrs (k: v: nodeImage v) (filterNodes filter);

# allows to build vpsadminos with specific
vpsadminosCustom = {modules ? [], vpsadminos, nixpkgs, vpsadmin}:
vpsadminosCustom = { name, modules ? [], vpsadminos, nixpkgs, vpsadmin }:
let
# this is fed into scopedImport so vpsadminos sees correct <nixpkgs> everywhere
overrides = {
Expand All @@ -34,15 +37,15 @@ let
builtins = builtins // overrides;
};
in
builtins.scopedImport overrides (vpsadminos + "/os/") {
builtins.trace "${selfName}: evaluating ${name}" (builtins.scopedImport overrides (vpsadminos + "/os/") {
pkgs = nixpkgs;
system = "x86_64-linux";
configuration = {};
modules = modules;
};
});

vpsadminos = {modules ? [], ...}@args: vpsadminosCustom {
inherit modules;
vpsadminos = { name, modules ? [], ... }@args: vpsadminosCustom {
inherit name modules;
vpsadminos = args.vpsadminos or <vpsadminos>;
nixpkgs = args.nixpkgs or <nixpkgs>;
vpsadmin = args.vpsadmin or null;
Expand All @@ -60,6 +63,7 @@ let
lib = confLib.coreLib;
};
osBuild = vpsadminos {
name = node.name;
modules = [
{
imports = [
Expand Down Expand Up @@ -93,8 +97,8 @@ let
macs = node.config.netboot.macs or [];
};

nixosBuild = {modules ? []}:
(import <nixpkgs/nixos/lib/eval-config.nix> {
nixosBuild = { name, modules ? [] }:
builtins.trace "${selfName}: evaluating ${name}" (import <nixpkgs/nixos/lib/eval-config.nix> {
system = "x86_64-linux";
modules = [
<nixpkgs/nixos/modules/installer/netboot/netboot-minimal.nix>
Expand All @@ -117,9 +121,9 @@ let
++ modules;
}).config.system.build;

nixosNetboot = {modules ? []}:
nixosNetboot = { name, modules ? [] }:
let
build = nixosBuild { inherit modules; };
build = nixosBuild { inherit name modules; };
in {
toplevel = build.toplevel;
dir = pkgs.symlinkJoin {
Expand All @@ -131,9 +135,10 @@ let
inMenu = name: netbootitem: netbootitem // { menu = name; };

in rec {
nixos = nixosNetboot { };
nixos = nixosNetboot { name = "NixOS"; };

nixosZfs = nixosNetboot {
name = "NixOS with ZFS";
modules = [
{
imports = nixosModules;
Expand All @@ -143,6 +148,7 @@ in rec {
};

nixosZfsSSH = nixosNetboot {
name = "NixOS with ZFS and SSH";
modules = [
{
imports = nixosModules;
Expand Down

0 comments on commit 47e912f

Please sign in to comment.