nix: vms for testing ghostty

This commit is contained in:
Jeffrey C. Ollie
2025-01-04 22:26:07 -06:00
parent ff9414d9ea
commit 0b456d14a4
4 changed files with 213 additions and 25 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ test/cases/**/*.actual.png
glad.zip
/Box_test.ppm
/Box_test_diff.ppm
/ghostty.qcow2

View File

@ -31,7 +31,9 @@
zig,
...
}:
builtins.foldl' nixpkgs-stable.lib.recursiveUpdate {} (builtins.map (system: let
builtins.foldl' nixpkgs-stable.lib.recursiveUpdate {} (
builtins.map (
system: let
pkgs-stable = nixpkgs-stable.legacyPackages.${system};
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
in {
@ -57,11 +59,56 @@
formatter.${system} = pkgs-stable.alejandra;
nixosConfigurations = let
makeVM = (
path:
nixpkgs-stable.lib.nixosSystem {
inherit system;
modules = [
{
nixpkgs.overlays = [
self.overlays.debug
];
}
./nix/vm/common.nix
path
];
}
);
in {
"wayland-gnome-${system}" = makeVM ./nix/vm/wayland-gnome.nix;
};
apps.${system} = let
wrapVM = (
name: let
program = pkgs-stable.writeShellScript "run-ghostty-vm" ''
SHARED_DIR=$(pwd)
export SHARED_DIR
${self.nixosConfigurations."${name}-${system}".config.system.build.vm}/bin/run-ghostty-vm
'';
in {
type = "app";
program = "${program}";
}
);
in {
wayland-gnome = wrapVM "wayland-gnome";
};
}
# Our supported systems are the same supported systems as the Zig binaries.
}) (builtins.attrNames zig.packages))
) (builtins.attrNames zig.packages)
)
// {
overlays.default = final: prev: {
ghostty = self.packages.${prev.system}.default;
overlays = {
default = self.overlays.releasefast;
releasefast = final: prev: {
ghostty = self.packages.${prev.system}.ghostty-releasefast;
};
debug = final: prev: {
ghostty = self.packages.${prev.system}.ghostty-debug;
};
};
};

33
nix/vm/common.nix Normal file
View File

@ -0,0 +1,33 @@
{pkgs, ...}: {
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "ghostty";
networking.domain = "mitchellh.com";
virtualisation.vmVariant = {
virtualisation.memorySize = 2048;
};
users.mutableUsers = true;
users.groups.ghostty = {
gid = 1000;
};
users.users.ghostty = {
description = "Ghostty";
uid = 1000;
group = "ghostty";
extraGroups = ["wheel"];
isNormalUser = true;
initialPassword = "ghostty";
};
environment.systemPackages = [
pkgs.kitty
pkgs.ghostty
];
system.stateVersion = "24.11";
}

107
nix/vm/wayland-gnome.nix Normal file
View File

@ -0,0 +1,107 @@
{
config,
lib,
pkgs,
...
}: {
services.displayManager = {
autoLogin = {
user = "ghostty";
};
};
services.xserver = {
enable = true;
displayManager = {
gdm = {
enable = true;
autoSuspend = false;
};
};
desktopManager = {
gnome = {
enable = true;
};
};
};
environment.etc = {
"xdg/autostart/com.mitchellh.ghostty.desktop" = {
source = "${pkgs.ghostty}/share/applications/com.mitchellh.ghostty.desktop";
};
};
environment.systemPackages = [
pkgs.gnomeExtensions.no-overview
];
environment.gnome.excludePackages = with pkgs; [
atomix
cheese
epiphany
geary
gnome-music
gnome-photos
gnome-tour
hitori
iagno
tali
];
system.activationScripts = {
face = {
text = ''
mkdir -p /var/lib/AccountsService/{icons,users}
cp ${pkgs.ghostty}/share/icons/hicolor/1024x1024/apps/com.mitchellh.ghostty.png /var/lib/AccountsService/icons/ghostty
echo -e "[User]\nIcon=/var/lib/AccountsService/icons/ghostty\n" > /var/lib/AccountsService/users/ghostty
chown root:root /var/lib/AccountsService/users/ghostty
chmod 0600 /var/lib/AccountsService/users/ghostty
chown root:root /var/lib/AccountsService/icons/ghostty
chmod 0444 /var/lib/AccountsService/icons/ghostty
'';
};
};
programs.dconf = {
enable = true;
profiles.user.databases = [
{
settings = with lib.gvariant; {
"org/gnome/desktop/background" = {
picture-uri = "file://${pkgs.ghostty}/share/icons/hicolor/512x512/apps/com.mitchellh.ghostty.png";
picture-uri-dark = "file://${pkgs.ghostty}/share/icons/hicolor/512x512/apps/com.mitchellh.ghostty.png";
picture-options = "centered";
primary-color = "#000000000000";
secondary-color = "#000000000000";
};
"org/gnome/desktop/desktop" = {
interface = "prefer-dark";
};
"org/gnome/desktop/notifications" = {
show-in-lock-screen = false;
};
"org/gnome/desktop/screensaver" = {
lock-enabled = false;
picture-uri = "file://${pkgs.ghostty}/share/icons/hicolor/512x512/apps/com.mitchellh.ghostty.png";
picture-options = "centered";
primary-color = "#000000000000";
secondary-color = "#000000000000";
};
"org/gnome/desktop/session" = {
idle-delay = mkUint32 0;
};
"org/gnome/shell" = {
disable-user-extensions = false;
enabled-extensions = builtins.map (x: x.extensionUuid) (
lib.filter (p: p ? extensionUuid) config.environment.systemPackages
);
};
};
}
];
};
}