Skip to content

Nix/module: add defaultSettings #9939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
57 changes: 41 additions & 16 deletions nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ inputs: {
inherit (pkgs.stdenv.hostPlatform) system;
selflib = import ./lib.nix lib;
cfg = config.programs.hyprland;

hyprlangType = with lib.types; let
valueType =
nullOr (oneOf [
bool
int
float
str
path
(attrsOf valueType)
(listOf valueType)
])
// {
description = "Hyprlang configuration value";
};
in
valueType;
in {
options = {
programs.hyprland = {
Expand All @@ -20,22 +37,7 @@ in {
};

settings = lib.mkOption {
type = with lib.types; let
valueType =
nullOr (oneOf [
bool
int
float
str
path
(attrsOf valueType)
(listOf valueType)
])
// {
description = "Hyprland configuration value";
};
in
valueType;
type = hyprlangType;
default = {};
description = ''
Hyprland configuration written in Nix. Entries with the same key
Expand Down Expand Up @@ -70,6 +72,23 @@ in {
'';
};

defaultSettings = lib.mkOption {
type = hyprlangType;
default =
{
permission = [
"${cfg.portalPackage}/libexec/.xdg-desktop-portal-hyprland-wrapped, screencopy, allow"
"${lib.getExe pkgs.grim}, screencopy, allow"
];
}
// lib.mkIf cfg.withUWSM {
exec-once = "uwsm finalize";
};
description = ''
Default settings. Can be disabled by setting this option to `{}`.
'';
};

extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
Expand Down Expand Up @@ -146,6 +165,12 @@ in {
bottomCommandsPrefixes = cfg.bottomPrefixes;
}
cfg.settings)
+ lib.optionalString (cfg.defaultSettings != {})
(selflib.toHyprlang {
topCommandsPrefixes = cfg.topPrefixes;
bottomCommandsPrefixes = cfg.bottomPrefixes;
}
cfg.defaultSettings)
+ lib.optionalString (cfg.extraConfig != "") cfg.extraConfig;
};
})
Expand Down
Loading