Apparently `../modules` is creating a separate derivation that contains only that folder, so it's now separate from the flake source. But this transient derivation isn't mentioned explicitly anywhere in the flake outputs. It makes it impossible to target those modules in `disabledModules` directive. For example, after this change is applied, users can solve issues like https://github.com/danth/stylix/issues/577 locally, by just adding the following snippet to their configuration: disabledModules = [ "${inputs.stylix}/modules/regreet/nixos.nix" ]; Reviewed-by: Daniel Thwaites <danthwaites30@btinternet.com> Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
107 lines
3.1 KiB
Nix
107 lines
3.1 KiB
Nix
{ pkgs, inputs, lib, ... }:
|
|
|
|
let
|
|
username = "guest";
|
|
|
|
commonModule = { config, ... }: {
|
|
users.users.${username} = {
|
|
description = "Guest";
|
|
hashedPassword = "";
|
|
isNormalUser = true;
|
|
extraGroups = [ "wheel" ];
|
|
};
|
|
|
|
security.sudo.wheelNeedsPassword = false;
|
|
|
|
# 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 = "${inputs.self}/modules/${name}/testbed.nix";
|
|
};
|
|
in
|
|
lib.optional (builtins.pathExists testbed.module) testbed
|
|
)
|
|
(builtins.readDir "${inputs.self}/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) [
|
|
{
|
|
enable = true;
|
|
image = pkgs.fetchurl {
|
|
name = "three-bicycles.jpg";
|
|
url = "https://unsplash.com/photos/hwLAI5lRhdM/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzYxNDcwfA&force=true";
|
|
hash = "sha256-S0MumuBGJulUekoGI2oZfUa/50Jw0ZzkqDDu1nRkFUA=";
|
|
};
|
|
base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-latte.yaml";
|
|
polarity = "light";
|
|
}
|
|
{
|
|
enable = true;
|
|
image = pkgs.fetchurl {
|
|
name = "mountains.jpg";
|
|
url = "https://unsplash.com/photos/ZqLeQDjY6fY/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzY1NDY4fA&force=true";
|
|
hash = "sha256-Dm/0nKiTFOzNtSiARnVg7zM0J1o+EuIdUQ3OAuasM58=";
|
|
};
|
|
base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml";
|
|
polarity = "dark";
|
|
}
|
|
];
|
|
|
|
in
|
|
lib.listToAttrs (lib.flatten (map makeTestbeds autoload))
|