Skip to content

Commit 87694e1

Browse files
committed
Test description for NixOS
1 parent 341ba07 commit 87694e1

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

distro-tests/nixos/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
> incus image copy images:nixos/25.11 local: --alias nixos/25.11 --vm
3+
> incus launch local:nixos/25.11 nixos-vm --vm
4+
> incus stop local:nixos/25.11 nixos-vm
5+
> incus config set nixos-vm limits.memory 3GiB
6+
> incus config set nixos-vm security.secureboot false
7+
> incus start nixos-vm
8+
9+
> incus exec nixos-vm sed -- -i '/imports = \[/a\ ./vuinputd-test-automation.nix' /etc/nixos/configuration.nix
10+
11+
> incus file push vuinputd-test-automation.nix nixos-vm/etc/nixos/vuinputd-test-automation.nix
12+
13+
> incus exec nixos-vm nixos-rebuild -- switch --max-jobs 1
14+
15+
Execute the test
16+
> incus exec nixos-vm bwrap -- --unshare-net --ro-bind / / --tmpfs /tmp --tmpfs /run/udev --dev-bind /run/vuinputd/vuinput/dev-input /dev/input --dev-bind /dev/vuinput /dev/uinput /run/current-system/sw/bin/test-scenarios basic-keyboard
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{ config, pkgs, lib, ... }:
2+
let
3+
vuinputd = pkgs.rustPlatform.buildRustPackage {
4+
pname = "vuinputd";
5+
version = "0.3.2-git";
6+
7+
buildType = "debug";
8+
9+
nativeBuildInputs = [
10+
pkgs.pkg-config
11+
pkgs.rustPlatform.bindgenHook
12+
# breakpointHook
13+
];
14+
15+
buildInputs = [pkgs.udev pkgs.fuse3];
16+
17+
src = pkgs.fetchFromGitHub {
18+
owner = "joleuger";
19+
repo = "vuinputd";
20+
rev = "8c40fdc12005319ea16dceb752a8822abfc6039a";
21+
hash = "sha256-8Q34B04BngZqRLyixeFq8F1t5wFnk6JpaG3EEbgKRcU=";
22+
};
23+
24+
cargoHash = "sha256-nJw9bRh6Yn9g1H5SeoT6zxgZLCqV3AtAs9gMfE+P+CU=";
25+
26+
# Recent versions of fuse3 can also have libfuse_* types
27+
postPatch = ''
28+
substituteInPlace cuse-lowlevel/build.rs \
29+
--replace-fail '.allowlist_type("(?i)^fuse.*")' '.allowlist_type("(?i)^(fuse|libfuse).*")'
30+
'';
31+
32+
postInstall = ''
33+
mkdir -p $out/lib/udev/rules.d
34+
mkdir $out/lib/udev/hwdb.d
35+
cp vuinputd/udev/*.rules $out/lib/udev/rules.d/
36+
cp vuinputd/udev/*.hwdb $out/lib/udev/hwdb.d/
37+
'';
38+
};
39+
in
40+
{
41+
environment.systemPackages = with pkgs; [
42+
vim
43+
pkg-config
44+
udev
45+
fuse3
46+
git
47+
rustc
48+
cargo
49+
bubblewrap # for testing
50+
51+
vuinputd
52+
];
53+
54+
systemd.services.vuinputd = {
55+
enable = true;
56+
wantedBy = ["multi-user.target"];
57+
unitConfig = {
58+
Description = "Virtual input (/dev/vuinput) daemon";
59+
};
60+
serviceConfig = {
61+
Type = "exec";
62+
ExecStartPre = pkgs.writeShellScript "mount-tmpfs-dev-input" ''
63+
mkdir -p /run/vuinputd/vuinput/dev-input
64+
${pkgs.util-linux}/bin/mount -t tmpfs -o rw,dev,nosuid tpmfs /run/vuinputd/vuinput/dev-input
65+
'';
66+
ExecStart = "${lib.getExe vuinputd} --major 120 --minor 414795 --placement on-host";
67+
ExecStopPost = pkgs.writeShellScript "umount-dev-input" ''
68+
${pkgs.util-linux}/bin/umount /run/vuinputd/vuinput/dev-input
69+
'';
70+
Restart = "on-failure";
71+
DeviceAllow = "char-* rwm";
72+
73+
Environment = [
74+
"RUST_LOG=debug"
75+
];
76+
};
77+
};
78+
systemd.services.vuinputd-chmod = {
79+
unitConfig.Description = "Chmod 666 the /dev/vuinput";
80+
wantedBy = ["vuinputd.service"];
81+
after = ["vuinputd.service"];
82+
83+
serviceConfig = {
84+
ExecStart = pkgs.writeShellScript "chmod-vuinput" ''
85+
sleep 2 && chmod 666 /dev/vuinput
86+
'';
87+
};
88+
};
89+
}
90+

0 commit comments

Comments
 (0)