diff --git a/flake.nix b/flake.nix index 81e9b422c..b3cd77087 100644 --- a/flake.nix +++ b/flake.nix @@ -60,42 +60,18 @@ formatter.${system} = pkgs-stable.alejandra; 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 = ( 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" '' SHARED_DIR=$(pwd) 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 { type = "app"; @@ -124,6 +100,10 @@ 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 = { diff --git a/nix/vm/common-cinnamon.nix b/nix/vm/common-cinnamon.nix index a551321cf..dabe5e701 100644 --- a/nix/vm/common-cinnamon.nix +++ b/nix/vm/common-cinnamon.nix @@ -1,4 +1,8 @@ {...}: { + imports = [ + ./common.nix + ]; + services.xserver = { displayManager = { lightdm = { diff --git a/nix/vm/common-gnome.nix b/nix/vm/common-gnome.nix index d43f5dc9e..0c2bef150 100644 --- a/nix/vm/common-gnome.nix +++ b/nix/vm/common-gnome.nix @@ -4,6 +4,10 @@ pkgs, ... }: { + imports = [ + ./common.nix + ]; + services.xserver = { displayManager = { gdm = { diff --git a/nix/vm/common-plasma6.nix b/nix/vm/common-plasma6.nix index 3b280184c..e5c9bd4d8 100644 --- a/nix/vm/common-plasma6.nix +++ b/nix/vm/common-plasma6.nix @@ -1,4 +1,8 @@ {...}: { + imports = [ + ./common.nix + ]; + services = { displayManager = { sddm = { diff --git a/nix/vm/create-cinnamon.nix b/nix/vm/create-cinnamon.nix new file mode 100644 index 000000000..0efd3c72c --- /dev/null +++ b/nix/vm/create-cinnamon.nix @@ -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; +} diff --git a/nix/vm/create-gnome.nix b/nix/vm/create-gnome.nix new file mode 100644 index 000000000..9fb7f3914 --- /dev/null +++ b/nix/vm/create-gnome.nix @@ -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; +} diff --git a/nix/vm/create-plasma6.nix b/nix/vm/create-plasma6.nix new file mode 100644 index 000000000..47785899f --- /dev/null +++ b/nix/vm/create-plasma6.nix @@ -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; +} diff --git a/nix/vm/create.nix b/nix/vm/create.nix index 8aea5d19d..4481d4345 100644 --- a/nix/vm/create.nix +++ b/nix/vm/create.nix @@ -3,6 +3,7 @@ nixpkgs, overlay, path, + common ? ./common.nix, uid ? 1000, gid ? 1000, }: let @@ -33,9 +34,9 @@ in uid = uid; }; - system.stateVersion = "24.11"; + system.stateVersion = nixpkgs.lib.trivial.release; } - ./common.nix + common path ]; }