Conversation
|
I'm not sure we want to maintain the module in home-manager if upstream has its own? |
|
Alright, fair. I was just following up on this. I can close the PR if having it in two places is not suitable. |
|
@ncfavier So am I expected to track all the upstream repositories of software with nix support to get home-manager integration? That does not really sound feasible to me either. |
|
I guess? Not sure why that wouldn't be feasible. |
|
To be clear, I'm not opposed to adding a hyprland module at all, if that's what upstream wants. As long as they maintain their own out-of-tree module, I don't see the point in duplicating code and work. Closing for now. |
|
One advantage of the home-manager module would be that it than uses the nixpkgs package while upstream will use its own (which means user have to compile the window manager themself). |
|
(Just realised @fufexan is upstream... 🤦 guess I'll reopen.) |
|
I'm unsure why the tests fail on a module that I haven't touched. |
|
Should be fixed by rebasing. |
This PR predates the addition of plugin support. I will add it here as well. |
1a1aded to
3449677
Compare
| ''; | ||
| }; | ||
|
|
||
| disableAutoreload = lib.mkOption { |
There was a problem hiding this comment.
Best to avoid confusion with double negation and such. I would suggest
| disableAutoreload = lib.mkOption { | |
| enableAutoreload = lib.mkOption { |
with the default being true. That said, is there any occasion where you would not want automatic reload?
There was a problem hiding this comment.
I added it because of this issue, however I think it's safe to remove it.
| Hyprland package to use. Will override the 'xwayland' and 'nvidiaPatches' | ||
| options. |
There was a problem hiding this comment.
Seems a bit confusing, why not have the default be pkgs.hyprland and then add a read-only finalPackage option? Like in the emacs module, for example.
In the config section set
wayland.windowManager.hyprland.finalPackage = cfg.package.override { … }
There was a problem hiding this comment.
Oh, I didn't even think of this. Thanks, will fix.
| ''; | ||
| }; | ||
|
|
||
| systemdIntegration = lib.mkOption { |
There was a problem hiding this comment.
When would you not want to use systemd integration? Btw, when enabling the systemd integration I don't see any attempt at shutting down the graphical session when Hyprland exits. Will that happen automatically?
There was a problem hiding this comment.
Perhaps it makes sense for users that are on a distro without systemd. But they'd have a hard time using Nix by itself, let alone HM.
No, there's no attempt to shut down the graphical session. I don't know how to do this, but I'm willing to include it if you have clues. Also, it does not automatically shut down.
There was a problem hiding this comment.
Without something like exec-exit, which would run a command on shutdown it would be tricky to solve the shutdown entirely within Hyprland. I think it would require wrapping the Hyprland executable and in the wrapper do something like
home-manager/modules/xsession.nix
Lines 209 to 219 in 6a19225
| (lib.mdDoc "patching wlroots for better Nvidia support."); | ||
|
|
||
| extraConfig = lib.mkOption { | ||
| type = lib.types.nullOr lib.types.lines; |
There was a problem hiding this comment.
I think you could omit the null case.
| type = lib.types.nullOr lib.types.lines; | |
| type = lib.types.lines; |
That said, to me it seems like it would be possible to relatively easily create an RFC-42 style settings option instead of extraConfig?
There was a problem hiding this comment.
I think it could work. Currently there's hyprwm/Hyprland#870 which is very big and intricate.
Perhaps adapting lib.generators.toINI could work, but I'm unsure how to actually do it. I've tried
lib: let
libStr = lib.strings;
libAttr = lib.attrsets;
in {
toHyprconf = {
# format a setting line from key and value
mkKeyValue ? lib.generators.mkKeyValueDefault {} "=",
# allow lists as values for duplicate keys
listsAsDuplicateKeys ? false,
}: attrsOfAttrs: let
# map function to string for each key val
mapAttrsToStringsSep = sep: mapFn: attrs:
libStr.concatStringsSep sep
(libAttr.mapAttrsToList mapFn attrs);
mkSection = sectName: sectValues:
''
${sectName} {
''
+ (lib.generators.toKeyValue {inherit mkKeyValue listsAsDuplicateKeys;} sectValues)
+ ''
}
'';
in
# map input to hyprconf sections
mapAttrsToStringsSep "\n" mkSection attrsOfAttrs;
}but couldn't test it in a repl.
There was a problem hiding this comment.
Here is a rough and mostly untested attempt:
toHyprconf = { }: attrs: let
mkSection = n: attrs: ''
${n} {
${toKeyValue { listsAsDuplicateKeys = true; } attrs}
}
'';
mkField = mkKeyValueDefault {} "=";
sections = filterAttrs (n: v: isAttrs v) attrs;
fields = filterAttrs (n: v: !(isAttrs v)) attrs;
in
concatStringsSep "\n" (
mapAttrsToList mkSection sections ++ mapAttrsToList mkField fields
);This does assume that Hyprland does not care about field order, but I think that is a correct assumption?
There was a problem hiding this comment.
That gets us closer, but there are instances of nested sections, for example
input {
sensitivity = 0.5
touchpad {
natural_scroll = true
}
}There was a problem hiding this comment.
Maybe something like
toHyprconf = { }: attrs: let
mkSection = n: attrs: ''
${n} {
${toHyprconf { } attrs}}
'';
mkFields = generators.toKeyValue { listsAsDuplicateKeys = true; };
sections = filterAttrs (n: v: isAttrs v) attrs;
fields = filterAttrs (n: v: !(isAttrs v)) attrs;
in
concatStringsSep "\n" (mapAttrsToList mkSection sections)
+ mkFields fields;Won't do indentation or anything fancy but I guess good enough to start with.
There was a problem hiding this comment.
The hyprland config allows a key to have multiple values. For example
exec-once=eww open bar
exec-once=firefox
bind=SUPER, Return, exec, kitty
bind=SUPER, Return, exec, notify-send "Kitty was started!"How could we make this work?
There was a problem hiding this comment.
That's what listsAsDuplicateKeys does
There was a problem hiding this comment.
That's really handy then!
There was a problem hiding this comment.
Sorry for the long delay, I've been having exams for the past month.
I just realized we have to handle submaps (nested keybinds) as a special case.
# window resize
bind = $mod, S, submap, resize
submap = resize
binde = , right, resizeactive, 10 0
binde = , left, resizeactive, -10 0
binde = , up, resizeactive, 0 -10
binde = , down, resizeactive, 0 10
bind = , escape, submap, reset
submap = resetHere, the order of binds matters. Can we simply pass this as key=value (I'm thinking multiline string) or is there a better way?
There was a problem hiding this comment.
It seems the multiline string way worked just fine, although it looks a bit ugly.
638b3c1 to
b773241
Compare
|
I've tried testing this with my configuration but it does not seem to work in any way. I have the testing branch available here. If anyone wants to test building it ( Alternatively, here's the rough config file I've used for testing the > :lf nixpkgs
> config = import ./hyprconf2.nix lib
> :b legacyPackages.x86_64-linux.writeText "hyprland.conf" config |
7911d82 to
2f1e776
Compare
|
We may be able to remove the |
|
Actually, it seems |
| enableNvidiaPatches = | ||
| lib.mkEnableOption "patching wlroots for better Nvidia support"; | ||
|
|
||
| settings = lib.mkOption { |
There was a problem hiding this comment.
Note, name changed to settings in line with RFC 42.
|
Looks pretty good! I rebased and added a fixup commit with various cleanups (and added tests). If you can, then please give it a try. I'll try to finish it all up tomorrow. |
|
Thank you! I'll test this right now. |
|
I got this error error: A definition for option `home-manager.users.mihai.wayland.windowManager.hyprland.settings.input.touchpad' is not of type `atom (null, bool, int, float or string) or a list of them for duplicate keys'. Definition values:
- In `/nix/store/ml8sy5pirc2yi9d2kzkpw6hw9b87qn6i-source/home/wayland/hyprland/settings.nix':
{
scroll_factor = 0.3;
}This is the nix code that triggered it input = {
kb_layout = "ro";
# focus change on cursor move
follow_mouse = 1;
accel_profile = "flat";
touchpad = {
scroll_factor = 0.3;
};
};Edit: here's my dotfiles branch where I switched to this module. For more options, you can check |
|
@fufexan Aha, I wasn't aware that the nesting could be more than one level deep. I've force-pushed an update now that allows arbitrary nesting. Please give it a try. |
|
Thank you, works just fine now! |
Ported from https://github.com/hyprwm/Hyprland/blob/main/nix/hm-module.nix which was adapted from the sway module. Co-authored-by: Robert Helgesson <robert@rycee.net>
|
Great! I've merged it now 🙂 |
|
Thank you for all the help, Robert! |
|
Can this module be backported to |
Description
Add the Hyprland module, ported from
https://github.com/hyprwm/Hyprland/blob/main/nix/hm-module.nix,
which was adapted from the sway module.
CC: @Mic92
Checklist
Change is backwards compatible.
Code formatted with
./format.Code tested through
nix-shell --pure tests -A run.all.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
Added myself as module maintainer. See example.
Added myself and the module files to
.github/CODEOWNERS.