hyprland-community / hyprnix

30 stars 0 forks source link

How to use other hyprland "tools" which need to update hypr config folder. #7

Open hmajid2301 opened 4 months ago

hmajid2301 commented 4 months ago

Hi,

Thanks for the great work on this flake/hyprland module. It has made configuring my system a lot nicer. I was wondering if there was a way to use with some of the other hyprland tooling, such as hyprpaper or hypridle. Which require the config file to be in the ~/.config/hypr folder by default.

When I try to set up hyprpaper I get the following error.

Error installing file '.config/hypr/hyprpaper.conf' outside $HOME

This happens because I think it doesn't have permission to write to that config directory. As the entire directory is symlinked by this module? i.e. hypr -> /nix/store/10i7knfm540s6zy5g63xaik7aalr5hbj-home-manager-files/.config/hypr.

Any help would be appreciated

spikespaz commented 4 months ago

Yes, this is an oversight, my apologies. I will avoid writing the entire hypr directory as read-only. The assumption was that if you are using this flake, you are seeking an entirely declarative config, the expectation was that you use the mechanisms provided by the Home Manager module (for example, wayland.windowManager.hyprland.configFile."hyprpaper.conf".text) to write to that directory.

hmajid2301 commented 4 months ago

No need to apologise :), that would be great.

Also, just to clarify I am using the hyprpaper flake home-manager module in my example above. It is trying to write and failing to, causing an error https://github.com/hyprwm/hyprpaper/blob/main/nix/hm-module.nix#L66.

Thanks, as I say I prefer using this flake, to define my config in a more nix way.

spikespaz commented 4 months ago

Could you please try to set xdg.configFile."hypr".recursive = true?

spikespaz commented 4 months ago

There is a new branch if that option does not work or is unsatisfactory, revert-managed-config-dir. This branch reverts three commits that introduced a custom configFile attribute, very similar to xdg.configFile.

I did foresee this becoming a problem.

Documentation for the option wayland.windowManager.hyprland.configFile with type types.attrsOf (configFile pkgs "${config.xdg.configHome}/hypr"):

Configuration files and directories to link in the Hyprland config directory. This is an attribute set of file descriptions similar to {option}xdg.configFile, except relative to {path}$XDG_CONFIG_HOME/hypr.

If necessary, you may set {option}xdg.configFile."hypr".recursive = true.

To elaborate: I suggested this in the doc because I wanted users to be able to create and edit files within that directory (and allow external programs to do so, such as plugins with state). I am not sure if multiple entries for xdg.configFile."hypr" will work when recursive = true, but I'd like to see you try, and then if it doesn't work, use the branch I mentioned.

spikespaz commented 4 months ago

The branch reintroduces a bug that the config would have to be reloaded once for each file that was modified by the Nix config. For now, this is keybinds.conf and hyprland.conf. In some cases (IIRC) a change can cause both files to be modified, causing a double-reload, usually because a store path has changed. I don't remember what exactly caused this, but I tried to mitigate it by using an absolute path to keybinds.conf from a source line in hyprland.conf.

hmajid2301 commented 4 months ago

i will update you when i have some time to try this! :pray: thank you so much.

hmajid2301 commented 3 months ago

Sorry for the late reply,

I was able to get this working with xdg.configFile."hypr".recursive = true. I did have to turn off my hyprland config first in home-manager so the symlink was deleted (went to gnome) then switched the config back on (enabled it).

eza -al ~/.config/hypr
lrwxrwxrwx - haseeb  2 Apr 19:53 hyprland.conf -> /nix/store/snwq2gy6x2jhgwsm6a78jc3vdaqqad3w-home-manager-files/.config/hypr/hyprland.conf
lrwxrwxrwx - haseeb  2 Apr 19:53 hyprpaper.conf -> /nix/store/snwq2gy6x2jhgwsm6a78jc3vdaqqad3w-home-manager-files/.config/hypr/hyprpaper.conf
lrwxrwxrwx - haseeb  2 Apr 19:53 keybinds.conf -> /nix/store/snwq2gy6x2jhgwsm6a78jc3vdaqqad3w-home-manager-files/.config/hypr/keybinds.conf

Thanks a ton!

spikespaz commented 3 months ago

If you or anyone else has any problems relating to this, I want discussion to be immediately visible. No fix has been merged into master.

I am still not satisfied, as I myself have not confirmed if Home Manager will merge multiple configFile entries when recursive = true.