Skip to content

Commit b97b837

Browse files
committed
Nix/module: add defaultSettings
1 parent 3c12867 commit b97b837

File tree

1 file changed

+41
-16
lines changed

1 file changed

+41
-16
lines changed

nix/module.nix

+41-16
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ inputs: {
77
inherit (pkgs.stdenv.hostPlatform) system;
88
selflib = import ./lib.nix lib;
99
cfg = config.programs.hyprland;
10+
11+
hyprlangType = with lib.types; let
12+
valueType =
13+
nullOr (oneOf [
14+
bool
15+
int
16+
float
17+
str
18+
path
19+
(attrsOf valueType)
20+
(listOf valueType)
21+
])
22+
// {
23+
description = "Hyprlang configuration value";
24+
};
25+
in
26+
valueType;
1027
in {
1128
options = {
1229
programs.hyprland = {
@@ -20,22 +37,7 @@ in {
2037
};
2138

2239
settings = lib.mkOption {
23-
type = with lib.types; let
24-
valueType =
25-
nullOr (oneOf [
26-
bool
27-
int
28-
float
29-
str
30-
path
31-
(attrsOf valueType)
32-
(listOf valueType)
33-
])
34-
// {
35-
description = "Hyprland configuration value";
36-
};
37-
in
38-
valueType;
40+
type = hyprlangType;
3941
default = {};
4042
description = ''
4143
Hyprland configuration written in Nix. Entries with the same key
@@ -70,6 +72,23 @@ in {
7072
'';
7173
};
7274

75+
defaultSettings = lib.mkOption {
76+
type = hyprlangType;
77+
default =
78+
{
79+
permission = [
80+
"${cfg.portalPackage}/libexec/.xdg-desktop-portal-hyprland-wrapped, screencopy, allow"
81+
"${lib.getExe pkgs.grim}, screencopy, allow"
82+
];
83+
}
84+
// lib.mkIf cfg.withUWSM {
85+
exec-once = "uwsm finalize";
86+
};
87+
description = ''
88+
Default settings. Can be disabled by setting this option to `{}`.
89+
'';
90+
};
91+
7392
extraConfig = lib.mkOption {
7493
type = lib.types.lines;
7594
default = "";
@@ -146,6 +165,12 @@ in {
146165
bottomCommandsPrefixes = cfg.bottomPrefixes;
147166
}
148167
cfg.settings)
168+
+ lib.optionalString (cfg.defaultSettings != {})
169+
(selflib.toHyprlang {
170+
topCommandsPrefixes = cfg.topPrefixes;
171+
bottomCommandsPrefixes = cfg.bottomPrefixes;
172+
}
173+
cfg.defaultSettings)
149174
+ lib.optionalString (cfg.extraConfig != "") cfg.extraConfig;
150175
};
151176
})

0 commit comments

Comments
 (0)