idrisr
June 23, 2023, 2:06pm
1
I’m trying to build a version of qemu for the lm-32
target, which is no longer available in the current qemu.
Using this flake flake.nix · GitHub I get the error.
ninja: error: loading 'build.ninja': No such file or directory
The full log from nix build
is here: https://termbin.com/0l1r
I tried doing nix develop
, and after doing the unPackphase
and running ./configure --target-list=lm32-softmmu"
, I can cd build; buidPhase
and the build stage continues on.
How can I fix this derivation so it builds?
{
inputs.nixpkgs.url = "nixpkgs";
description = "qemu with lm32";
outputs = { self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
qemu52 = with pkgs;
stdenv.mkDerivation {
name = "qemu52";
src = fetchurl {
url = "https://download.qemu.org/qemu-5.2.0.tar.xz";
hash = "sha256-yxjYibYo++Y3ZysDJnidmw47gCfgRFuTZTfHhUnfF7w=";
};
configurePhase = "./configure --target-list=lm32-softmmu";
buildInputs = [ pixman glib pkg-config python3 ninja ];
};
in {
apps.${system} = { };
packages.${system} = { default = qemu52; };
devShells.${system} = { default = qemu52; };
};
}
greetings!
there are many ways to achieve that, here is I think the quickest
clone nixpkgs repo
git checkout 08adc0781104813a3d44936ab7c318b751aa43c0 # last commit for qemu 5.2.0
then edit qemu
git diff
diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix
index c3484a3312c..d7c11441422 100644
--- a/pkgs/applications/virtualization/qemu/default.nix
+++ b/pkgs/applications/virtualization/qemu/default.nix
@@ -241,19 +241,20 @@ stdenv.mkDerivation rec {
'';
configureFlags =
- [ "--audio-drv-list=${audio}"
+ [
+ "--audio-drv-list=${audio}"
"--enable-docs"
"--enable-tools"
"--enable-guest-agent"
"--localstatedir=/var"
"--sysconfdir=/etc"
+ "--target-list=lm32-softmmu"
]
++ optional numaSupport "--enable-numa"
++ optional seccompSupport "--enable-seccomp"
++ optional smartcardSupport "--enable-smartcard"
++ optional spiceSupport "--enable-spice"
++ optional usbredirSupport "--enable-usb-redir"
- ++ optional (hostCpuTargets != null) "--target-list=${lib.concatStringsSep "," hostCpuTargets}"
++ optional stdenv.isDarwin "--enable-cocoa"
++ optional stdenv.isDarwin "--enable-hvf"
++ optional stdenv.isLinux "--enable-linux-aio"
nix-build -A qemu
/nix/store/jljiv3cv7wnyqcazhi8hgva3403by2a8-qemu-5.2.0
ls result/bin/
elf2dmp qemu-edid qemu-ga qemu-img qemu-io qemu-nbd qemu-pr-helper qemu-storage-daemon qemu-system-lm32
hopefully this helps, feel free to reach out if you want to try this in less hacky way
2 Likes
idrisr
June 24, 2023, 12:12pm
3
You gave me a hint that I needed! At first I tried the patch approach and using an overlay, but then realized that would not work as the patch was for the nix file, and not for a source file. Then I realized I could do a simple override like so:
Thank you for your help!
{
inputs.nixpkgs.url =
"github:nixos/nixpkgs/08adc0781104813a3d44936ab7c318b751aa43c0";
description = "qemu with lm32";
outputs = { self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
qemu = pkgs.qemu.override { hostCpuTargets = [ "lm32-softmmu" ]; };
in {
packages.${system} = { default = qemu; };
devShells.${system} = { default = qemu; };
};
}
2 Likes
glad you got it sorted !
as a bonus, you can add that nixpks commit as second input to your flake so rest of your system is build from nixpkgs of your choice, and only qemu from nixpkgs from that old commit
edit: i realised that you dont you that flake to build nixos system so ignore my comment