From 517b0a5981621768ab47eaeb2afd9aa44fcf385b Mon Sep 17 00:00:00 2001 From: Bun Date: Fri, 16 May 2025 02:45:17 -0400 Subject: [PATCH] Add SSH configuration, move more things to xdg dirs --- modules/home/default.nix | 1 - modules/home/programs/gui/obs/default.nix | 4 +- modules/home/programs/terminal/default.nix | 1 + .../home/programs/terminal/direnv/default.nix | 6 ++- .../programs/terminal/lazygit/default.nix | 6 ++- .../home/programs/terminal/neovim/default.nix | 8 ++-- .../home/programs/terminal/ranger/default.nix | 38 +++++++++---------- .../home/programs/terminal/ssh/default.nix | 19 +++++++++- .../home/programs/terminal/zoxide/default.nix | 6 ++- modules/home/services/mpd/default.nix | 6 ++- modules/home/settings/dconf/default.nix | 5 ++- modules/home/settings/default.nix | 1 + modules/home/{ => settings}/user/default.nix | 0 modules/home/settings/xdg/folders/default.nix | 1 + 14 files changed, 67 insertions(+), 35 deletions(-) rename modules/home/{ => settings}/user/default.nix (100%) diff --git a/modules/home/default.nix b/modules/home/default.nix index 526c689a..6527a8ba 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -5,7 +5,6 @@ ./programs ./services ./settings - ./user ./variables ./wms ]; diff --git a/modules/home/programs/gui/obs/default.nix b/modules/home/programs/gui/obs/default.nix index 15381818..bb593e4c 100644 --- a/modules/home/programs/gui/obs/default.nix +++ b/modules/home/programs/gui/obs/default.nix @@ -12,6 +12,8 @@ ]; }; - home.persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = [ "data/.config/obs-studio" ]; + home.persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = + with lib; with config.home; with config.xdg; + [ "data/${removePrefix "${homeDirectory}/" configHome}/obs-studio" ]; }; } diff --git a/modules/home/programs/terminal/default.nix b/modules/home/programs/terminal/default.nix index 5c0c5738..8589ca96 100644 --- a/modules/home/programs/terminal/default.nix +++ b/modules/home/programs/terminal/default.nix @@ -14,6 +14,7 @@ ./nh ./nix-index ./ranger + ./ssh ./tmux ./yt-dlp ./zoxide diff --git a/modules/home/programs/terminal/direnv/default.nix b/modules/home/programs/terminal/direnv/default.nix index 51eac95e..c0858a93 100644 --- a/modules/home/programs/terminal/direnv/default.nix +++ b/modules/home/programs/terminal/direnv/default.nix @@ -1,9 +1,11 @@ -{ config, ... }: +{ config, lib, ... }: { programs.direnv = { enable = true; nix-direnv.enable = true; }; - home.persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = [ "data/.local/share/direnv" ]; + home.persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = + with lib; with config.home; with config.xdg; + [ "data/${removePrefix "${homeDirectory}/" dataHome}/direnv" ]; } diff --git a/modules/home/programs/terminal/lazygit/default.nix b/modules/home/programs/terminal/lazygit/default.nix index 243ff7f3..cd0059c1 100644 --- a/modules/home/programs/terminal/lazygit/default.nix +++ b/modules/home/programs/terminal/lazygit/default.nix @@ -1,5 +1,7 @@ -{ config, ... }: +{ config, lib, ... }: { programs.lazygit.enable = true; - home.persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = [ "state/.local/state/lazygit" ]; + home.persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = + with lib; with config.home; with config.xdg; + [ "state/${removePrefix "${homeDirectory}/" stateHome}/lazygit" ]; } diff --git a/modules/home/programs/terminal/neovim/default.nix b/modules/home/programs/terminal/neovim/default.nix index 695c7491..78c5225b 100644 --- a/modules/home/programs/terminal/neovim/default.nix +++ b/modules/home/programs/terminal/neovim/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: { programs.neovim = { enable = true; @@ -103,7 +103,7 @@ set mouse=a set undofile - set undodir=$HOME/.local/share/nvim/undo + set undodir=${config.xdg.dataHome}/nvim/undo set undolevels=100 set undoreload=10000 @@ -115,6 +115,8 @@ home = { sessionVariables.MANPAGER = "nvim +Man!"; - persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = [ "state/.local/share/nvim/undo" ]; + persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = + with lib; with config.home; with config.xdg; + [ "state/${removePrefix "${homeDirectory}/" dataHome}/nvim/undo" ]; }; } diff --git a/modules/home/programs/terminal/ranger/default.nix b/modules/home/programs/terminal/ranger/default.nix index 9590fe17..49057d9a 100644 --- a/modules/home/programs/terminal/ranger/default.nix +++ b/modules/home/programs/terminal/ranger/default.nix @@ -1,4 +1,4 @@ -{ config, pkgsStable, ... }: +{ config, lib, pkgsStable, ... }: { programs.ranger = { enable = true; @@ -94,28 +94,28 @@ # Ranger's bookmarks and necessary tools home = { - file = { - ".local/share/ranger/bookmarks".text = '' + file = with lib; with config.home; with config.xdg; with config.xdg.userDirs; with config.xdg.userDirs.extraConfig; { + "${removePrefix "${homeDirectory}/" dataHome}/ranger/bookmarks".text = '' # Local files - h:${config.home.homeDirectory} - k:${config.home.homeDirectory}/Keepers - d:${config.home.homeDirectory}/Downloads - j:${config.home.homeDirectory}/Documents - p:${config.home.homeDirectory}/Photos - v:${config.home.homeDirectory}/Videos - n:${config.home.homeDirectory}/Projects/nixos-config - c:${config.home.homeDirectory}/.config - l:${config.home.homeDirectory}/.local - q:/persist + h:${homeDirectory} + k:${XDG_KEEPERS_DIR} + d:${download} + j:${documents} + p:${pictures} + v:${videos} + n:${XDG_PROJECTS_DIR}/nixos-config + c:${configHome} + l:${dataHome} + q:${XDG_PERSIST_DIR} w:/mnt # Remote files - N:${config.home.homeDirectory}/Network - H:${config.home.homeDirectory}/Network/Midas/ - K:${config.home.homeDirectory}/Network/Midas/Files - M:${config.home.homeDirectory}/Network/Midas/Music - V:${config.home.homeDirectory}/Network/Midas/Videos - P:${config.home.homeDirectory}/Network/Midas/Photos + N:${XDG_NETWORK_DIR}/ + H:${XDG_NETWORK_DIR}/Midas/ + K:${XDG_NETWORK_DIR}/Midas/Files + M:${XDG_NETWORK_DIR}/Midas/Music + V:${XDG_NETWORK_DIR}/Midas/Videos + P:${XDG_NETWORK_DIR}/Midas/Photos ''; }; packages = with pkgsStable; [ diff --git a/modules/home/programs/terminal/ssh/default.nix b/modules/home/programs/terminal/ssh/default.nix index 9356eee6..59bf3077 100644 --- a/modules/home/programs/terminal/ssh/default.nix +++ b/modules/home/programs/terminal/ssh/default.nix @@ -1,7 +1,24 @@ -{ ... }: +{ config, lib, ... }: { programs.ssh = { enable = true; addKeysToAgent = "yes"; + compression = true; + matchBlocks = with lib.hm.dag; { + nixfox = { + host = "*.nixfox.ca"; + user = config.home.username; + }; + midas = entryAfter [ "nixfox" ] { + hostname = "sv.nixfox.ca"; + }; + kitty = entryAfter [ "nixfox" ] { + hostname = "sv.nixfox.ca"; + port = 2222; + }; + prophet = entryAfter [ "nixfox" ] { + hostname = "mx.nixfox.ca"; + }; + }; }; } diff --git a/modules/home/programs/terminal/zoxide/default.nix b/modules/home/programs/terminal/zoxide/default.nix index 36c56d59..e6d3cb37 100644 --- a/modules/home/programs/terminal/zoxide/default.nix +++ b/modules/home/programs/terminal/zoxide/default.nix @@ -1,9 +1,11 @@ -{ config, ... }: +{ config, lib, ... }: { programs.zoxide.enable = true; home = { shellAliases.cd = "z"; - persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = [ "state/.local/share/zoxide" ]; + persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = + with lib; with config.home; with config.xdg; + [ "state/${removePrefix "${homeDirectory}/" dataHome}/zoxide" ]; }; } diff --git a/modules/home/services/mpd/default.nix b/modules/home/services/mpd/default.nix index c84ac9a7..e842508a 100644 --- a/modules/home/services/mpd/default.nix +++ b/modules/home/services/mpd/default.nix @@ -5,7 +5,7 @@ mpd = { enable = true; network.startWhenNeeded = true; - musicDirectory = "${config.home.homeDirectory}/Network/Midas/Music/NixBops"; + musicDirectory = "${config.xdg.userDirs.extraConfig.XDG_NETWORK_DIR}/Midas/Music/NixBops"; playlistDirectory = "${config.services.mpd.musicDirectory}/Playlists"; extraConfig = '' audio_output { @@ -18,6 +18,8 @@ mpd-discord-rpc.enable = true; }; - home.persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = [ "state/.local/share/mpd" ]; + home.persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = + with lib; with config.home; with config.xdg; + [ "state/${removePrefix "${homeDirectory}/" dataHome}/mpd" ]; }; } diff --git a/modules/home/settings/dconf/default.nix b/modules/home/settings/dconf/default.nix index 36fd2ab6..69c88c4b 100644 --- a/modules/home/settings/dconf/default.nix +++ b/modules/home/settings/dconf/default.nix @@ -8,7 +8,8 @@ uris = [ "qemu:///system" ]; }; }; - home.persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = with lib; with config.home; with config.xdg; - [ "games/${removePrefix "${homeDirectory}/" stateHome}/dconf" ]; + home.persistence."${config.xdg.userDirs.extraConfig.XDG_PERSIST_DIR}".directories = + with lib; with config.home; with config.xdg; + [ "state/${removePrefix "${homeDirectory}/" configHome}/dconf" ]; }; } diff --git a/modules/home/settings/default.nix b/modules/home/settings/default.nix index c34510b7..59cfe345 100644 --- a/modules/home/settings/default.nix +++ b/modules/home/settings/default.nix @@ -11,6 +11,7 @@ ./nix ./nixgl ./qt + ./user ./xdg ]; } diff --git a/modules/home/user/default.nix b/modules/home/settings/user/default.nix similarity index 100% rename from modules/home/user/default.nix rename to modules/home/settings/user/default.nix diff --git a/modules/home/settings/xdg/folders/default.nix b/modules/home/settings/xdg/folders/default.nix index 289e0094..38a53e7b 100644 --- a/modules/home/settings/xdg/folders/default.nix +++ b/modules/home/settings/xdg/folders/default.nix @@ -13,6 +13,7 @@ extraConfig = { XDG_GAMES_DIR = "${homeDirectory}/Games"; XDG_KEEPERS_DIR = "${homeDirectory}/Keepers"; + XDG_NETWORK_DIR = "${homeDirectory}/Network"; XDG_PERSIST_DIR = if !config.targets.genericLinux.enable then "/persist${homeDirectory}" else "${homeDirectory}/.stow"; XDG_PROJECTS_DIR = "${homeDirectory}/Projects"; XDG_SCREENSHOTS_DIR = "${config.xdg.userDirs.pictures}/Screenshots";