-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Add dunst service #58209
Add dunst service #58209
Conversation
Good candidate for NixOS/rfcs#42 |
aed0ede
to
7a1a0b6
Compare
Yes, the rules part is probably too verbose. I wanted to internalize it more, in order to check for naming conflicts with official section names. But I agree, there is no need to go that deep into individual options for that. |
Other changes:
|
nixos/modules/services/x11/dunst.nix
Outdated
|
||
globalConfig = mkOption { | ||
type = types.nullOr (types.attrsOf types.string); | ||
default = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
type = with types; attrsOf str;
default = { };
Anyway, use types.str
because
# Deprecated; should not be used because it quietly concatenates
# strings, which is usually not what you want.
string = separatedString "";
nixos/modules/services/x11/dunst.nix
Outdated
|
||
options.services.dunst = { | ||
|
||
enable = mkOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enable = mkOption { | |
enable = mkEnableOption { |
I pushed some changes to use the upstream systemd unit file. |
ping (triage) |
Reading this code again after some time, I wonder if that is the right way to create the wrapper. |
Ok, I have an alternative implementation here using |
@xaverdh Well it looks like you have satisfied every request in the review of this PR so far... so let us know when you make up your mind because from skimming the comments in this PR I think a merge is in order 😄 |
Ok, lets merge this as is then. The implementation can still be switched later on. |
(triage) @dotlambda From the comments it looks like final word is yours. Please merge if you are satisfied. |
nixos/modules/services/x11/dunst.nix
Outdated
dunst-wrapper = pkgs.dunst.overrideAttrs (oldAttrs: { | ||
postInstall = oldAttrs.postInstall + '' | ||
wrapProgram $out/bin/dunst \ | ||
--add-flags ${escapeShellArg wrapper-args} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this trouble can be avoided by changing the services ExecStart somehow like this: systemd.user.services.dunst.serviceConfig.ExecStart = "${pkgs.dunst}/bin/dunst -config ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That actually leads to two ExecStart
directives in the service file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you can use e.g. mkOverride 900
on this entry to override the other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't work either. Maybe because I am using the upstream service file with systemd.packages
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh right. it's a bit ugly but give ExecStart = [ "" "${pkgs.dunst...
a try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That worked, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the socket activation seems broken with this approach somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it.
nixos/modules/services/x11/dunst.nix
Outdated
''; | ||
}); | ||
|
||
environment.systemPackages = [ dunst-wrapper ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
nixos/modules/services/x11/dunst.nix
Outdated
in mkIf cfg.enable { | ||
|
||
assertions = flip mapAttrsToList cfg.rules (name: conf: { | ||
assertion = ! ( any (ruleName: ruleName == name) reservedSections ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertion = ! ( any (ruleName: ruleName == name) reservedSections ); | |
assertion = ! elem name reservedSections; |
nixos/modules/services/x11/dunst.nix
Outdated
}; | ||
|
||
extraCliOptions = mkOption { | ||
type = types.str; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend types.listOf types.str
, which is better for escaping
nixos/modules/services/x11/dunst.nix
Outdated
urgency_critical = cfg.urgencyConfig.critical; | ||
} // cfg.rules; | ||
|
||
iconPath = builtins.concatStringsSep ":" cfg.iconDirs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iconPath = builtins.concatStringsSep ":" cfg.iconDirs; | |
iconPath = concatStringsSep ":" cfg.iconDirs; |
nixos/modules/services/x11/dunst.nix
Outdated
reservedSections = [ | ||
"global" "experimental" "frame" "shortcuts" | ||
"urgency_low" "urgency_normal" "urgency_critical" | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you put this at the top of the module, you can reuse this list in the description for rules
Thanks to Infinisil for the extensive review! |
nixos/modules/services/x11/dunst.nix
Outdated
|
||
iconPath = concatStringsSep ":" cfg.iconDirs; | ||
|
||
dunst-args = "-config ${pkgs.writeText "dunstrc" dunstConfig} -icon_path ${iconPath} ${concatStringsSep " " cfg.extraCliOptions}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should then be
{
dunstArgs = [
"-config" (pkgs.writeText "dunstrc" dunstConfig)
"-icon_path" iconPath
] ++ extraCliOptions;
}
And you can use escapeShellArgs dunstArgs
in the ExecStart
nixos/modules/services/x11/dunst.nix
Outdated
''; | ||
}; | ||
|
||
extraCliOptions = mkOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest renaming this to either extraArgs
or extraOptions
since this is a more common name for this
nixos/modules/services/x11/dunst.nix
Outdated
type = with types; listOf str; | ||
default = []; | ||
description = '' | ||
This gets appended verbatim to the command line of dunst. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest something like "Extra command line options for dunst" (describing what it is, not what it gets used for/does). Same for the other options
46d0a22
to
62f76b6
Compare
Status? Can we get this ready in time for 19.09? |
''; | ||
}; | ||
|
||
urgencyConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would really like examples for this config
Are there any news regarding this PR's status? I'm really interested in this service 😀 |
systemd.user.services.dunst.serviceConfig.ExecStart = [ "" "${pkgs.dunst}/bin/dunst ${escapeShellArgs dunst-args}" ]; | ||
# [ "" ... ] is needed to overwrite the ExecStart directive from the upstream service file | ||
|
||
systemd.packages = [ pkgs.dunst ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need to be installed for the user?
It would be good if somebody could try to see if it works how they expect. And check whether we should add some default config or at least more examples. |
I'd really like to get this in, so I picked this up and added some defaults, examples, and fixed merge conflict here: #112100 |
closed in favor of #112100 |
Motivation for this change
This is a fresh attempt at implementing #19183
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)