From 8d1438c222e20e20195c2e2e48d63b2b535ac482 Mon Sep 17 00:00:00 2001 From: Louis Dalibard Date: Tue, 24 Dec 2024 16:10:16 +0100 Subject: [PATCH] yes --- stylix/testbed.nix | 141 +++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 69 deletions(-) diff --git a/stylix/testbed.nix b/stylix/testbed.nix index c5b7c1a..ec7de24 100644 --- a/stylix/testbed.nix +++ b/stylix/testbed.nix @@ -1,14 +1,17 @@ -{ pkgs, inputs, lib, ... }: - -let +{ + pkgs, + inputs, + lib, + ... +}: let username = "guest"; - commonModule = { config, ... }: { + commonModule = {config, ...}: { users.users.${username} = { description = "Guest"; hashedPassword = ""; isNormalUser = true; - extraGroups = [ "wheel" ]; + extraGroups = ["wheel"]; }; security.sudo.wheelNeedsPassword = false; @@ -25,83 +28,83 @@ let }; }; - autoload = builtins.concatLists + autoload = + builtins.concatLists (lib.mapAttrsToList - (name: _: - let testbed = { - inherit name; - module = "${inputs.self}/modules/${name}/testbed.nix"; - }; + ( + 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}"; + makeTestbed = testbed: stylix: let + name = "testbed-${testbed.name}-${stylix.polarity}"; - system = lib.nixosSystem { - inherit (pkgs) system; + system = lib.nixosSystem { + inherit (pkgs) system; - modules = [ - commonModule - inputs.self.nixosModules.stylix - inputs.home-manager.nixosModules.home-manager - testbed.module + modules = [ + commonModule + inputs.self.nixosModules.stylix + inputs.home-manager.nixosModules.home-manager + testbed.module - { - inherit stylix; - system.name = name; - } - ]; - }; + { + 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 - } + 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 + # 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; + 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"; - } - ]; - + 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.force = "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.force = "dark"; + } + ]; in lib.listToAttrs (lib.flatten (map makeTestbeds autoload))