replace multiway if with pkgs.stdenv.hostPlatform.qemuArch

This commit is contained in:
Daniel Barlow 2023-11-05 11:40:26 +00:00
parent 92b9bf959e
commit 629624bb25

View file

@ -7,12 +7,6 @@
let let
inherit (lib) mkOption types concatStringsSep; inherit (lib) mkOption types concatStringsSep;
inherit (pkgs) liminix callPackage writeText; inherit (pkgs) liminix callPackage writeText;
arch = let s = pkgs.stdenv; in
if s.isAarch64
then "aarch64"
else if s.isMips
then "mips"
else throw "can't determine arch";
in in
{ {
imports = [ imports = [
@ -87,8 +81,8 @@ in
let let
cmdline = builtins.toJSON (concatStringsSep " " config.boot.commandLine); cmdline = builtins.toJSON (concatStringsSep " " config.boot.commandLine);
makeBootableImage = pkgs.runCommandCC "objcopy" {} makeBootableImage = pkgs.runCommandCC "objcopy" {}
(if pkgs.stdenv.isAarch64 (if pkgs.stdenv.hostPlatform.isAarch
then "${pkgs.stdenv.cc.targetPrefix}objcopy -O binary -S ${kernel} $out" then "${pkgs.stdenv.cc.targetPrefix}objcopy -O binary -R .comment -S ${kernel} $out"
else "cp ${kernel} $out"); else "cp ${kernel} $out");
in pkgs.runCommandCC "vmroot" {} '' in pkgs.runCommandCC "vmroot" {} ''
mkdir $out mkdir $out
@ -100,7 +94,7 @@ in
echo ${cmdline} > commandline echo ${cmdline} > commandline
cat > run.sh << EOF cat > run.sh << EOF
#!${pkgs.runtimeShell} #!${pkgs.runtimeShell}
CMDLINE=${cmdline} ${pkgs.pkgsBuildBuild.run-liminix-vm}/bin/run-liminix-vm --arch ${arch} \$* ${makeBootableImage} ${config.system.outputs.rootfs} CMDLINE=${cmdline} ${pkgs.pkgsBuildBuild.run-liminix-vm}/bin/run-liminix-vm --arch ${pkgs.stdenv.hostPlatform.qemuArch} \$* ${makeBootableImage} ${config.system.outputs.rootfs}
EOF EOF
chmod +x run.sh chmod +x run.sh
''; '';