Files
nixos/home.shared.nix
2026-07-28 19:07:30 -04:00

125 lines
3.3 KiB
Nix

{ config, lib, pkgs, hostname, userConfig, ... }:
let
onePassPath = if pkgs.stdenv.isDarwin
then "${userConfig.homeDirectory}/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
else "${userConfig.homeDirectory}/.1password/agent.sock";
ghosttyPkg = if pkgs.stdenv.isDarwin
then pkgs."ghostty-bin"
else pkgs.ghostty;
rebuildCmd = if pkgs.stdenv.isDarwin
then "darwin-rebuild"
else "nixos-rebuild";
in {
home.stateVersion = lib.mkDefault "26.05";
home.username = userConfig.username;
home.homeDirectory = userConfig.homeDirectory;
home.sessionVariables.SSH_AUTH_SOCK = onePassPath;
home.sessionVariables.CLAUDE_CONFIG_DIR = "${config.xdg.configHome}/claude";
xdg.enable = true;
xdg.configFile."ssh.conf".source = ./config.ssh.conf;
xdg.configFile."claude/settings.json".source = ./config.claude.json;
xdg.configFile."1Password/ssh/agent.toml".text = ''
[[ssh-keys]]
item = "${userConfig._1PassKeyName}"
vault = "${userConfig._1PassKeyVault}"
'';
programs.tmux.enable = true;
programs.fastfetch.enable = true;
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases = {
ll = "ls -l";
gst = "git status";
nix-update = "sudo ${rebuildCmd} switch --flake ~/nixos#${hostname}";
home-update = "home-manager switch --flake ~/nixos#${userConfig.username}@${hostname}";
};
};
programs.starship = {
enable = true;
enableZshIntegration = true;
# Optional custom settings (translates to ~/.config/starship.toml)
settings = {
# Line 1: ➜ folder git:(branch) [status]
format = "$character$directory$git_branch";
# Show current directory name only
directory = {
style = "bold cyan";
truncation_length = 1;
truncate_to_repo = false;
};
# git:(branch) styling
git_branch = {
format = "[git:\\([$branch](red)\\)](bold blue) ";
};
# Bottom line prompt arrow
character = {
success_symbol = "[➜](bold green)";
error_symbol = "[➜](bold red)";
vicmd_symbol = "[➜](bold yellow)";
};
git_status = {
disabled = false;
};
# Nix shell indicator module configuration
nix_shell = {
symbol = "❄️ ";
format = "via [$symbol$state]($style) ";
};
};
};
programs.ssh = {
enable = true;
enableDefaultConfig = false;
extraConfig = builtins.readFile ./config.ssh.conf;
settings = {
"*" = {
ControlMaster = "auto";
ControlPath = "~/.ssh/master-%r@%h:%p";
ControlPersist = "10m";
IdentityAgent = "\"${onePassPath}\"";
};
};
};
programs.git = {
enable = true;
settings = {
user.name = userConfig.gitName;
user.email = userConfig.gitEmail;
init.defaultBranch = "main";
pull.rebase = false;
core.sshCommand = "ssh";
};
};
programs.ghostty = {
enable = true;
package = ghosttyPkg;
enableBashIntegration = true;
enableZshIntegration = true;
settings = {
macos-icon = "chalkboard";
keybind = [
"home=text:\\x01" # Ctrl-A -> beginning of line
"end=text:\\x05" # Ctrl-E -> end of line
"delete=text:\\x7f"
];
};
};
}