Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions distro/nix/niri.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,93 @@ in
niri = {
enableKeybinds = lib.mkEnableOption "DankMaterialShell niri keybinds";
enableSpawn = lib.mkEnableOption "DankMaterialShell niri spawn-at-startup";
includes = {
enable = (lib.mkEnableOption "includes for niri-flake") // {
default = true;
};
override = lib.mkOption {
type = lib.types.bool;
description = ''
Whether DMS settings will be prioritized over settings defined in niri-flake or not
'';
default = true;
example = false;
};
originalFileName = lib.mkOption {
type = lib.types.str;
description = ''
A new name for the config file generated by niri-flake
'';
default = "hm";
example = "niri-flake";
};
filesToInclude = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = ''
A list of dms-generated files to include
'';
default = [
"alttab"
"binds"
"colors"
"layout"
"outputs"
"wpblur"
];
example = [
"outputs"
"wpblur"
];
};
};
};
};

config = lib.mkIf cfg.enable {
warnings = (
lib.optional (cfg.niri.enableKeybinds && cfg.niri.includes.enable) ''
It is not recommended to use both `enableKeybinds` and `includes.enable` at the same time.
''
);

# HACK: niri-flake does not support config includes yet, but we can "fix" that
# TODO: replace with proper config includes after https://github.com/sodiboo/niri-flake/pull/1548 merge
xdg.configFile = lib.mkIf cfg.niri.includes.enable (
let
cfg' = cfg.niri.includes;

withOriginalConfig =
dmsFiles:
if cfg'.override then
[ cfg'.originalFileName ] ++ dmsFiles
else
dmsFiles ++ [ cfg'.originalFileName ];

fixes = map (fix: "\n${fix}") (
lib.optional (cfg'.enable && config.programs.niri.settings.layout.border.enable)
# kdl
''
// Border fix
// See https://yalter.github.io/niri/Configuration%3A-Include.html#border-special-case for details
layout { border { on; }; }
''
);
in
{
niri-config.target = lib.mkForce "niri/${cfg'.originalFileName}.kdl";
niri-config-dms = {
target = "niri/config.kdl";
text = lib.pipe cfg'.filesToInclude [
(map (filename: "dms/${filename}"))
withOriginalConfig
(map (filename: "include \"${filename}.kdl\""))
(files: files ++ fixes)
(builtins.concatStringsSep "\n")
];
};
}
);

programs.niri.settings = lib.mkMerge [
(lib.mkIf cfg.niri.enableKeybinds {
binds =
Expand Down