about summary refs log tree commit diff
path: root/modules/user/aszlig/profiles/workstation/default.nix
blob: e08b9b305d14d2da8c0990f6cc8aa4729962cc47 (plain) (blame)
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
{ pkgs, config, lib, ... }:

let
  cfg = config.vuizvui.user.aszlig.profiles.workstation;
  inherit (config.services.xserver) xrandrHeads;
in {
  options.vuizvui.user.aszlig.profiles.workstation = {
    enable = lib.mkEnableOption "Workstation profile for aszlig";
  };

  config = lib.mkIf cfg.enable {
    vuizvui.user.aszlig.profiles.base.enable = true;

    boot.kernelParams = [ "panic=1800" ];
    boot.tmp.cleanOnBoot = true;

    # Allow sync, sak and unraw
    boot.kernel.sysctl."kernel.sysrq" = 20;

    environment.systemPackages = with lib; let
      mkRandrConf = acc: rcfg: acc ++ singleton {
        name = rcfg.output;
        value = "--output ${lib.escapeShellArg rcfg.output} --preferred"
              + optionalString rcfg.primary " --primary"
              + optionalString (acc != []) " --right-of '${(head acc).name}'";
      };
      randrConf = map (getAttr "value") (foldl mkRandrConf [] xrandrHeads);
      xreset = pkgs.writeScriptBin "xreset" ''
        #!${pkgs.stdenv.shell}
        ${pkgs.xorg.xrandr}/bin/xrandr ${concatStringsSep " " randrConf}
      '';
    in [
      xreset
      config.boot.kernelPackages.perf
      (pkgs.vuizvui.aszlig.psi.override {
        jid = "aszlig@aszlig.net";
        resource = config.networking.hostName;
      })
    ] ++ import ./packages.nix pkgs;

    vuizvui.requiresTests = [
      ["vuizvui" "aszlig" "programs" "psi"]
    ];

    environment.pathsToLink = lib.singleton "/share/chromium/extensions";

    # The default theme hurts my eyes.
    environment.variables.GTK_THEME = "Adwaita:dark";

    vuizvui.lazyPackages = import ./lazy-packages.nix pkgs;

    sound.enable = true;

    hardware = {
      pulseaudio.enable = true;
      pulseaudio.package = pkgs.pulseaudioFull;
      opengl = {
        driSupport32Bit = true;
      };
    };

    fonts = {
      fontDir.enable = true;
      enableGhostscriptFonts = true;
      fontconfig.useEmbeddedBitmaps = true;
      fonts = lib.singleton pkgs.ultimate-oldschool-pc-font-pack;
    };

    vuizvui.user.aszlig.services.i3.enable = true;
    vuizvui.user.aszlig.services.vlock.enable = true;
    vuizvui.user.aszlig.services.vlock.user = "aszlig";

    vuizvui.user.aszlig.programs.flameshot.enable = true;
    vuizvui.user.aszlig.programs.mpv.enable = true;

    vuizvui.user.aszlig.programs.git.enable = true;
    vuizvui.user.aszlig.programs.git.delta.enable = true;
    vuizvui.user.aszlig.programs.git.settings = {
      color.ui = "auto";
      user.email = "aszlig@nix.build";
      user.name = "aszlig";
      user.signingkey = "DD526BC7767DBA2816C095E5684089CE67EBB691";
      gpg.program = "${pkgs.gnupg}/bin/gpg";
      push.default = "current";
      tar."tar.xz".command = "${pkgs.xz}/bin/xz -c";
      rebase.autosquash = true;
      rerere.enabled = true;
      rerere.autoupdate = true;
      commit.gpgsign = true;
      pull.rebase = false;
      branch.sort = "-committerdate";

      merge.tool = "vimdiff3";
      merge.conflictstyle = "diff3";
      mergetool.keepBackup = false;

      delta = {
        commit-decoration-style = "bold yellow box";
        file-decoration-style = "blue ul";
        file-style = "bold blue ul";
        hunk-header-style = "line-number dim italic syntax";
        hunk-header-decoration-style = "blue";
        hunk-header-line-number-style = "cyan";
        plus-style = "syntax auto";
        minus-style = "syntax auto";
        line-numbers = true;
      };
    };

    vuizvui.hardware.gameController."03000000ff1100004133000010010000" = {
      name = "PS2 Controller";
      mapping = {
        a = "b2";
        b = "b1";
        x = "b3";
        y = "b0";
        back = "b8";
        start = "b9";
        leftshoulder = "b6";
        rightshoulder = "b7";
        leftstick = "b10";
        rightstick = "b11";
        leftx = "a0";
        lefty = "a1";
        rightx = "a3";
        righty = "a2";
        lefttrigger = "b4";
        righttrigger = "b5";
        dpup = "h0.1";
        dpleft = "h0.8";
        dpdown = "h0.4";
        dpright = "h0.2";
      };
    };

    vuizvui.programs.gnupg.enable = true;
    vuizvui.programs.gnupg.agent.enable = true;
    vuizvui.programs.gnupg.agent.sshSupport = true;
    vuizvui.programs.gnupg.agent.scdaemon.enable = true;

    vuizvui.system.kernel.zswap.enable = true;

    location.latitude = 48.4284;
    location.longitude = 10.866;

    # I occasionally run wg setups and I don't really care whether they're
    # online or not.
    systemd.network.wait-online.anyInterface = true;

    services = {
      openssh.enable = true;

      xfs.enable = false;

      gpm = {
        enable = true;
        protocol = "exps2";
      };

      printing.enable = true;
      printing.drivers = [ pkgs.gutenprint pkgs.hplip ];

      pcscd.enable = true;
      pcscd.plugins = [ pkgs.ccid pkgs.pcsc-cyberjack ];

      udev.extraRules = ''
        # aXbo S.P.A.C.
        SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", \
          ATTRS{serial}=="0001", OWNER="aszlig", SYMLINK+="axbo"
        # Enttec DMX device
        SUBSYSTEM=="usb*|tty", ACTION=="add|change", ATTRS{idVendor}=="0403", \
          ATTRS{idProduct}=="6001", OWNER="aszlig"
      '';

      redshift = {
        enable = true;
        temperature.day = 5500;
        temperature.night = 3500;
        brightness.night = "0.5";
      };

      xserver = {
        enable = true;

        displayManager = {
          lightdm.enable = true;
          defaultSession = "none+i3";
          sessionCommands = ''
            ${pkgs.xorg.xrdb}/bin/xrdb "${pkgs.writeText "xrdb.config" ''
              XTerm*termName:            xterm-direct
              XTerm*directColor:         true
              XTerm*faceName:            MxPlus IBM VGA 8x16
              XTerm*faceSize:            12
              XTerm*renderFont:          true
              XTerm*saveLines:           10000
              XTerm*bellIsUrgent:        true
              XTerm*background:          black
              XTerm*foreground:          grey

              XTerm*backarrowKeyIsErase: true
              XTerm*ptyInitialErase:     true
            ''}"
          '';
        } // lib.optionalAttrs (config.boot.initrd.luks.devices != {}) {
          # All of my workstations are single-user machines with encrypted root
          # and swap, so there is no need to prompt another time for a password
          # or passphrase.
          autoLogin.enable = true;
          autoLogin.user = "aszlig";
        };
      };
    };

    nixpkgs.overlays = lib.singleton (lib.const (super: {
      xterm = super.vuizvui.aszlig.xterm;
    }));

    users.users.aszlig = {
      uid = 1000;
      isNormalUser = true;
      description = "aszlig";
      extraGroups = [ "wheel" "video" ];
    };
  };
}