This commit is contained in:
Andrew Marshall 2024-04-30 22:22:25 -04:00 committed by GitHub
commit 2b692db29f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 1 deletions

View File

@ -269,7 +269,9 @@ let
checkPhase = lib.optionalString cfg.checkConfig ''
export DBUS_SESSION_BUS_ADDRESS=/dev/null
export XDG_RUNTIME_DIR=$(mktemp -d)
${pkgs.xvfb-run}/bin/xvfb-run ${swayPackage}/bin/sway --config "$target" --validate --unsupported-gpu
cp "$target" sway.conf
${cfg.preCheckConfig}
${pkgs.xvfb-run}/bin/xvfb-run ${swayPackage}/bin/sway --config sway.conf --validate --unsupported-gpu
'';
text = concatStringsSep "\n"
@ -478,6 +480,22 @@ in {
description = "Sway configuration options.";
};
preCheckConfig = mkOption {
type = types.lines;
default = "";
example = ''
sed 's/foo/bar/g' -i sway.conf
export HOME=$(mktemp -d)
touch ~/background.png
'';
description = ''
Script to run before running `sway --validate` on the generated config
file. The config file is available as `sway.conf`, and can be
manipulated without affecting the build output. Only used if
`checkConfig = true`.
'';
};
checkConfig = mkOption {
type = types.bool;
default = true;

View File

@ -6,6 +6,7 @@
sway-followmouse = ./sway-followmouse.nix;
sway-followmouse-legacy = ./sway-followmouse-legacy.nix;
sway-check-config = ./sway-check-config.nix;
sway-check-config-precheck = ./sway-check-config-precheck.nix;
sway-modules = ./sway-modules.nix;
sway-no-xwayland = ./sway-no-xwayland.nix;
sway-null-config = ./sway-null-config.nix;

View File

@ -0,0 +1,20 @@
{ config, lib, ... }:
lib.mkIf config.test.enableBig {
wayland.windowManager.sway = {
enable = true;
checkConfig = true;
preCheckConfig = ''
export HOME=$(mktemp -d)
sed 's/mybg/otherbg/g' -i sway.conf
touch ~/otherbg.png
'';
config.output."*".background = "~/mybg.png fill";
};
nmt.script = ''
assertFileExists home-files/.config/sway/config
assertFileRegex home-files/.config/sway/config 'mybg\.png'
assertFileNotRegex home-files/.config/sway/config 'otherbg\.png'
'';
}