about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2024-04-23 19:49:23 +0200
committerJörg Thalheim <joerg@thalheim.io>2024-04-23 20:05:26 +0200
commita4a18f7b9263b56e3b7f7af51efc7a7585058ade (patch)
tree95623d9058e8cce6116d3d8aa3e33b93f7ccf657 /nixos/modules
parent71b4a603862e715bac080d0f2e4362813d8c70c3 (diff)
nixos/systemd-boot: avoid expensive mypy builds on configuration changes
* Mypy dependencies pull in quite a few packages, which makes it harder to create offline installers.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix26
1 files changed, 14 insertions, 12 deletions
diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
index 8b218cf1a6b2f..02540c362d318 100644
--- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
+++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
@@ -7,8 +7,20 @@ let
 
   efi = config.boot.loader.efi;
 
+  # We check the source code in a derivation that does not depend on the
+  # system configuration so that most users don't have to redo the check and require
+  # the necessary dependencies.
+  checkedSource = pkgs.runCommand "systemd-boot" { } ''
+    install -m755 -D ${./systemd-boot-builder.py} $out
+    ${lib.getExe pkgs.buildPackages.mypy} \
+      --no-implicit-optional \
+      --disallow-untyped-calls \
+      --disallow-untyped-defs \
+      $out
+  '';
+
   systemdBootBuilder = pkgs.substituteAll rec {
-    src = ./systemd-boot-builder.py;
+    src = checkedSource;
 
     isExecutable = true;
 
@@ -66,19 +78,9 @@ let
     '';
   };
 
-  checkedSystemdBootBuilder = pkgs.runCommand "systemd-boot" { } ''
-    mkdir -p $out/bin
-    install -m755 ${systemdBootBuilder} $out/bin/systemd-boot-builder
-    ${lib.getExe pkgs.buildPackages.mypy} \
-      --no-implicit-optional \
-      --disallow-untyped-calls \
-      --disallow-untyped-defs \
-      $out/bin/systemd-boot-builder
-  '';
-
   finalSystemdBootBuilder = pkgs.writeScript "install-systemd-boot.sh" ''
     #!${pkgs.runtimeShell}
-    ${checkedSystemdBootBuilder}/bin/systemd-boot-builder "$@"
+    ${systemdBootBuilder} "$@"
     ${cfg.extraInstallCommands}
   '';
 in {