From 7c283c61c43074f4a8fc8ab766fe90a413677e1b Mon Sep 17 00:00:00 2001 From: hektor Date: Sat, 11 Jul 2026 22:58:51 +0200 Subject: [PATCH] refactor: extract home directory path into 'home' --- home/modules/shell/bash.nix | 8 ++++---- modules/ssh/extract-keys.nix | 7 ++++--- modules/syncthing/default.nix | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/home/modules/shell/bash.nix b/home/modules/shell/bash.nix index 4697654..62ebf2b 100644 --- a/home/modules/shell/bash.nix +++ b/home/modules/shell/bash.nix @@ -7,7 +7,7 @@ let cfg = config.shell.bash; - inherit (config.home) username; + inherit (config.home) homeDirectory; in { options.shell.bash = { @@ -54,12 +54,12 @@ in ]; initExtra = '' - for f in /home/${username}/.bashrc.d/*; do + for f in ${homeDirectory}/.bashrc.d/*; do [ -f "$f" ] && source "$f" done - ${lib.optionalString cfg.aliases.all "source /home/${username}/.bash_aliases/all"} - ${lib.optionalString cfg.aliases.lang-js "source /home/${username}/.bash_aliases/lang-js"} + ${lib.optionalString cfg.aliases.all "source ${homeDirectory}/.bash_aliases/all"} + ${lib.optionalString cfg.aliases.lang-js "source ${homeDirectory}/.bash_aliases/lang-js"} ${cfg.extraInit} ''; diff --git a/modules/ssh/extract-keys.nix b/modules/ssh/extract-keys.nix index bcb144e..61cb754 100644 --- a/modules/ssh/extract-keys.nix +++ b/modules/ssh/extract-keys.nix @@ -2,12 +2,13 @@ let inherit (config.host) username; + home = config.users.users.${username}.home; in { config = lib.mkIf config.ssh.enable { system.activationScripts.extractSshKeys = lib.stringAfter [ "etc" ] '' HOST_KEY="/etc/ssh/ssh_host_ed25519_key.pub" - HOST_DIR="/home/${username}/nix/hosts/${config.networking.hostName}" + HOST_DIR="${home}/nix/hosts/${config.networking.hostName}" if [ -f "$HOST_KEY" ] && [ -d "$HOST_DIR" ]; then cp "$HOST_KEY" "$HOST_DIR/ssh_host.pub" @@ -17,8 +18,8 @@ in USER_KEY="" for candidate in \ - "/home/${username}/.ssh/id_ed25519_sk.pub" \ - "/home/${username}/.ssh/id_ed25519.pub"; do + "${home}/.ssh/id_ed25519_sk.pub" \ + "${home}/.ssh/id_ed25519.pub"; do if [ -f "$candidate" ]; then USER_KEY="$candidate" break diff --git a/modules/syncthing/default.nix b/modules/syncthing/default.nix index cbc2ff4..687a3dd 100644 --- a/modules/syncthing/default.nix +++ b/modules/syncthing/default.nix @@ -3,6 +3,7 @@ let cfg = config.syncthing; inherit (config.host) username; + home = config.users.users.${username}.home; deviceRegistry = import ./devices.nix; deviceName = lib.types.enum (builtins.attrNames deviceRegistry); @@ -48,7 +49,7 @@ in enable = true; user = username; group = username; - configDir = "/home/${username}/.local/state/syncthing"; + configDir = "${home}/.local/state/syncthing"; openDefaultPorts = true; settings = { devices = lib.mapAttrs (_: id: { inherit id; }) (lib.getAttrs referencedDevices deviceRegistry);