aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/desktop.nix
blob: 6979252fe0163aec26cee644f11ee02a369f9c02 (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
{
  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 {
    programs = {
      sway = {
        enable = true;
        wrapperFeatures.gtk = true;
        extraPackages = with pkgs;
          [
            gnome.dconf-editor
            glib
            gsettings-desktop-schemas
            i3blocks
            sysstat
            wofi
            rofimoji
            wev
            swaybackground
            myswaylock

            alacritty

            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-gnome
            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
            delft-icon-theme
            gnome.adwaita-icon-theme
            vanilla-dmz
            sound-theme-freedesktop
            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
            texlive.combined.scheme-full
            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
          ]);
      };
      vim.package = pkgs.vimHugeX;
      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];
      };
    };
    xdg.portal = {
      enable = true;
      wlr.enable = true;
      extraPortals = with pkgs; [xdg-desktop-portal-gtk];
    };
    xdg.mime.defaultApplications = {
      "text/html" = ["firefox.desktop"];
      "application/pdf" = ["org.pwmt.zathura.desktop"];
      "image/jpeg" = ["feh.desktop"];
      "image/png" = ["feh.desktop"];
      "image/svg" = ["feh.desktop"];
    };

    programs.usbkey = {
      enable = true;
      devicesUUID = [];
    };

    programs.gnupg.agent = {
      enable = true;
      enableSSHSupport = true;
      enableBrowserSocket = true;
    };
    services.dbus.packages = [pkgs.gcr];

    programs.kdeconnect.enable = true;

    services.pipewire = {
      enable = true;
      alsa.enable = true;
      alsa.support32Bit = true;
      pulse.enable = true;
    };
    environment.etc."pipewire/pipewire.conf.d/zeroconf.conf".text = ''
      context.modules = [
        { name = libpipewire-module-zeroconf-discover }
      ]
    '';
    security.rtkit.enable = true;

    services.printing = {
      enable = true;
      drivers = with pkgs; [
        gutenprint
        gutenprintBin
        cnijfilter2
      ];
    };

    services.avahi.enable = true;
    services.samba-wsdd = {
      enable = true;
      discovery = true;
    };
    networking.firewall.allowedTCPPorts = [5357];
    networking.firewall.allowedUDPPorts = [3702];

    fonts.packages = with pkgs; [
      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
    ];

    services.udev.extraRules = ''
      ACTION=="add|change", KERNEL=="sd*[!0-9]", ATTR{queue/scheduler}="bfq"
    '';
    hardware.opengl.driSupport = true;
    hardware.opengl.driSupport32Bit = true;

    hardware.bluetooth.enable = mkIf cnf.laptop true;

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

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

    services.snapper.configs = {
      home = {
        SUBVOLUME = "/home";
        ALLOW_GROUPS = ["users"];
        TIMELINE_CREATE = true;
        TIMELINE_CLEANUP = true;
      };
    };

    # Autologin on the first TTY
    services.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
      '');
    };

    # Leds group is required for light
    users.users.cynerd.extraGroups = ["leds"];

    # VTI settings
    console = {
      colors = [
        "2e3440"
        "3b4252"
        "434c5e"
        "4c566a"
        "d8dee9"
        "e5e9f0"
        "eceff4"
        "8fbcbb"
        "88c0d0"
        "81a1c1"
        "5e81ac"
        "bf616a"
        "d08770"
        "ebcb8b"
        "a3be8c"
        "b48ead"
      ];
      earlySetup = true;
      useXkbConfig = true;
    };
    services.xserver.xkb.options = "grp:alt_shift_toggle,caps:escape";
    services.gpm.enable = true;

    services.locate.enable = 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'';
    };
  };
}