mirror of
https://github.com/nix-community/home-manager
synced 2024-12-18 15:59:48 +01:00
sway: check config file validity
Helps avoid successful build but Sway failing to start. To meaningfully test this, I had to actually use `pkgs.sway` in the test rather than the stub, but left all other tests using the stub and changed them to skipping the test. We need to pass `--unsupported-gpu` as Sway checks for `nvidia` in `/proc/modules`, and the Nix sandbox has `/proc/modules` available.
This commit is contained in:
parent
95888b153c
commit
3a435342e2
17 changed files with 46 additions and 5 deletions
|
@ -258,12 +258,21 @@ let
|
|||
|
||||
variables = concatStringsSep " " cfg.systemd.variables;
|
||||
extraCommands = concatStringsSep " && " cfg.systemd.extraCommands;
|
||||
swayPackage = if cfg.package == null then pkgs.sway else cfg.package;
|
||||
systemdActivation = ''
|
||||
exec "${pkgs.dbus}/bin/dbus-update-activation-environment --systemd ${variables}; ${extraCommands}"'';
|
||||
|
||||
configFile = pkgs.writeTextFile {
|
||||
name = "sway.conf";
|
||||
text = (concatStringsSep "\n"
|
||||
|
||||
# Sway always does some init, see https://github.com/swaywm/sway/issues/4691
|
||||
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
|
||||
'';
|
||||
|
||||
text = concatStringsSep "\n"
|
||||
((optional (cfg.extraConfigEarly != "") cfg.extraConfigEarly)
|
||||
++ (if cfg.config != null then
|
||||
with cfg.config;
|
||||
|
@ -319,7 +328,7 @@ let
|
|||
else
|
||||
[ ]) ++ (optional cfg.systemd.enable systemdActivation)
|
||||
++ (optional (!cfg.xwayland) "xwayland disable")
|
||||
++ [ cfg.extraConfig ]));
|
||||
++ [ cfg.extraConfig ]);
|
||||
};
|
||||
|
||||
defaultSwayPackage = pkgs.sway.override {
|
||||
|
@ -469,6 +478,13 @@ in {
|
|||
description = "Sway configuration options.";
|
||||
};
|
||||
|
||||
checkConfig = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description =
|
||||
"If enabled (the default), validates the generated config file.";
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
|
@ -506,9 +522,7 @@ in {
|
|||
home.packages = optional (cfg.package != null) cfg.package
|
||||
++ optional cfg.xwayland pkgs.xwayland;
|
||||
|
||||
xdg.configFile."sway/config" = let
|
||||
swayPackage = if cfg.package == null then pkgs.sway else cfg.package;
|
||||
in {
|
||||
xdg.configFile."sway/config" = {
|
||||
source = configFile;
|
||||
onChange = ''
|
||||
swaySocket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep --uid $UID -x sway || true).sock"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
sway-default = ./sway-default.nix;
|
||||
sway-followmouse = ./sway-followmouse.nix;
|
||||
sway-followmouse-legacy = ./sway-followmouse-legacy.nix;
|
||||
sway-check-config = ./sway-check-config.nix;
|
||||
sway-modules = ./sway-modules.nix;
|
||||
sway-no-xwayland = ./sway-no-xwayland.nix;
|
||||
sway-null-config = ./sway-null-config.nix;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
# overriding findutils causes issues
|
||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
# overriding findutils causes issues
|
||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||
config.bindkeysToCode = true;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
lib.mkIf config.test.enableBig {
|
||||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
checkConfig = true;
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/sway/config
|
||||
'';
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
# overriding findutils causes issues
|
||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
|
||||
config = {
|
||||
focus.followMouse = false;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
|
||||
config = {
|
||||
focus.followMouse = "always";
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
# overriding findutils causes issues
|
||||
config = {
|
||||
menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
config = null;
|
||||
systemd.enable = false;
|
||||
xwayland = false;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
config = null;
|
||||
systemd.enable = false;
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = null;
|
||||
checkConfig = false;
|
||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||
};
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
# overriding findutils causes issues
|
||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
# overriding findutils causes issues
|
||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
# overriding findutils causes issues
|
||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
# overriding findutils causes issues
|
||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||
config.defaultWorkspace = "workspace number 9";
|
||||
|
|
|
@ -15,6 +15,7 @@ in {
|
|||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@sway@"; };
|
||||
checkConfig = false;
|
||||
# overriding findutils causes issues
|
||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||
|
||||
|
|
Loading…
Reference in a new issue