mirror of
https://gitlab.com/simple-nixos-mailserver/nixos-mailserver.git
synced 2024-11-11 19:39:16 +05:00
0e6bb4e898
Their CI environment currently doesn't have KVM. This commit should be reverted when/if they do, for much better CI speed. You can still run tests locally on your KVM-enabled machine as documented on the wiki. Workaround on GitLab is several pieces (injected through .gitlab-ci.yml): - Make a /dev/kvm file so that nix thinks we have "kvm" system feature and proceeds with executing the tests. - Inject a QEMU package that replaces qemu-kvm with a full emulator. - Monkey-patch the test script to wait longer for the VM to boot, since it's slow on full emulation. 1200 seconds, double the previous value. The patch method is not bulletproof, but better than maintaining forks of nixpkgs. - Set systemd's DefaultTimeoutStartSec=15min, so nix's "backdoor" test service doesn't time out on the slow boot.
32 lines
1.2 KiB
Nix
32 lines
1.2 KiB
Nix
let
|
|
pkgs = (import <nixpkgs> { system = builtins.currentSystem; config = {}; });
|
|
patchedMachinePM = pkgs.writeTextFile {
|
|
name = "Machine.pm.patched-to-wait-longer-for-vm";
|
|
text = builtins.replaceStrings ["alarm 600;"] ["alarm 1200;"] (builtins.readFile (<nixpkgs>+"/nixos/lib/test-driver/Machine.pm"));
|
|
};
|
|
in
|
|
(pkgs // {
|
|
qemu_test = with pkgs; stdenv.mkDerivation {
|
|
name = "qemu_test_no_kvm";
|
|
buildInputs = [ coreutils qemu_test ];
|
|
inherit qemu_test;
|
|
inherit coreutils;
|
|
builder = builtins.toFile "builder.sh" ''
|
|
PATH=$coreutils/bin:$PATH
|
|
mkdir -p $out/bin
|
|
cp $qemu_test/bin/* $out/bin/
|
|
ln -sf $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} $out/bin/qemu-kvm
|
|
'';
|
|
};
|
|
stdenv = pkgs.stdenv // {
|
|
mkDerivation = args: (pkgs.stdenv.mkDerivation (args // (
|
|
pkgs.lib.optionalAttrs (args.name == "nixos-test-driver") {
|
|
installPhase = args.installPhase + ''
|
|
rm $libDir/Machine.pm
|
|
cp ${patchedMachinePM} $libDir/Machine.pm
|
|
'';
|
|
}
|
|
)));
|
|
};
|
|
})
|