summaryrefslogtreecommitdiff
path: root/nix/modules/home/user.nix
blob: d378fb672bd6b9e983abbdfbe55e948dc8e1363d (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
{ lib, config, super, pkgs, ... }:
{
  home = {
    activation.startup-files = lib.hm.dag.entryAfter [ "installPackages" ] ''
      if [ ! -d "/home/${config.monorepo.vars.userName}/email/${config.monorepo.vars.internetName}/" ]; then
        mkdir -p /home/${config.monorepo.vars.userName}/email/${config.monorepo.vars.internetName}/
      fi

      if [ ! -d "/home/${config.monorepo.vars.userName}/music" ]; then
        mkdir -p /home/${config.monorepo.vars.userName}/music
      fi

      if [ ! -d /home/${config.monorepo.vars.userName}/org ]; then
        mkdir -p /home/${config.monorepo.vars.userName}/org
      fi

      if [ ! -d /home/${config.monorepo.vars.userName}/src ]; then
        mkdir -p /home/${config.monorepo.vars.userName}/src
      fi

      touch /home/${config.monorepo.vars.userName}/org/agenda.org
      touch /home/${config.monorepo.vars.userName}/org/notes.org
    '';

    enableNixpkgsReleaseCheck = false;
    username = config.monorepo.vars.userName;
    homeDirectory = "/home/${config.monorepo.vars.userName}";
    stateVersion = "24.11";

    packages = with pkgs; (if config.monorepo.profiles.graphics.enable then [
      # wikipedia
      # kiwix kiwix-tools
      gnupg
      unzip
      mupdf
      zathura

      fzf
      # passwords
      age
      sops

      # formatting
      ghostscript
      texliveFull
      pandoc

      # Emacs Deps
      graphviz
      jq

      # Apps
      # octaveFull
      grim
      swww
      vim
      kotatogram-desktop
      tg
      qwen-code
      element-desktop
      signal-desktop
      signal-cli
      thunderbird
      jami

      # Sound/media
      pavucontrol
      alsa-utils
      imagemagick
      ffmpeg
      helvum

      # Net
      curl
      rsync
      gitFull
      iamb
      ungoogled-chromium

      # Tor
      torsocks
      tor-browser

      # For transfering secrets onto new system
      stow

      # fonts
      nerd-fonts.iosevka
      noto-fonts
      noto-fonts-cjk-sans
      noto-fonts-color-emoji
      fira-code
      font-awesome_6
      victor-mono
      (aspellWithDicts
        (dicts: with dicts; [ en en-computers en-science ]))

      # Misc.
      pinentry-gnome3
      x11_ssh_askpass
      xdg-utils
      acpilight
      pfetch
      libnotify
      htop

      (pkgs.writeShellScriptBin "help"
        ''
          #!/usr/bin/env sh
          # Portable, colored, nicely aligned alias list

          # Generate uncolored alias pairs
          aliases=$(cat <<'EOF'
          ${let aliases = config.programs.zsh.shellAliases;
            in lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value:
              "${name} -> ${value}"
            ) aliases)}
          EOF
                                         )

          # Align and color using awk
          echo "$aliases" | awk '
          BEGIN {
              GREEN="\033[0;32m";
              YELLOW="\033[0;33m";
              RESET="\033[0m";
              maxlen=0;
                         }
          {
              # Split line on " -> "
              split($0, parts, / -> /);
              name[NR]=parts[1];
              cmd[NR]=parts[2];
              if(length(parts[1])>maxlen) maxlen=length(parts[1]);
          }
          END {
              for(i=1;i<=NR;i++) {
                  # printf with fixed width for alias name
                  printf "%s%-*s%s -> %s%s%s\n", GREEN, maxlen, name[i], RESET, YELLOW, cmd[i], RESET;
                  }
          }'
        '')

      (writeShellScriptBin "remote-build"
        ''
          #!/bin/bash
          nixos-rebuild --sudo --ask-sudo-password --target-host "$1" switch --flake $HOME/monorepo/nix#spontaneity
        ''
      )
      (writeShellScriptBin "install-vps"
        ''
          #!/bin/bash
          nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config $HOME/monorepo/nix/systems/spontaneity/hardware-configuration.nix --flake $HOME/monorepo/nix#spontaneity --target-host "$1"
        '')
      (writeShellScriptBin "secrets"
        ''
          #!/bin/bash
          cd "$HOME/secrets"
          git pull # repo is over LAN
          stow */ # manage secrets with gnu stow
          cd "$HOME"
        '')
      (writeShellScriptBin "spontaneity-ci"
        ''
          #!/bin/bash
          nixos-rebuild build-vm --flake $HOME/monorepo/nix#spontaneity && QEMU_OPTS="-serial stdio" ./result/bin/run-spontaneity-vm 2>&1 | tee vm-boot.log'')
    ] else [
      pfetch
      # net
      curl
      torsocks
      rsync
    ]);
  };

  services = {
    gpg-agent = {
      pinentry.package = pkgs.pinentry-emacs;
      enable = true;
      extraConfig = ''
        allow-emacs-pinentry
        allow-loopback-pinentry
      '';
    };
  };
  xdg.mimeApps = {
    enable = lib.mkDefault config.monorepo.profiles.graphics.enable;
    defaultApplications = {
      "x-scheme-handler/mailto" = "emacsclient-mail.desktop";
      "text/html" = "librewolf.desktop";
      "text/xml" = "librewolf.desktop";
      "application/xhtml+xml" = "librewolf.desktop";
      "x-scheme-handler/http" = "librewolf.desktop";
      "x-scheme-handler/https" = "librewolf.desktop";
      "x-scheme-handler/about" = "librewolf.desktop";
      "x-scheme-handler/unknown" = "librewolf.desktop";
    };
  };

  programs.bash.enable = true;
  fonts.fontconfig.enable = true;
}