mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
feat(distro/nix/niri): add a hack for config includes with niri flake (#1239)
It works fine but needs all dms-generated config files to be present
This commit is contained in:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user