nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.72k stars 1.76k forks source link

make it possible or easier to pass gtk themes to flatpaks #4859

Open beh-10257 opened 8 months ago

beh-10257 commented 8 months ago

Description

I want to have the ability to pass my themes and icons and cursor theme to flatpaks there is already https://github.com/NixOS/nixpkgs/pull/262462 but thats only about icons and fonts it seems (hopefully cursor themes are included cause this is pain) so yeah this is what I used to do on arch put the themes I want to use in $HOME/.local/share/themes/ select the theme in nwg-look and than just give flatpaks the right to read xdg-data/themes and xdg-config/gtk-3.0 and xdg-config/gtk-4.0 and it will just work I even had my own custom theme at some point I don't know how to do this in nix in the first place but if theres is a way why not make it into an option which can be toggled on and off something like flatpak.theme.hack = true I guess if this will be implemented home-manager has to download stuff in .local/share/themes

but yeah I guess anyway thanks and thats all

beh-10257 commented 6 months ago

anyway heres a temporary fix hopefully

{ config, pkgs, ... }:
let
home-path = ''${config.home-manager.users.your_user_name.home.path}'';
home-files = ''${config.home-manager.users.your_user_name.home-files}'';
icon_theme_name = ''${config.home-manager.users.your_user_name.gtk.iconTheme.name}'';
theme_name = ''${config.home-manager.users.your_user_name.gtk.theme.name}'';
cursor_theme_name= ''${config.home-manager.users.your_user_name.gtk.cursorTheme.name}'';
in
let
gawk=''${pkgs.gawk}/bin/gawk'';
flatpak=''${pkgs.flatpak}/bin/flatpak'';
su=''${pkgs.su}/bin/su'';
cursor_theme_path=''${home-files}/.local/share/icons/${cursor_theme_name}'';
icon_theme_path=''${home-files}/.local/share/icons/${icon_theme_name}'';
theme_path=''${home-files}/.local/share/themes/${theme_name}'';
icon_theme_path_1=''${home-path}/share/icons/${icon_theme_name}'';
theme_path_1=''${home-path}/share/themes/${theme_name}'';
in
let
workaround =
''
${gawk} -i inplace '{gsub(/\/nix\/store[^;]*;|!\/nix\/store[^;]*;/,""); print}' /var/lib/flatpak/overrides/global
${gawk} -i inplace '{gsub(/filesystems=/,"filesystems=${icon_theme_path};${theme_path};${cursor_theme_path};"); print}' /var/lib/flatpak/overrides/global
${gawk} -i inplace '{gsub(/\/nix\/store[^;]*;|!\/nix\/store[^;]*;/,""); print}' /home/your_user_name/.local/share/flatpak/overrides/global
${gawk} -i inplace '{gsub(/filesystems=/,"filesystems=${icon_theme_path};${theme_path};${cursor_theme_path};"); print}' /home/your_user_name/.local/share/flatpak/overrides/global
${flatpak} override --env=GTK_THEME=${theme_name}
${su} your_user_name -c '${flatpak} override --user --env=GTK_THEME=${theme_name}'
'';
in
{
  services = {
    flatpak = {
      enable = true;
    };
  };
  ##workaround for themes and icons
  systemd.services.workaround-for-theme-and-icons = {
      wantedBy = ["multi-user.target"];
      after = ["systemd-user-sessions.service"] ;
      before = ["getty.target"] ;
      script = workaround;
  };
  home-manager.users.your_user_name.home.file = {
    ".local/share/icons/${icon_theme_name}".source = config.home-manager.users.your_user_name.lib.file.mkOutOfStoreSymlink "${icon_theme_path_1}";
    ".local/share/themes/${theme_name}".source = config.home-manager.users.your_user_name.lib.file.mkOutOfStoreSymlink "${theme_path_1}";
  };
}
stale[bot] commented 2 months ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.