aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/desktop.nix
blob: 0c8f287b8a6f98c83eab4342640f757e677bfd7a (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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
{
  config,
  lib,
  pkgs,
  ...
}: let
  inherit (lib) mkOption mkIf types optionals;
  cnf = config.cynerd.desktop;
in {
  options = {
    cynerd.desktop = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Enable my desktop";
      };
      laptop = mkOption {
        type = types.bool;
        default = false;
        description = "The desktop requires Laptop extensions";
      };
    };
  };

  config = mkIf cnf.enable {
    hardware = {
      opengl = {
        driSupport = true;
        driSupport32Bit = true;
      };
      bluetooth.enable = mkIf cnf.laptop true;
    };

    programs = {
      sway = {
        enable = true;
        wrapperFeatures.gtk = true;
        extraPackages = with pkgs;
          [
            gnome.dconf-editor
            glib
            gsettings-desktop-schemas
            sysstat
            wofi
            rofimoji
            wev
            waybar
            swaybackground
            myswaylock

            alacritty
            gnome.nautilus

            kanshi
            wdisplays
            wayvnc
            wl-mirror
            slurp
            grim
            wf-recorder
            wl-clipboard
            wl-color-picker
            swayidle
            dunst
            libnotify

            resources

            isync
            msmtp
            notmuch
            astroid
            taskwarrior
            vdirsyncer
            #khal
            #khard
            gnupg
            pinentry-gnome3
            pinentry-curses
            (pass.withExtensions (exts: [
              exts.pass-otp
              #exts.pass-audit
            ]))
            nextcloud-client

            chromium
            ferdium
            signal-desktop
            libreoffice
            mupdf
            zathura
            pdfgrep

            xdg-utils
            xdg-launch
            mesa-demos
            vulkan-tools

            pulsemixer
            mpd
            mpc-cli
            ncmpcpp
            feh
            shotwell
            id3lib
            vlc
            mpv
            youtube-dl
            spotify

            nordic
            nordzy-cursor-theme
            nordzy-icon-theme
            gnome.adwaita-icon-theme
            vanilla-dmz
            sound-theme-freedesktop
            gnome.gnome-characters
            gucharmap

            (sdcv.withDictionaries [stardict-en-cz stardict-de-cz stardict-cz])

            samba
            cifs-utils

            tigervnc
            freerdp
            plasma5Packages.kdeconnect-kde

            hdparm
            ethtool
            multipath-tools
            usb-modeswitch
            v4l-utils

            # Calculating
            python3Packages.numpy
            python3Packages.sympy
            python3Packages.matplotlib

            # Creation
            simple-scan
            audacity
            gimp
            inkscape
            blender
            kdenlive

            # GStreamer
            gst_all_1.gst-libav
            gst_all_1.gst-plugins-bad
            gst_all_1.gst-plugins-base
            gst_all_1.gst-plugins-good
            gst_all_1.gst-plugins-ugly
            gst_all_1.gst-plugins-viperfx

            # Writing
            typst
            typst-fmt
            typst-live
            typst-lsp
            vale

            # Gnome utils
            gnome-firmware
            #gaphor

            # CAD
            freecad
            kicad
            sweethome3d.application
            qelectrotech
          ]
          ++ (optionals cnf.laptop [
            # Power management
            powertop
            acpi
          ]);
      };

      firefox = {
        enable = true;
        languagePacks = ["en-US" "cs"];
        nativeMessagingHosts.packages = with pkgs; [browserpass];
      };

      light.enable = mkIf cnf.laptop true;

      nix-ld = {
        enable = true;
        libraries = with pkgs; [xorg.libXpm];
      };

      usbkey = {
        enable = true;
        devicesUUID = [
          "de269652-2070-46b2-84f8-409dc9dd50ee"
          "16a089d0-a663-4047-bd88-3885dd7fdee2"
        ];
      };

      gnupg.agent = {
        enable = true;
        enableSSHSupport = true;
        enableBrowserSocket = true;
      };
    };

    xdg = {
      portal = {
        enable = true;
        wlr.enable = true;
        extraPortals = with pkgs; [xdg-desktop-portal-gtk];
      };
      mime.defaultApplications = {
        "text/html" = ["firefox.desktop"];
        "application/pdf" = ["org.pwmt.zathura.desktop"];
        "image/jpeg" = ["feh.desktop"];
        "image/png" = ["feh.desktop"];
        "image/svg" = ["feh.desktop"];
      };
    };

    services = {
      # Autologin on the first TTY
      getty = {
        extraArgs = ["--skip-login"];
        loginProgram = "${pkgs.bash}/bin/sh";
        loginOptions = toString (pkgs.writeText "login-program.sh" ''
          if [[ "$(tty)" == '/dev/tty1' ]]; then
            ${pkgs.shadow}/bin/login -f cynerd;
          else
            ${pkgs.shadow}/bin/login;
          fi
        '');
      };

      gpm.enable = true; # mouse in buffer
      udev.extraRules = ''
        ACTION=="add|change", KERNEL=="sd*[!0-9]", ATTR{queue/scheduler}="bfq"
      '';
      xserver.xkb.options = "grp:alt_shift_toggle,caps:escape";

      # Gnome crypto services (GnuPG)
      dbus.packages = [pkgs.gcr];

      pipewire = {
        enable = true;
        alsa.enable = true;
        alsa.support32Bit = true;
        pulse.enable = true;
        extraConfig.pipewire."10-zeroconf" = {
          "context.modules" = [{name = "libpipewire-module-zeroconf-discover";}];
        };
      };

      upower.enable = true;
      hardware.openrgb = {
        enable = true;
        package = pkgs.openrgb-with-all-plugins;
      };

      printing = {
        enable = true;
        drivers = with pkgs; [
          gutenprint
          gutenprintBin
          cnijfilter2
        ];
      };
      avahi.enable = true;
      samba-wsdd = {
        enable = true;
        discovery = true;
      };
      davfs2.enable = true;

      locate.enable = true;
    };

    # Beneficial for Pipewire
    security.rtkit.enable = true;

    # Local share (avahi, samba)
    networking.firewall = {
      allowedTCPPorts = [5357];
      allowedUDPPorts = [3702];
    };

    fonts.packages = with pkgs; [
      (nerdfonts.override {fonts = ["Hack"];})
      arkpandora_ttf
      corefonts
      dejavu_fonts
      font-awesome
      freefont_ttf
      hack-font
      liberation_ttf
      libertine
      noto-fonts
      noto-fonts-emoji
      terminus_font_ttf
      ubuntu_font_family
      unifont
    ];

    documentation = {
      enable = true;
      man.enable = true;
      info.enable = true;
    };

    # VTI settings
    console = {
      colors = [
        "2e3440"
        "3b4252"
        "434c5e"
        "4c566a"
        "d8dee9"
        "e5e9f0"
        "eceff4"
        "8fbcbb"
        "88c0d0"
        "81a1c1"
        "5e81ac"
        "bf616a"
        "d08770"
        "ebcb8b"
        "a3be8c"
        "b48ead"
      ];
      earlySetup = true;
      useXkbConfig = true;
    };

    # Support running app images
    boot.binfmt.registrations.appimage = {
      wrapInterpreterInShell = false;
      interpreter = "${pkgs.appimage-run}/bin/appimage-run";
      recognitionType = "magic";
      offset = 0;
      mask = ''\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\xff'';
      magicOrExtension = ''\x7fELF....AI\x02'';
    };
  };
}