-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stylix: add testbeds for desktop environments (#320)
Co-authored-by: NAHO <[email protected]>
- Loading branch information
Showing
5 changed files
with
128 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
services.xserver = { | ||
enable = true; | ||
desktopManager.gnome.enable = true; | ||
displayManager.gdm.enable = true; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
services.xserver = { | ||
enable = true; | ||
desktopManager.plasma5.enable = true; | ||
displayManager.sddm.enable = true; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ pkgs, inputs, lib, ... }: | ||
|
||
let | ||
username = "guest"; | ||
|
||
commonModule = { config, ... }: { | ||
users.users.${username} = { | ||
description = "Guest"; | ||
hashedPassword = ""; | ||
isNormalUser = true; | ||
}; | ||
|
||
# The state version can safely track the latest release because the disk | ||
# image is ephermal. | ||
system.stateVersion = config.system.nixos.release; | ||
home-manager.users.${username}.home.stateVersion = config.system.nixos.release; | ||
|
||
virtualisation.vmVariant.virtualisation = { | ||
# This is a maximum limit; the VM should still work if the host has fewer cores. | ||
cores = 4; | ||
memorySize = lib.mkDefault 2048; | ||
}; | ||
}; | ||
|
||
autoload = builtins.concatLists | ||
(lib.mapAttrsToList | ||
(name: _: | ||
let testbed = { | ||
inherit name; | ||
module = "${../modules}/${name}/testbed.nix"; | ||
}; | ||
in | ||
lib.optional (builtins.pathExists testbed.module) testbed | ||
) | ||
(builtins.readDir ../modules)); | ||
|
||
makeTestbed = | ||
testbed: stylix: | ||
let | ||
name = "testbed-${testbed.name}-${stylix.polarity}"; | ||
|
||
system = lib.nixosSystem { | ||
inherit (pkgs) system; | ||
|
||
modules = [ | ||
commonModule | ||
inputs.self.nixosModules.stylix | ||
inputs.home-manager.nixosModules.home-manager | ||
testbed.module | ||
|
||
{ | ||
inherit stylix; | ||
system.name = name; | ||
} | ||
]; | ||
}; | ||
|
||
script = pkgs.writeShellApplication { | ||
inherit name; | ||
text = '' | ||
cleanup() { | ||
if rm --recursive "$directory"; then | ||
printf '%s\n' 'Virtualisation disk image removed.' | ||
fi | ||
} | ||
# We create a temporary directory rather than a temporary file, since | ||
# temporary files are created empty and are not valid disk images. | ||
directory="$(mktemp --directory)" | ||
trap cleanup EXIT | ||
NIX_DISK_IMAGE="$directory/nixos.qcow2" \ | ||
${lib.getExe system.config.system.build.vm} | ||
''; | ||
}; | ||
in | ||
lib.nameValuePair name script; | ||
|
||
# This generates a copy of each testbed for each of the following themes. | ||
makeTestbeds = testbed: map (makeTestbed testbed) [ | ||
{ | ||
image = "${pkgs.pantheon.elementary-wallpapers}/share/backgrounds/Photo of Valley.jpg"; | ||
base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-latte.yaml"; | ||
polarity = "light"; | ||
} | ||
{ | ||
image = "${pkgs.pantheon.elementary-wallpapers}/share/backgrounds/Snow-Capped Mountain.jpg"; | ||
base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml"; | ||
polarity = "dark"; | ||
} | ||
]; | ||
|
||
in | ||
lib.listToAttrs (lib.flatten (map makeTestbeds autoload)) |