From e1b6f307ecfa88e9759646b22c8b9ece580e1b78 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Thu, 5 Sep 2024 13:44:17 +1000 Subject: [PATCH] linux-builder: make `package.nixosConfig` accurate --- modules/nix/linux-builder.nix | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/modules/nix/linux-builder.nix b/modules/nix/linux-builder.nix index 9edfed6..9756fe4 100644 --- a/modules/nix/linux-builder.nix +++ b/modules/nix/linux-builder.nix @@ -3,16 +3,8 @@ with lib; let - inherit (pkgs) stdenv; - cfg = config.nix.linux-builder; - builderWithOverrides = cfg.package.override (previousArguments: { - # the linux-builder packages require a list `modules` argument, so it's - # always non-null. - modules = previousArguments.modules ++ [ cfg.config ]; - }); - # create-builder uses TMPDIR to share files with the builder, notably certs. # macOS will clean up files in /tmp automatically that haven't been accessed in 3+ days. # If we let it use /tmp, leaving the computer asleep for 3 days makes the certs vanish. @@ -23,9 +15,9 @@ let mkdir -p $TMPDIR trap "rm -rf $TMPDIR" EXIT ${lib.optionalString cfg.ephemeral '' - rm -f ${cfg.workingDirectory}/${builderWithOverrides.nixosConfig.networking.hostName}.qcow2 + rm -f ${cfg.workingDirectory}/${cfg.package.nixosConfig.networking.hostName}.qcow2 ''} - ${builderWithOverrides}/bin/create-builder + ${cfg.package}/bin/create-builder ''; in @@ -41,6 +33,11 @@ in type = types.package; default = pkgs.darwin.linux-builder; defaultText = "pkgs.darwin.linux-builder"; + apply = pkg: pkg.override (old: { + # the linux-builder package requires `modules` as an argument, so it's + # always non-null. + modules = old.modules ++ [ cfg.config ]; + }); description = '' This option specifies the Linux builder to use. ''; @@ -135,7 +132,7 @@ in systems = mkOption { type = types.listOf types.str; - default = [ builderWithOverrides.nixosConfig.nixpkgs.hostPlatform.system ]; + default = [ cfg.package.nixosConfig.nixpkgs.hostPlatform.system ]; defaultText = '' The `nixpkgs.hostPlatform.system` of the build machine's final NixOS configuration. '';