nix vm: more reusability

This commit is contained in:
Jeffrey C. Ollie
2025-01-07 22:03:04 -06:00
parent e1e2f94681
commit 321119e001
8 changed files with 61 additions and 32 deletions

View File

@ -60,42 +60,18 @@
formatter.${system} = pkgs-stable.alejandra; formatter.${system} = pkgs-stable.alejandra;
apps.${system} = let apps.${system} = let
makeVM = (
path: system: uid: gid:
nixpkgs-stable.lib.nixosSystem {
system = builtins.replaceStrings ["darwin"] ["linux"] system;
modules = [
{
virtualisation.vmVariant = {
virtualisation.host.pkgs = pkgs-stable;
};
nixpkgs.overlays = [
self.overlays.debug
];
users.groups.ghostty = {
gid = gid;
};
users.users.ghostty = {
uid = gid;
};
system.stateVersion = "24.11";
}
./nix/vm/common.nix
path
];
}
);
runVM = ( runVM = (
path: let path: let
vm = import ./nix/vm/create.nix {
inherit system path;
nixpkgs = nixpkgs-stable;
overlay = self.overlays.debug;
};
program = pkgs-stable.writeShellScript "run-ghostty-vm" '' program = pkgs-stable.writeShellScript "run-ghostty-vm" ''
SHARED_DIR=$(pwd) SHARED_DIR=$(pwd)
export SHARED_DIR export SHARED_DIR
${(makeVM path system 1000 1000).config.system.build.vm}/bin/run-ghostty-vm ${vm.config.system.build.vm}/bin/run-ghostty-vm
''; '';
in { in {
type = "app"; type = "app";
@ -124,6 +100,10 @@
ghostty = self.packages.${prev.system}.ghostty-debug; ghostty = self.packages.${prev.system}.ghostty-debug;
}; };
}; };
create-vm = import ./nix/vm/create.nix;
create-cinnamon-vm = import ./nix/vm/create-cinnamon.nix;
create-gnome-vm = import ./nix/vm/create-gnome.nix;
create-plasma6-vm = import ./nix/vm/create-plasma6.nix;
}; };
nixConfig = { nixConfig = {

View File

@ -1,4 +1,8 @@
{...}: { {...}: {
imports = [
./common.nix
];
services.xserver = { services.xserver = {
displayManager = { displayManager = {
lightdm = { lightdm = {

View File

@ -4,6 +4,10 @@
pkgs, pkgs,
... ...
}: { }: {
imports = [
./common.nix
];
services.xserver = { services.xserver = {
displayManager = { displayManager = {
gdm = { gdm = {

View File

@ -1,4 +1,8 @@
{...}: { {...}: {
imports = [
./common.nix
];
services = { services = {
displayManager = { displayManager = {
sddm = { sddm = {

View File

@ -0,0 +1,12 @@
{
system,
nixpkgs,
overlay,
path,
uid ? 1000,
gid ? 1000,
}:
import ./create.nix {
inherit system nixpkgs overlay path uid gid;
common = ./common-cinnamon.nix;
}

12
nix/vm/create-gnome.nix Normal file
View File

@ -0,0 +1,12 @@
{
system,
nixpkgs,
overlay,
path,
uid ? 1000,
gid ? 1000,
}:
import ./create.nix {
inherit system nixpkgs overlay path uid gid;
common = ./common-gnome.nix;
}

12
nix/vm/create-plasma6.nix Normal file
View File

@ -0,0 +1,12 @@
{
system,
nixpkgs,
overlay,
path,
uid ? 1000,
gid ? 1000,
}:
import ./create.nix {
inherit system nixpkgs overlay path uid gid;
common = ./common-plasma6.nix;
}

View File

@ -3,6 +3,7 @@
nixpkgs, nixpkgs,
overlay, overlay,
path, path,
common ? ./common.nix,
uid ? 1000, uid ? 1000,
gid ? 1000, gid ? 1000,
}: let }: let
@ -33,9 +34,9 @@ in
uid = uid; uid = uid;
}; };
system.stateVersion = "24.11"; system.stateVersion = nixpkgs.lib.trivial.release;
} }
./common.nix common
path path
]; ];
} }