From 89909fa8e455be7ff25d81403156a54280559797 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 16 Mar 2022 21:50:20 +0100 Subject: [PATCH] rpi-netboot: move tftproot from flake.nix into module --- flake.nix | 21 ++++++--------------- modules/rpi-netboot.nix | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/flake.nix b/flake.nix index 53fb112d..7d9e5513 100644 --- a/flake.nix +++ b/flake.nix @@ -205,21 +205,8 @@ meta.mainProgram = "run-${host}-vm"; }); } // - nixpkgs.lib.optionalAttrs config.boot.loader.raspberryPi.enable { - "${host}-boot" = pkgs.runCommand "tftproot" {} '' - mkdir -p $out - cp -rs ${pkgs.raspberrypifw}/share/raspberrypi/boot/* $out/ - rm -f $out/kernel8.img $out/initrd.img - ln -s ${config.system.build.kernel}/Image $out/kernel8.img - ln -s ${config.system.build.initialRamdisk}/initrd $out/initrd.img - cat << EOF > $out/config.txt - kernel=kernel8.img - initramfs initrd.img followkernel - gpu_mem=64 - arm_64bit=1 - EOF - echo "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 verbose init=${config.system.build.toplevel}/init" > $out/cmdline.txt - ''; + nixpkgs.lib.optionalAttrs (config.system.build ? tftproot) { + "${host}-tftproot" = config.system.build.tftproot; } ) {} (builtins.attrNames self.nixosConfigurations) ) self.legacyPackages; @@ -550,6 +537,10 @@ ) (builtins.mapAttrs (_: nixosSystem: nixosSystem.config.system.build.toplevel ) self.nixosConfigurations) + // + nixpkgs.lib.filterAttrs (name: _: + builtins.match ".+-tftproot" name != null + ) self.packages.${system} ) ); }; diff --git a/modules/rpi-netboot.nix b/modules/rpi-netboot.nix index ab45e57b..b995687d 100644 --- a/modules/rpi-netboot.nix +++ b/modules/rpi-netboot.nix @@ -1,4 +1,4 @@ -{ hostRegistry, pkgs, lib, ... }: +{ hostRegistry, config, pkgs, lib, ... }: { boot = { loader.raspberryPi = { @@ -59,4 +59,19 @@ services.journald.extraConfig = '' Storage=volatile ''; + + system.build.tftproot = pkgs.runCommand "tftproot-${config.networking.hostName}" {} '' + mkdir -p $out + cp -rs ${pkgs.raspberrypifw}/share/raspberrypi/boot/* $out/ + rm -f $out/kernel8.img $out/initrd.img + ln -s ${config.system.build.kernel}/Image $out/kernel8.img + ln -s ${config.system.build.initialRamdisk}/initrd $out/initrd.img + cat << EOF > $out/config.txt + kernel=kernel8.img + initramfs initrd.img followkernel + gpu_mem=64 + arm_64bit=1 + EOF + echo "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 verbose init=${config.system.build.toplevel}/init" > $out/cmdline.txt + ''; }