checks: extract hyprland config smoke test
This commit is contained in:
18
nixos/checks/hyprland-config-syntax/default.nix
Normal file
18
nixos/checks/hyprland-config-syntax/default.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
pkgs,
|
||||
hyprlandConfig,
|
||||
}:
|
||||
pkgs.runCommand "hyprland-config-syntax" {
|
||||
nativeBuildInputs = [pkgs.lua5_4];
|
||||
} ''
|
||||
cp ${hyprlandConfig} hyprland.lua
|
||||
luac -p hyprland.lua
|
||||
|
||||
if grep -n 'hyprctl' hyprland.lua | grep -v 'hyprctl reload' | grep -v 'hyprctl eval' | grep -v 'hyprctl_eval' | grep -v 'hyprctl -j monitors'; then
|
||||
echo "hyprland.lua should not shell out to hyprctl for window/workspace manipulation" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
lua ${./smoke-test.lua} ./hyprland.lua
|
||||
touch "$out"
|
||||
''
|
||||
110
nixos/checks/hyprland-config-syntax/smoke-test.lua
Normal file
110
nixos/checks/hyprland-config-syntax/smoke-test.lua
Normal file
@@ -0,0 +1,110 @@
|
||||
local config_path = arg[1] or "./hyprland.lua"
|
||||
local callbacks = {}
|
||||
|
||||
local function noop() end
|
||||
|
||||
local function dispatcher_proxy()
|
||||
local proxy = {}
|
||||
return setmetatable(proxy, {
|
||||
__index = function()
|
||||
return dispatcher_proxy()
|
||||
end,
|
||||
__call = function()
|
||||
return noop
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
local notification = {
|
||||
is_alive = function()
|
||||
return true
|
||||
end,
|
||||
set_text = noop,
|
||||
set_timeout = noop,
|
||||
pause = noop,
|
||||
resume = noop,
|
||||
set_paused = noop,
|
||||
dismiss = noop,
|
||||
}
|
||||
|
||||
local monitor = {
|
||||
id = 1,
|
||||
name = "stub-monitor",
|
||||
focused = true,
|
||||
}
|
||||
|
||||
local workspace = {
|
||||
id = 1,
|
||||
name = "1",
|
||||
windows = 0,
|
||||
special = false,
|
||||
monitor = monitor,
|
||||
}
|
||||
|
||||
monitor.active_workspace = workspace
|
||||
|
||||
hl = {
|
||||
animation = noop,
|
||||
bind = noop,
|
||||
config = noop,
|
||||
curve = noop,
|
||||
env = noop,
|
||||
exec_cmd = noop,
|
||||
define_submap = function(_, reset_or_callback, callback)
|
||||
local cb = type(reset_or_callback) == "function" and reset_or_callback or callback
|
||||
if cb then
|
||||
cb()
|
||||
end
|
||||
end,
|
||||
monitor = noop,
|
||||
workspace_rule = noop,
|
||||
window_rule = noop,
|
||||
dsp = dispatcher_proxy(),
|
||||
notification = {
|
||||
create = function()
|
||||
return notification
|
||||
end,
|
||||
},
|
||||
plugin = {
|
||||
load = noop,
|
||||
},
|
||||
get_active_workspace = function()
|
||||
return workspace
|
||||
end,
|
||||
get_active_monitor = function()
|
||||
return monitor
|
||||
end,
|
||||
get_active_window = function()
|
||||
return nil
|
||||
end,
|
||||
get_monitor = function()
|
||||
return monitor
|
||||
end,
|
||||
get_workspace = function(id)
|
||||
if tostring(id) == "1" then
|
||||
return workspace
|
||||
end
|
||||
return nil
|
||||
end,
|
||||
get_windows = function()
|
||||
return {}
|
||||
end,
|
||||
get_workspace_windows = function()
|
||||
return {}
|
||||
end,
|
||||
on = function(_, callback)
|
||||
callbacks[#callbacks + 1] = callback
|
||||
end,
|
||||
timer = function(callback)
|
||||
callback()
|
||||
return {
|
||||
set_enabled = noop,
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
||||
dofile(config_path)
|
||||
|
||||
for _, callback in ipairs(callbacks) do
|
||||
callback()
|
||||
end
|
||||
127
nixos/flake.nix
127
nixos/flake.nix
@@ -546,129 +546,10 @@
|
||||
hyprexpo-lua = inputs.hyprland-plugins-lua.packages.${system}.hyprexpo;
|
||||
hyprwinview = inputs.hyprwinview.packages.${system}.hyprwinview;
|
||||
hypr-workspace-history = inputs.hypr-workspace-history.packages.${system}.hypr-workspace-history;
|
||||
hyprland-config-syntax =
|
||||
pkgs.runCommand "hyprland-config-syntax" {
|
||||
nativeBuildInputs = [pkgs.lua5_4];
|
||||
} ''
|
||||
cp ${../dotfiles/config/hypr/hyprland.lua} hyprland.lua
|
||||
luac -p hyprland.lua
|
||||
if grep -n 'hyprctl' hyprland.lua | grep -v 'hyprctl reload' | grep -v 'hyprctl eval' | grep -v 'hyprctl_eval' | grep -v 'hyprctl -j monitors'; then
|
||||
echo "hyprland.lua should not shell out to hyprctl for window/workspace manipulation" >&2
|
||||
exit 1
|
||||
fi
|
||||
lua <<'LUA'
|
||||
local callbacks = {}
|
||||
|
||||
local function noop() end
|
||||
|
||||
local function dispatcher_proxy()
|
||||
local proxy = {}
|
||||
return setmetatable(proxy, {
|
||||
__index = function()
|
||||
return dispatcher_proxy()
|
||||
end,
|
||||
__call = function()
|
||||
return noop
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
local notification = {
|
||||
is_alive = function()
|
||||
return true
|
||||
end,
|
||||
set_text = noop,
|
||||
set_timeout = noop,
|
||||
pause = noop,
|
||||
resume = noop,
|
||||
set_paused = noop,
|
||||
dismiss = noop,
|
||||
}
|
||||
|
||||
local monitor = {
|
||||
id = 1,
|
||||
name = "stub-monitor",
|
||||
focused = true,
|
||||
}
|
||||
|
||||
local workspace = {
|
||||
id = 1,
|
||||
name = "1",
|
||||
windows = 0,
|
||||
special = false,
|
||||
monitor = monitor,
|
||||
}
|
||||
|
||||
monitor.active_workspace = workspace
|
||||
|
||||
hl = {
|
||||
animation = noop,
|
||||
bind = noop,
|
||||
config = noop,
|
||||
curve = noop,
|
||||
env = noop,
|
||||
exec_cmd = noop,
|
||||
define_submap = function(_, reset_or_callback, callback)
|
||||
local cb = type(reset_or_callback) == "function" and reset_or_callback or callback
|
||||
if cb then
|
||||
cb()
|
||||
end
|
||||
end,
|
||||
monitor = noop,
|
||||
workspace_rule = noop,
|
||||
window_rule = noop,
|
||||
dsp = dispatcher_proxy(),
|
||||
notification = {
|
||||
create = function()
|
||||
return notification
|
||||
end,
|
||||
},
|
||||
plugin = {
|
||||
load = noop,
|
||||
},
|
||||
get_active_workspace = function()
|
||||
return workspace
|
||||
end,
|
||||
get_active_monitor = function()
|
||||
return monitor
|
||||
end,
|
||||
get_active_window = function()
|
||||
return nil
|
||||
end,
|
||||
get_monitor = function()
|
||||
return monitor
|
||||
end,
|
||||
get_workspace = function(id)
|
||||
if tostring(id) == "1" then
|
||||
return workspace
|
||||
end
|
||||
return nil
|
||||
end,
|
||||
get_windows = function()
|
||||
return {}
|
||||
end,
|
||||
get_workspace_windows = function()
|
||||
return {}
|
||||
end,
|
||||
on = function(_, callback)
|
||||
callbacks[#callbacks + 1] = callback
|
||||
end,
|
||||
timer = function(callback)
|
||||
callback()
|
||||
return {
|
||||
set_enabled = noop,
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
||||
dofile("./hyprland.lua")
|
||||
|
||||
for _, callback in ipairs(callbacks) do
|
||||
callback()
|
||||
end
|
||||
LUA
|
||||
touch "$out"
|
||||
'';
|
||||
hyprland-config-syntax = import ./checks/hyprland-config-syntax {
|
||||
inherit pkgs;
|
||||
hyprlandConfig = ../dotfiles/config/hypr/hyprland.lua;
|
||||
};
|
||||
hyprland-verify-config = let
|
||||
hyprlandPackage = inputs.hyprland.packages.${system}.hyprland;
|
||||
hyprNStackPackage = inputs.hyprNStack.packages.${system}.hyprNStack;
|
||||
|
||||
Reference in New Issue
Block a user