Files
att_wm/nix/hm-module.nix
T
2026-07-26 20:47:19 +02:00

78 lines
2.0 KiB
Nix

self:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.att_wm;
in
{
options.programs.att_wm = {
enable = lib.mkEnableOption "att_wm, a dwm-like window manager for river";
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${pkgs.stdenv.hostPlatform.system}.att_wm;
defaultText = lib.literalMD "the flake's `att_wm` package";
description = "The att_wm package to use.";
};
settings = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
example = lib.literalExpression "./config.zig";
description = ''
A replacement for att_wm's `src/config.zig`. att_wm is configured at
compile time in the manner of dwm, so setting this rebuilds it.
'';
};
autostart = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "quickshell" ];
description = ''
Commands appended to river's init script, run once the session starts.
att_wm itself is always started last and kept in the foreground.
'';
};
riverPackage = lib.mkOption {
type = lib.types.package;
default = pkgs.river;
description = "The river package the init script is written for.";
};
};
config = lib.mkIf cfg.enable (
let
att_wm =
if cfg.settings == null then
cfg.package
else
cfg.package.override { configFile = cfg.settings; };
in
{
home.packages = [
att_wm
cfg.riverPackage
];
# river runs this executable on startup and expects the window manager to
# connect; keeping att_wm in the foreground ties the session's lifetime to
# it, so quitting att_wm ends the session cleanly.
xdg.configFile."river/init" = {
executable = true;
text = ''
#!${pkgs.runtimeShell}
${lib.concatMapStringsSep "\n" (c: "${c} &") cfg.autostart}
exec ${lib.getExe att_wm}
'';
};
}
);
}