stylix: revert improval of how discord testbed is disabled (#1291)

Revert the improval of how discord testbed is disabled to get the proper
commit structure into the commit history.

Reverts: 5113479d69 ("stylix: improve how discord testbed is disabled (#1291)")
This commit is contained in:
NAHO 2025-05-21 11:06:06 +02:00 committed by GitHub
parent 5113479d69
commit dfcab7476d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 91 deletions

View file

@ -7,28 +7,46 @@
{
perSystem =
{ pkgs, config, ... }:
{
pkgs,
system,
config,
...
}:
{
# Build all packages with 'nix flake check' instead of only verifying they
# are derivations.
checks = config.packages;
packages = lib.mkMerge [
# Testbeds are virtual machines based on NixOS, therefore they are
# only available for Linux systems.
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux (
import "${self}/stylix/testbed.nix" {
packages =
let
testbedPackages = import "${self}/stylix/testbed.nix" {
inherit pkgs inputs lib;
}
))
{
docs = pkgs.callPackage "${self}/doc" {
inherit inputs;
inherit (inputs.nixpkgs.lib) nixosSystem;
inherit (inputs.home-manager.lib) homeManagerConfiguration;
};
palette-generator = pkgs.callPackage "${self}/palette-generator" { };
}
];
# Discord is not available on arm64. This workaround filters out
# testbeds using that package, until we have a better way to handle
# this.
testbedPackages' =
if system == "aarch64-linux" then
lib.filterAttrs (
name: _: !lib.hasPrefix "testbed:discord:vencord" name
) testbedPackages
else
testbedPackages;
in
lib.mkMerge [
# Testbeds are virtual machines based on NixOS, therefore they are
# only available for Linux systems.
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux testbedPackages')
{
docs = pkgs.callPackage "${self}/doc" {
inherit inputs;
inherit (inputs.nixpkgs.lib) nixosSystem;
inherit (inputs.home-manager.lib) homeManagerConfiguration;
};
palette-generator = pkgs.callPackage "${self}/palette-generator" { };
}
];
};
}

View file

@ -6,14 +6,9 @@ let
};
in
{
stylix.testbed = {
# Discord is not available on arm64.
enable = lib.meta.availableOn pkgs.stdenv.hostPlatform package;
ui.application = {
name = "discord";
inherit package;
};
stylix.testbed.ui.application = {
name = "discord";
inherit package;
};
environment.systemPackages = [ package ];

View file

@ -37,36 +37,6 @@ let
};
};
enableModule =
{ lib, config, ... }:
{
options.stylix.testbed.enable = lib.mkOption {
type = lib.types.bool;
default = true;
example = lib.literalExpression "lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.discord";
description = ''
Whether to enable this testbed.
The testbed will not be included as a flake output if set to false.
> [!CAUTION]
>
> This option can only access `lib` and `pkgs` inputs. Attempting to
> read other inputs, like `config` or `options`, will cause the
> testbed evaluation to fail.
>
> This is a performance-driven restriction, as noted in `isEnabled`.
'';
};
config.assertions = [
{
assertion = config.stylix.testbed.enable;
message = "Building a disabled testbed. This testbed should have been filtered out!";
}
];
};
applicationModule =
{ config, lib, ... }:
{
@ -183,41 +153,16 @@ let
};
};
# Creates a minimal configuration to extract the `stylix.testbed.enable`
# option value.
#
# This is for performance reasons. Primarily, to avoid fully evaluating
# testbed system configurations to determine flake outputs.
# E.g., when running `nix flake show`.
isEnabled =
module:
let
minimal = lib.evalModules {
modules = [
module
enableModule
{ _module.check = false; }
{ _module.args = { inherit pkgs; }; }
];
};
in
minimal.config.stylix.testbed.enable;
autoload =
let
directory = "testbeds";
modules = "${inputs.self}/modules";
in
lib.pipe modules [
builtins.readDir
builtins.attrNames
(builtins.concatMap (
module:
lib.flatten (
lib.mapAttrsToList (
module: _:
let
testbeds = "${modules}/${module}/${directory}";
files = lib.optionalAttrs (builtins.pathExists testbeds) (
builtins.readDir testbeds
);
in
lib.mapAttrsToList (
testbed: type:
@ -237,15 +182,15 @@ let
name = lib.removeSuffix ".nix" testbed;
path = "${testbeds}/${testbed}";
}
) files
))
];
) (lib.optionalAttrs (builtins.pathExists testbeds) (builtins.readDir testbeds))
) (builtins.readDir modules)
);
makeTestbed =
testbed: stylix:
let
name =
lib.concatMapStringsSep testbedFieldSeparator
name = builtins.concatStringsSep testbedFieldSeparator (
map
(
field:
lib.throwIf (lib.hasInfix testbedFieldSeparator field)
@ -260,14 +205,14 @@ let
"image${lib.optionalString (stylix.image or null == null) "less"}"
"scheme${lib.optionalString (stylix.base16Scheme or null == null) "less"}"
"cursor${lib.optionalString (stylix.cursor or null == null) "less"}"
];
]
);
system = lib.nixosSystem {
inherit (pkgs) system;
modules = [
commonModule
enableModule
applicationModule
inputs.self.nixosModules.stylix
inputs.home-manager.nixosModules.home-manager
@ -299,7 +244,7 @@ let
'';
};
in
lib.optionalAttrs (isEnabled testbed.path) {
{
${name} = script;
};
@ -361,5 +306,5 @@ in
# Testbeds are merged using lib.attrsets.unionOfDisjoint to throw an error if
# testbed names collide.
builtins.foldl' lib.attrsets.unionOfDisjoint { } (
builtins.concatMap makeTestbeds autoload
lib.flatten (map makeTestbeds autoload)
)