From dd791f454ea2b1ced3baddfe1a27230a487607b9 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 17 Nov 2024 17:27:14 -0600 Subject: [PATCH] nix: use xdg.configFile instead of home.file where possible Signed-off-by: Myned --- options/custom/programs/bitwarden-menu.nix | 2 +- options/custom/programs/clipse.nix | 2 +- options/custom/programs/discord.nix | 7 +- options/custom/programs/element-desktop.nix | 2 +- options/custom/programs/fastfetch.nix | 2 +- options/custom/programs/libreoffice.nix | 9 ++- options/custom/programs/logseq.nix | 7 +- .../custom/programs/networkmanager-dmenu.nix | 2 +- options/custom/programs/nvtop.nix | 2 +- options/custom/programs/onedrive.nix | 6 +- options/custom/programs/remmina.nix | 5 +- options/custom/programs/rofi-rbw.nix | 2 +- options/custom/programs/thunderbird.nix | 3 +- options/custom/programs/tio.nix | 2 +- options/custom/programs/vscode.nix | 81 +++++++++++-------- options/custom/programs/waybar/default.nix | 8 +- options/custom/services/clipcat.nix | 6 +- options/custom/services/easyeffects.nix | 13 ++- options/custom/services/samba.nix | 2 +- options/custom/services/swayosd.nix | 2 +- options/custom/settings/xdg.nix | 2 +- 21 files changed, 98 insertions(+), 69 deletions(-) diff --git a/options/custom/programs/bitwarden-menu.nix b/options/custom/programs/bitwarden-menu.nix index 2970cce..d48c1c2 100644 --- a/options/custom/programs/bitwarden-menu.nix +++ b/options/custom/programs/bitwarden-menu.nix @@ -14,7 +14,7 @@ in { # https://github.com/firecat53/bitwarden-menu #!! Options not available, files written directly # https://github.com/firecat53/bitwarden-menu/blob/main/docs/configure.md - home.file.".config/bwm/config.ini".text = '' + xdg.configFile."bwm/config.ini".text = '' [dmenu] dmenu_command = ${wofi} --dmenu diff --git a/options/custom/programs/clipse.nix b/options/custom/programs/clipse.nix index c1c72f3..d8f1b37 100644 --- a/options/custom/programs/clipse.nix +++ b/options/custom/programs/clipse.nix @@ -19,7 +19,7 @@ in { home-manager.users.${config.custom.username} = mkIf cfg.enable { # https://github.com/savedra1/clipse?tab=readme-ov-file#configuration - home.file.".config/clipse/config.json".text = '' + xdg.configFile."clipse/config.json".text = '' { "historyFile": "clipboard_history.json", "maxHistory": 50, diff --git a/options/custom/programs/discord.nix b/options/custom/programs/discord.nix index b1315f7..3d23a1b 100644 --- a/options/custom/programs/discord.nix +++ b/options/custom/programs/discord.nix @@ -9,8 +9,9 @@ in { options.custom.programs.discord.enable = mkOption {default = false;}; config.home-manager.users.myned = mkIf cfg.enable { - home.file.".config/BetterDiscord".source = - config.home-manager.users.${config.custom.username}.lib.file.mkOutOfStoreSymlink - "/home/${config.custom.username}/SYNC/common/config/discord/BetterDiscord"; + xdg.configFile."BetterDiscord" = { + force = true; + source = config.home-manager.users.${config.custom.username}.lib.file.mkOutOfStoreSymlink "${config.custom.sync}/common/config/discord/BetterDiscord"; + }; }; } diff --git a/options/custom/programs/element-desktop.nix b/options/custom/programs/element-desktop.nix index 36c7ad3..ff33c97 100644 --- a/options/custom/programs/element-desktop.nix +++ b/options/custom/programs/element-desktop.nix @@ -11,7 +11,7 @@ in { config.home-manager.users.${config.custom.username} = mkIf cfg.enable { # Element Desktop custom themes # https://github.com/aaronraimist/element-themes - home.file.".config/Element/config.json".text = '' + xdg.configFile."Element/config.json".text = '' { "show_labs_settings": true, "setting_defaults": { diff --git a/options/custom/programs/fastfetch.nix b/options/custom/programs/fastfetch.nix index 9ef50fc..b246fad 100644 --- a/options/custom/programs/fastfetch.nix +++ b/options/custom/programs/fastfetch.nix @@ -30,7 +30,7 @@ in { # https://github.com/fastfetch-cli/fastfetch #!! Option not available, files written directly - home-manager.users.${config.custom.username}.home.file.".config/fastfetch/config.jsonc".text = '' + home-manager.users.${config.custom.username}.xdg.configFile."fastfetch/config.jsonc".text = '' { "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", "logo": { diff --git a/options/custom/programs/libreoffice.nix b/options/custom/programs/libreoffice.nix index f1e76d7..0636dff 100644 --- a/options/custom/programs/libreoffice.nix +++ b/options/custom/programs/libreoffice.nix @@ -17,8 +17,11 @@ in { environment.systemPackages = [cfg.package]; #!! Options not available, files synced - home-manager.users.${config.custom.username}.home.file.".config/libreoffice/4/user".source = - config.home-manager.users.${config.custom.username}.lib.file.mkOutOfStoreSymlink - "/home/${config.custom.username}/SYNC/linux/config/libreoffice/user"; + home-manager.users.${config.custom.username} = { + xdg.configFile.".config/libreoffice/4/user" = { + force = true; + source = config.home-manager.users.${config.custom.username}.lib.file.mkOutOfStoreSymlink "${config.custom.sync}/linux/config/libreoffice/user"; + }; + }; }; } diff --git a/options/custom/programs/logseq.nix b/options/custom/programs/logseq.nix index aae8a22..e4c0c83 100644 --- a/options/custom/programs/logseq.nix +++ b/options/custom/programs/logseq.nix @@ -10,8 +10,9 @@ in { config.home-manager.users.${config.custom.username} = mkIf cfg.enable { #!! Synced imperative configuration - home.file.".logseq/".source = - config.home-manager.users.${config.custom.username}.lib.file.mkOutOfStoreSymlink - "/home/${config.custom.username}/SYNC/common/config/logseq/"; + home.file.".logseq/" = { + force = true; + source = config.home-manager.users.${config.custom.username}.lib.file.mkOutOfStoreSymlink "${config.custom.sync}/common/config/logseq/"; + }; }; } diff --git a/options/custom/programs/networkmanager-dmenu.nix b/options/custom/programs/networkmanager-dmenu.nix index e711f75..f9e76e3 100644 --- a/options/custom/programs/networkmanager-dmenu.nix +++ b/options/custom/programs/networkmanager-dmenu.nix @@ -15,7 +15,7 @@ in { # https://github.com/firecat53/networkmanager-dmenu/blob/main/config.ini.example #!! Option not available, files written directly # FIXME: active_chars does not take effect - home.file.".config/networkmanager-dmenu/config.ini".text = '' + xdg.configFile."networkmanager-dmenu/config.ini".text = '' [dmenu] dmenu_command = ${menu} --input active_chars = > diff --git a/options/custom/programs/nvtop.nix b/options/custom/programs/nvtop.nix index f145b3f..de4cf66 100644 --- a/options/custom/programs/nvtop.nix +++ b/options/custom/programs/nvtop.nix @@ -12,7 +12,7 @@ in { # https://github.com/Syllo/nvtop #!! Options not available, config written directly #?? Imperative config generated by F12 - home.file.".config/nvtop/interface.ini".text = '' + xdg.configFile."nvtop/interface.ini".text = '' [GeneralOption] UseColor = true UpdateInterval = 3000 diff --git a/options/custom/programs/onedrive.nix b/options/custom/programs/onedrive.nix index 5214359..87c0240 100644 --- a/options/custom/programs/onedrive.nix +++ b/options/custom/programs/onedrive.nix @@ -15,14 +15,14 @@ in { #?? systemctl --user enable --now onedrive@onedrive.service #!! Option not available, files written directly - home.file = { + xdg.configFile = { # https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md#configuration - ".config/onedrive/config".text = '' + "onedrive/config".text = '' sync_dir = "~/SYNC/edu/hawkeye" ''; # https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md#performing-a-selective-sync-via-sync_list-file - ".config/onedrive/sync_list".text = '' + "onedrive/sync_list".text = '' !/Apps/ !/Attachments/ /* diff --git a/options/custom/programs/remmina.nix b/options/custom/programs/remmina.nix index f6c42f5..cb4349a 100644 --- a/options/custom/programs/remmina.nix +++ b/options/custom/programs/remmina.nix @@ -11,7 +11,10 @@ in { config = mkIf cfg.enable { home-manager.users.${config.custom.username} = { #!! Imperative configuration - home.file.".config/remmina/remmina.pref".source = config.home-manager.users.${config.custom.username}.lib.file.mkOutOfStoreSymlink "${config.custom.sync}/linux/config/remmina/remmina.pref"; + xdg.configFile."remmina/remmina.pref" = { + force = true; + source = config.home-manager.users.${config.custom.username}.lib.file.mkOutOfStoreSymlink "${config.custom.sync}/linux/config/remmina/remmina.pref"; + }; }; }; } diff --git a/options/custom/programs/rofi-rbw.nix b/options/custom/programs/rofi-rbw.nix index 5b929e5..61e88d8 100644 --- a/options/custom/programs/rofi-rbw.nix +++ b/options/custom/programs/rofi-rbw.nix @@ -14,7 +14,7 @@ in { # https://github.com/fdw/rofi-rbw?tab=readme-ov-file#configuration # TODO: Enable input emulation when merged (uinput.enable?) # https://github.com/NixOS/nixpkgs/pull/303745 - home.file.".config/rofi-rbw.rc".text = '' + xdg.configFile."rofi-rbw.rc".text = '' action=copy ''; }; diff --git a/options/custom/programs/thunderbird.nix b/options/custom/programs/thunderbird.nix index cc38733..8052b5d 100644 --- a/options/custom/programs/thunderbird.nix +++ b/options/custom/programs/thunderbird.nix @@ -77,7 +77,6 @@ in { accounts.email.accounts.${config.custom.username}.thunderbird.enable = true; # https://github.com/rafaelmardojai/thunderbird-gnome-theme - home.file.".thunderbird/default/chrome/thunderbird-gnome-theme".source = - inputs.thunderbird-gnome-theme; + home.file.".thunderbird/default/chrome/thunderbird-gnome-theme".source = inputs.thunderbird-gnome-theme; }; } diff --git a/options/custom/programs/tio.nix b/options/custom/programs/tio.nix index 7edd28b..21f0de2 100644 --- a/options/custom/programs/tio.nix +++ b/options/custom/programs/tio.nix @@ -15,7 +15,7 @@ in { # https://github.com/tio/tio #!! Options not available, files written directly - home-manager.users.${config.custom.username}.home.file.".config/tio/config".text = '' + home-manager.users.${config.custom.username}.xdg.configFile."tio/config".text = '' baudrate = 9600 ''; }; diff --git a/options/custom/programs/vscode.nix b/options/custom/programs/vscode.nix index d049157..4806472 100644 --- a/options/custom/programs/vscode.nix +++ b/options/custom/programs/vscode.nix @@ -81,44 +81,59 @@ in { ]); }; + xdg.configFile = with config.home-manager.users.${config.custom.username}.lib.file; { + # Imperative symlinks intended to be synced + "VSCodium/User/settings.json" = { + force = true; + source = mkOutOfStoreSymlink "${config.custom.sync}/dev/config/vscode/settings.json"; + }; + + "VSCodium/User/keybindings.json" = { + force = true; + source = mkOutOfStoreSymlink "${config.custom.sync}/dev/config/vscode/keybindings.json"; + }; + + "VSCodium/User/snippets/" = { + force = true; + source = mkOutOfStoreSymlink "${config.custom.sync}/dev/config/vscode/snippets/"; + }; + + "VSCodium/User/profiles/" = { + force = true; + source = mkOutOfStoreSymlink "${config.custom.sync}/dev/config/vscode/profiles/"; + }; + }; + home = { # https://github.com/nix-community/nixd/blob/main/nixd/docs/features.md sessionVariables.NIXD_FLAGS = "--inlay-hints=false"; # Disable package versions in the editor - file = with config.home-manager.users.${config.custom.username}.lib.file; { - # Imperative symlinks intended to be synced - ".config/VSCodium/User/settings.json".source = mkOutOfStoreSymlink "/home/${config.custom.username}/SYNC/dev/config/vscode/settings.json"; - ".config/VSCodium/User/keybindings.json".source = mkOutOfStoreSymlink "/home/${config.custom.username}/SYNC/dev/config/vscode/keybindings.json"; - ".config/VSCodium/User/snippets/".source = mkOutOfStoreSymlink "/home/${config.custom.username}/SYNC/dev/config/vscode/snippets/"; - ".config/VSCodium/User/profiles/".source = mkOutOfStoreSymlink "/home/${config.custom.username}/SYNC/dev/config/vscode/profiles/"; + # Work around wrong wmclass + # https://github.com/microsoft/vscode/issues/129953 + # https://github.com/VSCodium/vscodium/issues/1414 + #!! Keep updated with upstream desktop file + #?? cat /etc/profiles/per-user/USER/share/applications/codium.desktop + # file.".local/share/applications/codium.desktop".text = '' + # [Desktop Entry] + # Actions=new-empty-window + # Categories=Utility;TextEditor;Development;IDE + # Comment=Code Editing. Redefined. + # Exec=codium %F + # GenericName=Text Editor + # Icon=vscodium + # Keywords=vscode + # MimeType=text/plain;inode/directory + # Name=VSCodium + # StartupNotify=true + # StartupWMClass=codium-url-handler + # Type=Application + # Version=1.4 - # Work around wrong wmclass - # https://github.com/microsoft/vscode/issues/129953 - # https://github.com/VSCodium/vscodium/issues/1414 - #!! Keep updated with upstream desktop file - #?? cat /etc/profiles/per-user/USER/share/applications/codium.desktop - # ".local/share/applications/codium.desktop".text = '' - # [Desktop Entry] - # Actions=new-empty-window - # Categories=Utility;TextEditor;Development;IDE - # Comment=Code Editing. Redefined. - # Exec=codium %F - # GenericName=Text Editor - # Icon=vscodium - # Keywords=vscode - # MimeType=text/plain;inode/directory - # Name=VSCodium - # StartupNotify=true - # StartupWMClass=codium-url-handler - # Type=Application - # Version=1.4 - - # [Desktop Action new-empty-window] - # Exec=codium --new-window %F - # Icon=vscodium - # Name=New Empty Window - # ''; - }; + # [Desktop Action new-empty-window] + # Exec=codium --new-window %F + # Icon=vscodium + # Name=New Empty Window + # ''; }; }; } diff --git a/options/custom/programs/waybar/default.nix b/options/custom/programs/waybar/default.nix index 23d3c02..438893f 100644 --- a/options/custom/programs/waybar/default.nix +++ b/options/custom/programs/waybar/default.nix @@ -357,9 +357,9 @@ in { #?? text #?? tooltip #?? class - home.file = { + xdg.configFile = { # Return inhibit idle status - ".config/waybar/scripts/inhibitor.sh" = { + "waybar/scripts/inhibitor.sh" = { executable = true; text = '' #! /usr/bin/env ${bash} @@ -377,7 +377,7 @@ in { }; # Return tailscale status - ".config/waybar/scripts/vm.sh" = { + "waybar/scripts/vm.sh" = { executable = true; text = '' #! /usr/bin/env ${bash} @@ -404,7 +404,7 @@ in { }; # Return tailscale status - ".config/waybar/scripts/vpn.sh" = { + "waybar/scripts/vpn.sh" = { executable = true; text = '' #! /usr/bin/env ${bash} diff --git a/options/custom/services/clipcat.nix b/options/custom/services/clipcat.nix index dbd6473..b7d6216 100644 --- a/options/custom/services/clipcat.nix +++ b/options/custom/services/clipcat.nix @@ -17,8 +17,8 @@ in { services.clipcat.enable = true; # https://github.com/xrelkd/clipcat?tab=readme-ov-file#configuration - home-manager.users.${config.custom.username}.home.file = { - ".config/clipcat/clipcatd.toml".text = '' + home-manager.users.${config.custom.username}.xdg.configFile = { + "clipcat/clipcatd.toml".text = '' daemonize = false max_history = 100 @@ -30,7 +30,7 @@ in { enable_http = false ''; - ".config/clipcat/clipcat-menu.toml".text = '' + "clipcat/clipcat-menu.toml".text = '' finder = "custom_finder" [custom_finder] diff --git a/options/custom/services/easyeffects.nix b/options/custom/services/easyeffects.nix index 4697d24..2217aae 100644 --- a/options/custom/services/easyeffects.nix +++ b/options/custom/services/easyeffects.nix @@ -15,9 +15,16 @@ in { ### PRESETS ### # https://github.com/Digitalone1/EasyEffects-Presets - home.file = with config.home-manager.users.${config.custom.username}.lib.file; { - ".config/easyeffects/input".source = mkOutOfStoreSymlink "/home/${config.custom.username}/SYNC/linux/config/easyeffects/input"; - ".config/easyeffects/output".source = mkOutOfStoreSymlink "/home/${config.custom.username}/SYNC/linux/config/easyeffects/output"; + xdg.configFile = with config.home-manager.users.${config.custom.username}.lib.file; { + "easyeffects/input" = { + force = true; + source = mkOutOfStoreSymlink "${config.custom.sync}/linux/config/easyeffects/input"; + }; + + "easyeffects/output" = { + force = true; + source = mkOutOfStoreSymlink "${config.custom.sync}/linux/config/easyeffects/output"; + }; }; }; } diff --git a/options/custom/services/samba.nix b/options/custom/services/samba.nix index 77ea898..5504036 100644 --- a/options/custom/services/samba.nix +++ b/options/custom/services/samba.nix @@ -24,7 +24,7 @@ in { # https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html settings = { Public.path = "/home/${config.custom.username}/Public"; - SYNC.path = "/home/${config.custom.username}/SYNC"; + SYNC.path = config.custom.sync; global = { "allow insecure wide links" = "yes"; diff --git a/options/custom/services/swayosd.nix b/options/custom/services/swayosd.nix index 27ba9b4..4c08523 100644 --- a/options/custom/services/swayosd.nix +++ b/options/custom/services/swayosd.nix @@ -15,6 +15,6 @@ in { ### THEME ### # https://github.com/ErikReider/SwayOSD/blob/main/data/style/style.scss #!! Options not yet available, files written directly - home.file.".config/swayosd/style.css".text = ''''; + xdg.configFile."swayosd/style.css".text = ''''; }; } diff --git a/options/custom/settings/xdg.nix b/options/custom/settings/xdg.nix index 33e3252..9610a93 100644 --- a/options/custom/settings/xdg.nix +++ b/options/custom/settings/xdg.nix @@ -137,7 +137,7 @@ in { userDirs = { enable = true; createDirectories = true; - templates = "/home/${config.custom.username}/SYNC/linux/config/templates"; + templates = "${config.custom.sync}/linux/config/templates"; extraConfig = { XDG_SCREENSHOTS_DIR = "${config.home-manager.users.${config.custom.username}.xdg.userDirs.pictures}/Screenshots";