1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-01 04:23:34 +02:00

i3: validate configuration at build time

PR #1579
This commit is contained in:
Nicolas Berbiche 2020-11-15 17:58:55 -05:00 committed by Robert Helgesson
parent 99b75f99df
commit 6dc68b1d16
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
3 changed files with 23 additions and 5 deletions

View File

@ -193,6 +193,21 @@ let
else
"") + "\n" + cfg.extraConfig);
# Validates the i3 configuration
checkI3Config =
pkgs.runCommandLocal "i3-config" { buildInputs = [ cfg.package ]; } ''
# We have to make sure the wrapper does not start a dbus session
export DBUS_SESSION_BUS_ADDRESS=1
# A zero exit code means i3 succesfully validated the configuration
i3 -c ${configFile} -C -d all || {
echo "i3 configuration validation failed"
echo "For a verbose log of the failure, run 'i3 -c ${configFile} -C -d all'"
exit 1
};
cp ${configFile} $out
'';
in {
options = {
xsession.windowManager.i3 = {
@ -229,7 +244,7 @@ in {
home.packages = [ cfg.package ];
xsession.windowManager.command = "${cfg.package}/bin/i3";
xdg.configFile."i3/config" = {
source = configFile;
source = checkI3Config;
onChange = ''
i3Socket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.*
if [ -S $i3Socket ]; then

View File

@ -14,7 +14,9 @@ with lib;
(self: super: {
dmenu = super.dmenu // { outPath = "@dmenu@"; };
i3 = super.i3 // { outPath = "@i3@"; };
i3 = super.writeScriptBin "i3" "" // { outPath = "@i3@"; };
i3-gaps = super.writeScriptBin "i3" "" // { outPath = "@i3-gaps@"; };
i3status = super.i3status // { outPath = "@i3status@"; };
})

View File

@ -19,9 +19,10 @@ with lib;
nixpkgs.overlays = [
(self: super: {
dmenu = super.dmenu // { outPath = "@dmenu@"; };
i3 = super.i3 // { outPath = "@i3@"; };
i3 = super.writeScriptBin "i3" "" // { outPath = "@i3@"; };
i3-gaps = super.writeScriptBin "i3-gaps" "" // {
outPath = "@i3-gaps@";
};
i3status = super.i3status // { outPath = "@i3status@"; };
})
];