mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 05:03:09 +00:00
Fix eval errors when i3 or sway null configs are null (#1989)
This commit is contained in:
parent
ff959fd49a
commit
b2dec35b86
17 changed files with 116 additions and 133 deletions
|
@ -258,14 +258,14 @@ in {
|
||||||
mkDefault (if (cfg.config.gaps != null) then pkgs.i3-gaps else pkgs.i3);
|
mkDefault (if (cfg.config.gaps != null) then pkgs.i3-gaps else pkgs.i3);
|
||||||
})
|
})
|
||||||
|
|
||||||
{
|
(mkIf (cfg.config != null) {
|
||||||
warnings = (optional (isList cfg.config.fonts)
|
warnings = (optional (isList cfg.config.fonts)
|
||||||
"Specifying i3.config.fonts as a list is deprecated. Use the attrset version instead.")
|
"Specifying i3.config.fonts as a list is deprecated. Use the attrset version instead.")
|
||||||
++ flatten (map (b:
|
++ flatten (map (b:
|
||||||
optional (isList b.fonts)
|
optional (isList b.fonts)
|
||||||
"Specifying i3.config.bars[].fonts as a list is deprecated. Use the attrset version instead.")
|
"Specifying i3.config.bars[].fonts as a list is deprecated. Use the attrset version instead.")
|
||||||
cfg.config.bars);
|
cfg.config.bars);
|
||||||
}
|
})
|
||||||
|
|
||||||
(mkIf (cfg.config != null
|
(mkIf (cfg.config != null
|
||||||
&& (any (s: s.workspace != null) cfg.config.startup)) {
|
&& (any (s: s.workspace != null) cfg.config.startup)) {
|
||||||
|
|
|
@ -410,34 +410,38 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable (mkMerge [
|
||||||
warnings = (optional (isList cfg.config.fonts)
|
(mkIf (cfg.config != null) {
|
||||||
"Specifying sway.config.fonts as a list is deprecated. Use the attrset version instead.")
|
warnings = (optional (isList cfg.config.fonts)
|
||||||
++ flatten (map (b:
|
"Specifying sway.config.fonts as a list is deprecated. Use the attrset version instead.")
|
||||||
optional (isList b.fonts)
|
++ flatten (map (b:
|
||||||
"Specifying sway.config.bars[].fonts as a list is deprecated. Use the attrset version instead.")
|
optional (isList b.fonts)
|
||||||
cfg.config.bars);
|
"Specifying sway.config.bars[].fonts as a list is deprecated. Use the attrset version instead.")
|
||||||
|
cfg.config.bars);
|
||||||
|
})
|
||||||
|
|
||||||
home.packages = optional (cfg.package != null) cfg.package
|
{
|
||||||
++ optional cfg.xwayland pkgs.xwayland;
|
home.packages = optional (cfg.package != null) cfg.package
|
||||||
xdg.configFile."sway/config" = {
|
++ optional cfg.xwayland pkgs.xwayland;
|
||||||
source = configFile;
|
xdg.configFile."sway/config" = {
|
||||||
onChange = ''
|
source = configFile;
|
||||||
swaySocket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep -x sway || ${pkgs.coreutils}/bin/true).sock
|
onChange = ''
|
||||||
if [ -S $swaySocket ]; then
|
swaySocket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep -x sway || ${pkgs.coreutils}/bin/true).sock
|
||||||
echo "Reloading sway"
|
if [ -S $swaySocket ]; then
|
||||||
$DRY_RUN_CMD ${pkgs.sway}/bin/swaymsg -s $swaySocket reload
|
echo "Reloading sway"
|
||||||
fi
|
$DRY_RUN_CMD ${pkgs.sway}/bin/swaymsg -s $swaySocket reload
|
||||||
'';
|
fi
|
||||||
};
|
'';
|
||||||
systemd.user.targets.sway-session = mkIf cfg.systemdIntegration {
|
|
||||||
Unit = {
|
|
||||||
Description = "sway compositor session";
|
|
||||||
Documentation = [ "man:systemd.special(7)" ];
|
|
||||||
BindsTo = [ "graphical-session.target" ];
|
|
||||||
Wants = [ "graphical-session-pre.target" ];
|
|
||||||
After = [ "graphical-session-pre.target" ];
|
|
||||||
};
|
};
|
||||||
};
|
systemd.user.targets.sway-session = mkIf cfg.systemdIntegration {
|
||||||
};
|
Unit = {
|
||||||
|
Description = "sway compositor session";
|
||||||
|
Documentation = [ "man:systemd.special(7)" ];
|
||||||
|
BindsTo = [ "graphical-session.target" ];
|
||||||
|
Wants = [ "graphical-session-pre.target" ];
|
||||||
|
After = [ "graphical-session-pre.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
i3-fonts = ./i3-fonts.nix;
|
i3-fonts = ./i3-fonts.nix;
|
||||||
i3-fonts-deprecated = ./i3-fonts-deprecated.nix;
|
i3-fonts-deprecated = ./i3-fonts-deprecated.nix;
|
||||||
i3-keybindings = ./i3-keybindings.nix;
|
i3-keybindings = ./i3-keybindings.nix;
|
||||||
|
i3-null-config = ./i3-null-config.nix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,17 +13,7 @@ with lib;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [ (import ./i3-overlay.nix) ];
|
||||||
(self: super: {
|
|
||||||
dmenu = super.dmenu // { outPath = "@dmenu@"; };
|
|
||||||
|
|
||||||
i3 = super.writeScriptBin "i3" "" // { outPath = "@i3@"; };
|
|
||||||
|
|
||||||
i3-gaps = super.writeScriptBin "i3" "" // { outPath = "@i3-gaps@"; };
|
|
||||||
|
|
||||||
i3status = super.i3status // { outPath = "@i3status@"; };
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/i3/config
|
assertFileExists home-files/.config/i3/config
|
||||||
|
|
|
@ -22,17 +22,7 @@ with lib;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [ (import ./i3-overlay.nix) ];
|
||||||
(self: super: {
|
|
||||||
dmenu = super.dmenu // { outPath = "@dmenu@"; };
|
|
||||||
|
|
||||||
i3 = super.writeScriptBin "i3" "" // { outPath = "@i3@"; };
|
|
||||||
|
|
||||||
i3-gaps = super.writeScriptBin "i3" "" // { outPath = "@i3-gaps@"; };
|
|
||||||
|
|
||||||
i3status = super.i3status // { outPath = "@i3status@"; };
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/i3/config
|
assertFileExists home-files/.config/i3/config
|
||||||
|
|
|
@ -16,16 +16,7 @@ with lib;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [ (import ./i3-overlay.nix) ];
|
||||||
(self: super: {
|
|
||||||
dmenu = super.dmenu // { outPath = "@dmenu@"; };
|
|
||||||
i3 = super.writeScriptBin "i3" "" // { outPath = "@i3@"; };
|
|
||||||
i3-gaps = super.writeScriptBin "i3-gaps" "" // {
|
|
||||||
outPath = "@i3-gaps@";
|
|
||||||
};
|
|
||||||
i3status = super.i3status // { outPath = "@i3status@"; };
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/i3/config
|
assertFileExists home-files/.config/i3/config
|
||||||
|
|
20
tests/modules/services/window-managers/i3/i3-null-config.nix
Normal file
20
tests/modules/services/window-managers/i3/i3-null-config.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
xsession.windowManager.i3 = {
|
||||||
|
enable = true;
|
||||||
|
config = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs.overlays = [ (import ./i3-overlay.nix) ];
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/i3/config
|
||||||
|
assertFileContent home-files/.config/i3/config \
|
||||||
|
${pkgs.writeText "expected" "\n"}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
12
tests/modules/services/window-managers/i3/i3-overlay.nix
Normal file
12
tests/modules/services/window-managers/i3/i3-overlay.nix
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
self: super:
|
||||||
|
# Avoid unnecessary downloads in CI jobs and/or make out paths
|
||||||
|
# constant, i.e., not containing hashes, version numbers etc.
|
||||||
|
{
|
||||||
|
dmenu = super.dmenu // { outPath = "@dmenu@"; };
|
||||||
|
|
||||||
|
i3 = super.writeScriptBin "i3" "" // { outPath = "@i3@"; };
|
||||||
|
|
||||||
|
i3-gaps = super.writeScriptBin "i3" "" // { outPath = "@i3-gaps@"; };
|
||||||
|
|
||||||
|
i3status = super.i3status // { outPath = "@i3status@"; };
|
||||||
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
sway-post-2003 = ./sway-post-2003.nix;
|
sway-post-2003 = ./sway-post-2003.nix;
|
||||||
sway-followmouse = ./sway-followmouse.nix;
|
sway-followmouse = ./sway-followmouse.nix;
|
||||||
sway-followmouse-legacy = ./sway-followmouse-legacy.nix;
|
sway-followmouse-legacy = ./sway-followmouse-legacy.nix;
|
||||||
|
sway-null-config = ./sway-null-config.nix;
|
||||||
sway-null-package = ./sway-null-package.nix;
|
sway-null-package = ./sway-null-package.nix;
|
||||||
sway-modules = ./sway-modules.nix;
|
sway-modules = ./sway-modules.nix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,17 +15,7 @@ in {
|
||||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [ (import ./sway-overlay.nix) ];
|
||||||
(self: super: {
|
|
||||||
dmenu = dummy-package // { outPath = "@dmenu@"; };
|
|
||||||
rxvt-unicode-unwrapped = dummy-package // {
|
|
||||||
outPath = "@rxvt-unicode-unwrapped@";
|
|
||||||
};
|
|
||||||
i3status = dummy-package // { outPath = "@i3status@"; };
|
|
||||||
sway = dummy-package // { outPath = "@sway@"; };
|
|
||||||
xwayland = dummy-package // { outPath = "@xwayland@"; };
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/sway/config
|
assertFileExists home-files/.config/sway/config
|
||||||
|
|
|
@ -19,21 +19,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [ (import ./sway-overlay.nix) ];
|
||||||
(self: super: {
|
|
||||||
dmenu = dummy-package // { outPath = "@dmenu@"; };
|
|
||||||
rxvt-unicode-unwrapped = dummy-package // {
|
|
||||||
outPath = "@rxvt-unicode-unwrapped@";
|
|
||||||
};
|
|
||||||
sway = dummy-package // { outPath = "@sway@"; };
|
|
||||||
sway-unwrapped = dummy-package // {
|
|
||||||
outPath = "@sway-unwrapped@";
|
|
||||||
version = "1";
|
|
||||||
};
|
|
||||||
swaybg = dummy-package // { outPath = "@swaybg@"; };
|
|
||||||
xwayland = dummy-package // { outPath = "@xwayland@"; };
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/sway/config
|
assertFileExists home-files/.config/sway/config
|
||||||
|
|
|
@ -19,18 +19,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [ (import ./sway-overlay.nix) ];
|
||||||
(self: super: {
|
|
||||||
dmenu = dummy-package // { outPath = "@dmenu@"; };
|
|
||||||
rxvt-unicode-unwrapped = dummy-package // {
|
|
||||||
outPath = "@rxvt-unicode-unwrapped@";
|
|
||||||
};
|
|
||||||
sway = dummy-package // { outPath = "@sway@"; };
|
|
||||||
sway-unwrapped = dummy-package // { version = "1"; };
|
|
||||||
swaybg = dummy-package // { outPath = "@swaybg@"; };
|
|
||||||
xwayland = dummy-package // { outPath = "@xwayland@"; };
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/sway/config
|
assertFileExists home-files/.config/sway/config
|
||||||
|
|
|
@ -21,17 +21,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [ (import ./sway-overlay.nix) ];
|
||||||
(self: super: {
|
|
||||||
dmenu = dummy-package // { outPath = "@dmenu@"; };
|
|
||||||
rxvt-unicode-unwrapped = dummy-package // {
|
|
||||||
outPath = "@rxvt-unicode-unwrapped@";
|
|
||||||
};
|
|
||||||
i3status = dummy-package // { outPath = "@i3status@"; };
|
|
||||||
sway = dummy-package // { outPath = "@sway@"; };
|
|
||||||
xwayland = dummy-package // { outPath = "@xwayland@"; };
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/sway/config
|
assertFileExists home-files/.config/sway/config
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
wayland.windowManager.sway = {
|
||||||
|
enable = true;
|
||||||
|
config = null;
|
||||||
|
systemdIntegration = false;
|
||||||
|
package = pkgs.sway;
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs.overlays = [ (import ./sway-overlay.nix) ];
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/sway/config
|
||||||
|
assertFileContent home-files/.config/sway/config \
|
||||||
|
${pkgs.writeText "expected" "\n"}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -17,17 +17,7 @@ in {
|
||||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [ (import ./sway-overlay.nix) ];
|
||||||
(self: super: {
|
|
||||||
dmenu = dummy-package // { outPath = "@dmenu@"; };
|
|
||||||
rxvt-unicode-unwrapped = dummy-package // {
|
|
||||||
outPath = "@rxvt-unicode-unwrapped@";
|
|
||||||
};
|
|
||||||
i3status = dummy-package // { outPath = "@i3status@"; };
|
|
||||||
sway = dummy-package // { outPath = "@sway@"; };
|
|
||||||
xwayland = dummy-package // { outPath = "@xwayland@"; };
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
assertions = [{
|
assertions = [{
|
||||||
assertion =
|
assertion =
|
||||||
|
|
17
tests/modules/services/window-managers/sway/sway-overlay.nix
Normal file
17
tests/modules/services/window-managers/sway/sway-overlay.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
self: super:
|
||||||
|
# Avoid unnecessary downloads in CI jobs.
|
||||||
|
let dummy-package = super.runCommandLocal "dummy-package" { } "mkdir $out";
|
||||||
|
in {
|
||||||
|
dmenu = dummy-package // { outPath = "@dmenu@"; };
|
||||||
|
rxvt-unicode-unwrapped = dummy-package // {
|
||||||
|
outPath = "@rxvt-unicode-unwrapped@";
|
||||||
|
};
|
||||||
|
i3status = dummy-package // { outPath = "@i3status@"; };
|
||||||
|
sway = dummy-package // { outPath = "@sway@"; };
|
||||||
|
sway-unwrapped = dummy-package // {
|
||||||
|
outPath = "@sway-unwrapped@";
|
||||||
|
version = "1";
|
||||||
|
};
|
||||||
|
swaybg = dummy-package // { outPath = "@swaybg@"; };
|
||||||
|
xwayland = dummy-package // { outPath = "@xwayland@"; };
|
||||||
|
}
|
|
@ -17,17 +17,7 @@ in {
|
||||||
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
config.menu = "${pkgs.dmenu}/bin/dmenu_run";
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [ (import ./sway-overlay.nix) ];
|
||||||
(self: super: {
|
|
||||||
dmenu = dummy-package // { outPath = "@dmenu@"; };
|
|
||||||
rxvt-unicode-unwrapped = dummy-package // {
|
|
||||||
outPath = "@rxvt-unicode-unwrapped@";
|
|
||||||
};
|
|
||||||
sway = dummy-package // { outPath = "@sway@"; };
|
|
||||||
i3status = dummy-package // { outPath = "@i3status@"; };
|
|
||||||
xwayland = dummy-package // { outPath = "@xwayland@"; };
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/sway/config
|
assertFileExists home-files/.config/sway/config
|
||||||
|
|
Loading…
Reference in a new issue