summaryrefslogtreecommitdiff
path: root/kj-laptop01/home.nix
blob: 78a6667f851a98e4622e81c24200fe3ba3e487d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
  config,
  pkgs,
  ...
}:
{
  home.username = "kjtsanaktsidis";
  home.homeDirectory = "/home/kjtsanaktsidis";
  home.stateVersion = "25.05";

  programs.home-manager.enable = true;

  # Install packages
  home.packages = with pkgs; [
    htop
    git
    zellij
    tmu
  ];

  # Configure sops for home-manager
  sops = {
    age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
    defaultSopsFile = ./secrets.yaml;
    secrets = {
      kj_id_ed25519 = {
        path = "${config.home.homeDirectory}/.ssh/id_ed25519";
      };
      kj_gpg_private_key = {
        path = "${config.home.homeDirectory}/.gnupg/private-key.asc";
      };
    };
  };

  # Helix editor configuration
  programs.helix = {
    enable = true;
    defaultEditor = true;
  };

  # SSH public key (private key is managed by sops)
  home.file.".ssh/id_ed25519.pub" = {
    text = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMtGcEXu5S/0zsF6Suxc65DmGFGt1JWRnqadoVhErOed kjtsanaktsidis@KJMacbookGroq.local";
  };

  # Zsh configuration
  programs.zsh = {
    enable = true;
    history = {
      size = 1000000;
      save = 1000000;
      append = true;
      extended = true;
      ignoreSpace = false;
      ignoreDups = false;
    };

    initContent = ''
      # Initialize completion system
      autoload -Uz compinit
      compinit

      # Initialize prompt system
      autoload -Uz promptinit
      promptinit

      # Set options
      setopt extendedglob nomatch notify

      # Define gentoo prompt theme
      prompt_gentoo_help () {
        cat <<'EOF'
      This prompt is color-scheme-able.  You can invoke it thus:

        prompt gentoo [<promptcolor> [<usercolor> [<rootcolor>]]]

      EOF
      }

      prompt_gentoo_setup () {
        local prompt_gentoo_prompt=''${1:-'blue'}
        local prompt_gentoo_user=''${2:-'green'}
        local prompt_gentoo_root=''${3:-'red'}

        if [ "$USER" = 'root' ]
        then
          local base_prompt="%B%F{$prompt_gentoo_root}%m%k "
        else
          local base_prompt="%B%F{$prompt_gentoo_user}%n@%m%k "
        fi
        local post_prompt="%b%f%k"

        local path_prompt="%B%F{$prompt_gentoo_prompt}%1~"
        typeset -g PS1="$base_prompt$path_prompt %# $post_prompt"
        typeset -g PS2="$base_prompt$path_prompt %_> $post_prompt"
        typeset -g PS3="$base_prompt$path_prompt ?# $post_prompt"
      }

      # Register the prompt with promptinit
      prompt_themes+=( gentoo )

      # Use the gentoo prompt
      prompt gentoo
    '';
  };

  # FZF with standard keybindings
  programs.fzf = {
    enable = true;
    enableZshIntegration = true;
  };

  programs.gpg = {
    enable = true;
    homedir = "${config.home.homeDirectory}/.gnupg";
  };
  services.gpg-agent = {
    enable = true;
  };
  home.activation.importGpgPrivateKey = config.lib.dag.entryAfter ["sops-nix" "onFilesChange"] ''
    export GNUPGHOME="${config.programs.gpg.homedir}"
    $DRY_RUN_CMD ${pkgs.gnupg}/bin/gpg --batch --verbose --trust-model always --import "${config.sops.secrets.kj_gpg_private_key.path}"
    echo "GPG private key imported from sops secret"
  '';
}