forked from nickpiaddo/rsfdisk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.nix
More file actions
89 lines (77 loc) · 2.46 KB
/
test.nix
File metadata and controls
89 lines (77 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11";
pkgs = import nixpkgs { config = {}; overlays = []; };
in
pkgs.testers.runNixOSTest {
name = "rsfdisk";
nodes.vm = {config, pkgs, ...}: {
# QEMU config
virtualisation = {
memorySize = 2048; #MiB
diskSize = 8192; #MiB
sharedDirectories = {
rsfdisk = { source = "${./.}"; target = "/repos/rsfdisk"; };
};
};
environment = {
sessionVariables = {
# Rust source path
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
# Required by `libblkid-sys`
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.libclang ];
# Required by `pkg-config` to discover the locations of `libblkid` and `libmount`
PKG_CONFIG_PATH = "${pkgs.util-linux.dev}/lib/pkgconfig";
# Inspired by: "C header includes in NixOS"
# https://discourse.nixos.org/t/c-header-includes-in-nixos/17410
# Solves the root cause of error messages emitted when trying to
# compile rsfdisk-sys from inside a VM.
# --- stderr
# src/wrapper.h:1:10: fatal error: 'blkid/blkid.h' file not found
C_INCLUDE_PATH="${pkgs.util-linux.dev}/include";
};
};
# For interactive builds
nix = {
# Install Nix Flakes
package = pkgs.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
# Root user
users.users.root = {
password = "";
# Default packages.
packages = with pkgs; [
# For interactive builds
bat
git
htop
vim
# For Rust
cargo
cargo-nextest
cargo-tarpaulin
rustc
rust-analyzer
rustfmt
rustPackages.clippy
clang
libclang.lib
pkg-config
util-linux.dev
];
};
services.getty.autologinUser = "root";
system.stateVersion = "23.11";
};
testScript = ''
vm.wait_for_unit("multi-user.target")
# Copy repos
vm.succeed("rsync -a /repos/rsfdisk /root --exclude .git --exclude .direnv --exclude target --exclude result --exclude web-snapshots --exclude area51 --exclude test-microvm")
# Run tests
#vm.succeed("cd /root/rsfdisk; cargo nextest run; cargo test --doc")
vm.succeed("cd /root/rsfdisk && cargo nextest run")
vm.succeed("cd /root/rsfdisk && cargo test --doc")
'';
}