summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/default.nix
blob: 9161d887ff0ac0bf2388be7c158efbee3e5a66bb (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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
{ flake, userName, pkgs, customUtils, lib, config, ... }@inputs:
let
  cfg = config.home-manager.users.${userName};
  xmonad = import ./xmonad pkgs.haskellPackages;
  emacsclientDesktopItem = pkgs.makeDesktopItem {
    name = "emacsclient";
    genericName = "Text Editor";
    desktopName = "emacsclient";
    icon = "emacs";
    mimeType = "text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;";
    exec = "${config.home-manager.users.${userName}.programs.emacs.package}/bin/emacsclient -a \"\" %F";
  };
  emacsScratch = pkgs.stdenv.mkDerivation rec {
    pname = "scratch";
    version = "0077334cc299aa7885f804d88f52cdb1b35caf71";

    src = pkgs.fetchFromGitHub {
      owner = "ffevotte";
      repo = "scratch.el";
      rev = version;
      sha256 = "sha256-FUkKJ+1COGzgllzzv51yUIjMZI6slOFVExdwWl2ZEBA=";
    };

    phases = [ "installPhase" ];

    installPhase = ''
      mkdir -p $out/share/emacs/site-lisp
      cp $src/scratch.el $out/share/emacs/site-lisp/default.el
    '';
  };
  muteScript = pkgs.stdenv.mkDerivation {
    name = "mute";
    src = ./scripts/mute.zsh;

    buildInputs = with pkgs; [ makeWrapper ];

    phases = [ "installPhase" ];

    installPhase = ''
      mkdir -p $out/bin
      install -m 0755 $src $out/bin/mute
      wrapProgram $out/bin/mute \
        --prefix PATH : ${pkgs.zsh}/bin \
        --prefix PATH : ${pkgs.findutils}/bin \
        --prefix PATH : ${pkgs.util-linux}/bin \
        --prefix PATH : ${pkgs.coreutils}/bin \
        --prefix PATH : ${pkgs.pulseaudio}/bin
    '';
  };
  wrappedChrome = pkgs.runCommand "${pkgs.google-chrome.name}-wrapped" { buildInputs = with pkgs; [ makeWrapper ]; } ''
    mkdir -p "$out/bin"
    install -m 0755 ${pkgs.google-chrome}/bin/google-chrome-stable $out/bin/google-chrome
    wrapProgram $out/bin/google-chrome \
      --add-flags '--force-device-scale-factor=1.6'
  '';
  wrappedZulip = pkgs.runCommand "${pkgs.zulip.name}-wrapped" { buildInputs = with pkgs; [ makeWrapper ]; } ''
    mkdir -p "$out/bin"
    install -m 0755 ${pkgs.zulip}/bin/zulip $out/bin/zulip
    wrapProgram $out/bin/zulip \
      --add-flags '--force-device-scale-factor=1.6'
  '';
in {
  imports = with flake.nixosModules.userProfiles.${userName}; [
    mpv
  ];
  
  home-manager.users.${userName} = {
    programs = {
      ssh = {
        matchBlocks = import ./ssh-hosts.nix; # customUtils.nixImport { dir = ./ssh-hosts; };
        extraConfig = ''
          Match host uniworx3.ifi.lmu.de,uniworx4.ifi.lmu.de,uniworx5.ifi.lmu.de,uni2workgw.ifi.lmu.de,blackbeard.tcs.ifi.lmu.de,gitlab2.rz.ifi.lmu.de,oregon.tcs.ifi.lmu.de !exec "nc -z -w 1 %h %p &>/dev/null"
            ProxyJump remote.cip.ifi.lmu.de

          Host *
        '';
      };

      emacs = {
        enable = true;
        extraPackages = epkgs: with epkgs; [
          evil evil-dvorak undo-tree magit haskell-mode
          nix-mode yaml-mode json-mode shakespeare-mode
          smart-mode-line highlight-parentheses highlight-symbol
          notmuch ag sass-mode lua-mode fira-code-mode use-package
          use-package-ensure-system-package git-gutter emacsScratch
        ];
      };
      firefox = {
        enable = true;
        profiles.default = {
          settings = {
            "layout.css.devPixelsPerPx" = "1.75";
            "browser.tabs.drawInTitlebar" = false;
            "toolkit.legacyUserProfileCustomizations.stylesheets" = true;
            "dom.security.https_only_mode" = true;
          };
        };
      };

      alacritty = {
        enable = true;
        settings = import ./alacritty.nix;
      };

      zathura = {
        enable = true;
        package = pkgs.zathura.override { useMupdf = false; };
      };

      mpv.config = {
        demuxer-max-bytes = 1073741824;
        demuxer-max-back-bytes = 268435456;
      };

      autorandr = {
        enable = true;
        hooks.postswitch = {
          # "restart-compton" = "${pkgs.systemd}/bin/systemctl --user try-restart picom";
          "restart-trays" = ''
              ${pkgs.coreutils}/bin/sleep 5
              ${pkgs.systemd}/bin/systemctl --user try-restart trayer xmobar
            '';
        };
        profiles = customUtils.nixImport { dir = ./autorandr-profiles; };
      };

      zsh.initExtra = "source ${./zshrc}";
      zsh.dirHashes = {
        u2w = "$HOME/projects/uni2work";
        docs = "$HOME/documents";
        dl = "$HOME/Downloads";
        flk = "$HOME/config/nixos-flakes";
        fsk-timi = "$HOME/projects/21s/fsk-timi";
        fsk-timi-exam = "$HOME/projects/21s/fsk-timi-exam";
      };

      obs-studio = {
        enable = true;
        plugins = with pkgs; [];
      };
    };

    services = {
      dunst = {
        settings = import ./dunst-settings.nix inputs;
        iconTheme = cfg.gtk.iconTheme;
        enable = true;
      };
      emacs.enable = true;
      gpg-agent = {
        enable = true;
        enableSshSupport = true;
        extraConfig = ''
          pinentry-program ${pkgs.pinentry-gtk2}/bin/pinentry
          grab
        '';
      };
      pasystray.enable = true;
      udiskie = {
        enable = true;
        automount = false;
      };
      unclutter = {
        enable = true;
        timeout = 5;
      };
      network-manager-applet.enable = true;
      blueman-applet.enable = true;

      sxhkd = {
        enable = true;
        keybindings = {
          "button8" = "${muteScript}/bin/mute unmute";
          "@button8" = "${muteScript}/bin/mute mute";
          "button9" = "${pkgs.pulseaudio}/bin/pacmd set-sink-mute @DEFAULT_SINK@ 1";
          "@button9" = "${pkgs.pulseaudio}/bin/pacmd set-sink-mute @DEFAULT_SINK@ 0";
        };
      };
    };

    gtk = {
      enable = true;
      font.name = "DejaVu Sans 6";
      theme = {
        package = pkgs.equilux-theme;
        name = "Equilux-compact";
      };
      iconTheme = {
        package = pkgs.paper-icon-theme;
        name = "Paper";
      };
    };

    xsession = {
      enable = true;

      windowManager.command = "${xmonad}/bin/xmonad";

      initExtra = let
          lockScript = pkgs.writeScript "lock" ''
            #!${pkgs.stdenv.shell}
            ${pkgs.playerctl}/bin/playerctl -a pause
            exec ${pkgs.xsecurelock}/bin/xsecurelock
          '';
        in ''
             ${pkgs.coreutils}/bin/env XSECURELOCK_WANT_FIRST_KEYPRESS=1 XSECURELOCK_DIM_ALPHA=1 ${pkgs.xss-lock}/bin/xss-lock -l -n ${pkgs.xsecurelock}/libexec/xsecurelock/dimmer -- ${lockScript} &
             ${pkgs.xorg.xinput}/bin/xinput disable 'Synaptics TM3512-010'
             ${pkgs.xorg.xset}/bin/xset s 590 10
             ${pkgs.xorg.xmodmap}/bin/xmodmap -e 'keysym Caps_Lock = Multi_key'
           '';
    };

    xresources.properties = import ./xresources.nix;

    home = {
      packages = with pkgs; [
        fira-code powerline-fonts nerdfonts pavucontrol keepassxc
        youtube-dl sxiv xclip mumble pulseaudio-ctl libnotify synergy
        xorg.xbacklight screen-message pidgin-with-plugins
        google-play-music-desktop-player qt5ct playerctl evince
        thunderbird wrappedZulip zoom-us steam steam-run wireshark skype
        virt-manager rclone cached-nix-shell xournal discord xmonad
        worktime fira-code-symbols emacsclientDesktopItem libreoffice
        xournalpp wrappedChrome
      ];

      file = {
        ".emacs".source = ./emacs.el;
        ".backup-munin".source = ./backup-patterns;
        ".mozilla/firefox/default/chrome/userChrome.css".source = ./firefox-chrome.css;
        ".mozilla/firefox/default/chrome/userContent.css".source = ./firefox-content.css;
      };

      sessionVariables = {
        GDK_SCALE = 96.0 / 282.0;
        QT_AUTO_SCREEN_SCALE_FACTOR = 1;
        QT_QPA_PLATFORMTHEME = "qt5ct";
      };

      extraProfileCommands = ''
        export XDG_DATA_DIRS="${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}''${XDG_DATA_DIRS:+:''${XDG_DATA_DIRS}}"
      '';

      keyboard = {
        layout = "us";
        variant = "dvp";
        options = [ "ctl:nocaps" ];
      };
    };

    fonts.fontconfig.enable = true;

    systemd.user = import ./systemd.nix inputs;
  };
}