Compare commits

...

1 Commits

Author SHA1 Message Date
cameron
dad6f2480d initial test setup 2025-12-19 21:39:04 +00:00
5 changed files with 141 additions and 33 deletions

View File

@@ -17,7 +17,7 @@
rust-overlay,
crane,
...
}:
} @ inputs:
let
systems = [
"x86_64-linux"
@@ -51,6 +51,12 @@
overlays.default = final: _: {
zed-editor = mkZed final;
};
checks = forAllSystems (pkgs: {
simple = (import ./nix/test/simple.nix) {
inherit pkgs;
zed = mkZed pkgs;
};
});
};
nixConfig = {

View File

@@ -15,6 +15,8 @@
protobuf,
nodejs_22,
zig,
livekit,
}:
(mkShell.override { inherit (zed-editor) stdenv; }) {
inputsFrom = [ zed-editor ];
@@ -33,6 +35,8 @@
# we'll just put it on `$PATH`:
nodejs_22
zig
livekit
];
env =

54
nix/test/common.nix Normal file
View File

@@ -0,0 +1,54 @@
{
config,
lib,
...
}: let
cfg = config.test-support;
in {
options.test-support = with lib; {
user = mkOption {
default = "alice";
type = types.str;
};
desktop-environment = mkOption {
default = "icewm";
type = types.enum ["icewm"];
};
};
config = let
de = cfg.desktop-environment;
displayManager =
if de == "icewm"
then "lightdm"
else throw "unreachable";
windowManager =
if de == "icewm"
then "icewm"
else throw "unreachable";
in {
virtualisation.memorySize = lib.mkDefault 2000; # 2gb
services.displayManager.autoLogin.enable = true;
services.displayManager.autoLogin.user = "alice";
services.displayManager.defaultSession =
if de == "icewm"
then "none+icewm"
else null;
services.xserver.enable = true;
services.xserver.windowManager.${windowManager}.enable = true;
services.xserver.displayManager.${displayManager}.enable = true;
environment.sessionVariables = {
"ZED_ALLOW_EMULATED_GPU" = 1;
};
users.users.${cfg.user} = {
createHome = true;
home = "/home/${cfg.user}";
group = "users";
isNormalUser = true;
password = "password";
};
};
}

41
nix/test/simple.nix Normal file
View File

@@ -0,0 +1,41 @@
{
pkgs,
zed,
...
}: let
user = "alice";
run = command: "sudo -u ${user} ${command}";
in
pkgs.testers.runNixOSTest {
name = "simple file reading";
# sshBackdoor.enable = true;
# enableDebugHook = true;
enableOCR = true;
nodes.machine = {config, ...}: {
imports = [./common.nix];
test-support.user = user;
test-support.desktop-environment = "icewm";
environment.systemPackages = [zed];
};
testScript =
/*
python
*/
''
machine.wait_for_x()
machine.succeed("${run "zeditor /home/${user}/foo.md"}")
machine.wait_for_text("foo.md")
machine.send_chars("hello world\n");
machine.wait_for_text("hello world");
machine.send_key("ctrl-s");
machine.wait_for_file("/home/${user}/foo.md");
'';
}

View File

@@ -8,40 +8,43 @@ then maysudo=''
else maysudo="$(command -v sudo || command -v doas || true)"
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Linux dependencies..."
script/linux
else
echo "installing foreman..."
which foreman > /dev/null || brew install foreman
if [[ ! -v OFFLINE ]]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Linux dependencies..."
script/linux
else
echo "installing foreman..."
which foreman > /dev/null || brew install foreman
fi
# Install minio if needed
if ! which minio > /dev/null; then
if command -v brew > /dev/null; then
echo "minio not found. Installing via brew"
brew install minio/stable/minio
elif command -v apt > /dev/null; then
echo "minio not found. Installing via apt from https://dl.min.io/server/minio/release/linux-amd64/minio.deb"
wget -q https://dl.min.io/server/minio/release/linux-amd64/minio.deb -O /tmp/minio.deb
$maysudo apt install /tmp/minio.deb
rm -f /tmp/minio.deb
elif command -v dnf > /dev/null; then
echo "minio not found. Installing via dnf from https://dl.min.io/server/minio/release/linux-amd64/minio.rpm"
wget -q https://dl.min.io/server/minio/release/linux-amd64/minio.rpm -O /tmp/minio.rpm
$maysudo dnf install /tmp/minio.rpm
rm -f /tmp/minio.rpm
else
echo "No supported package manager found (brew, apt, or dnf)"
exit 1
fi
fi
# Install sqlx-cli if needed
if ! [[ "$(command -v sqlx)" && "$(sqlx --version)" == "sqlx-cli 0.7.2" ]]; then
echo "sqlx-cli not found or not the required version, installing version 0.7.2..."
cargo install sqlx-cli --version 0.7.2
fi
fi
# Install minio if needed
if ! which minio > /dev/null; then
if command -v brew > /dev/null; then
echo "minio not found. Installing via brew"
brew install minio/stable/minio
elif command -v apt > /dev/null; then
echo "minio not found. Installing via apt from https://dl.min.io/server/minio/release/linux-amd64/minio.deb"
wget -q https://dl.min.io/server/minio/release/linux-amd64/minio.deb -O /tmp/minio.deb
$maysudo apt install /tmp/minio.deb
rm -f /tmp/minio.deb
elif command -v dnf > /dev/null; then
echo "minio not found. Installing via dnf from https://dl.min.io/server/minio/release/linux-amd64/minio.rpm"
wget -q https://dl.min.io/server/minio/release/linux-amd64/minio.rpm -O /tmp/minio.rpm
$maysudo dnf install /tmp/minio.rpm
rm -f /tmp/minio.rpm
else
echo "No supported package manager found (brew, apt, or dnf)"
exit 1
fi
fi
# Install sqlx-cli if needed
if ! [[ "$(command -v sqlx)" && "$(sqlx --version)" == "sqlx-cli 0.7.2" ]]; then
echo "sqlx-cli not found or not the required version, installing version 0.7.2..."
cargo install sqlx-cli --version 0.7.2
fi
cd crates/collab