refactor: update devshell.nix so a usable "fake" quickemu is created

`direnv reload` create a monkey patched `.direnv/bin/quickemu` so testing `quickemu` with secure boot is possible.
This commit is contained in:
Martin Wimpress 2024-06-27 00:35:02 +01:00 committed by Martin Wimpress
parent 5f8c40f7ab
commit faccbae06a
1 changed files with 26 additions and 40 deletions

View File

@ -1,64 +1,50 @@
{ { lib,
lib,
mkShell, mkShell,
pkgs,
stdenv, stdenv,
cdrtools,
curl,
gawk,
git,
glxinfo,
gnugrep,
gnused,
jq,
ncurses,
nixpkgs-fmt,
pciutils,
procps,
python3,
qemu,
socat,
spice-gtk,
swtpm,
unzip,
usbutils,
util-linux,
xdg-user-dirs,
xrandr,
zsync,
OVMF,
OVMFFull,
}: }:
mkShell { mkShell {
strictDeps = true; packages = with pkgs; ([
nativeBuildInputs = [
cdrtools cdrtools
curl curl
gawk gawk
git
gnugrep gnugrep
gnused gnused
jq jq
ncurses ncurses
nixpkgs-fmt
procps
pciutils pciutils
procps
python3 python3
qemu qemu
socat socat
spice-gtk spice-gtk
swtpm
unzip unzip
util-linux util-linux
xrandr xorg.xrandr
] ++ lib.optionals stdenv.isLinux [
glxinfo
swtpm
usbutils
xdg-user-dirs
zsync zsync
OVMF OVMF
OVMFFull OVMFFull
] ++ lib.optionals stdenv.isLinux [
glxinfo
usbutils
xdg-user-dirs
]);
inputsFrom = with pkgs; [
git
]; ];
buildInputs = []; shellHook = ''
echo "**********************************************************************"
echo "* 'direnv reload' to update '.direnv/bin/quickemu' for testing *"
echo "**********************************************************************"
sed \
-e '/OVMF_CODE_4M.secboot.fd/s|ovmfs=(|ovmfs=("${pkgs.OVMFFull.firmware}","${pkgs.OVMFFull.variables}" |' \
-e '/OVMF_CODE_4M.fd/s|ovmfs=(|ovmfs=("${pkgs.OVMF.firmware}","${pkgs.OVMF.variables}" |' \
-e '/cp "''${VARS_IN}" "''${VARS_OUT}"/a chmod +w "''${VARS_OUT}"' \
-e 's/Icon=.*qemu.svg/Icon=qemu/' \
quickemu > $PWD/.direnv/bin/quickemu
chmod +x $PWD/.direnv/bin/quickemu
'';
} }