aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/desktop.nix
blob: 5208a3dc3e8c513f6df848deed51412604ff11e7 (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
{ config, lib, pkgs, ... }:

with lib;
let

  cnf = config.cynerd.desktop;

  autologinScript = pkgs.writeText "login-program.sh" ''
    if [[ "$(tty)" == '/dev/tty1' ]]; then
      ${pkgs.shadow}/bin/login -f cynerd;
    else
      ${pkgs.shadow}/bin/login;
    fi
  '';

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 {
    cynerd.hosts.enable = true;

    programs.sway.enable = true;
    programs.sway.wrapperFeatures.gtk = true;
    programs.sway.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

      isync msmtp notmuch astroid
      taskwarrior vdirsyncer khal khard
      gnupg pass pinentry-gnome pinentry-curses

      firefox chromium
      ferdium signal-desktop
      libreoffice
      mupdf pdfgrep

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

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

      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

      # Latex
      texlive.combined.scheme-full

    ] ++ (optionals cnf.laptop [
      # Power management
      powertop
      acpi
    ]);
    programs.vim.package = pkgs.vimHugeX;
    programs.shellrc.desktop = true;
    xdg.portal.enable = true;
    xdg.portal.wlr.enable = true;
    xdg.portal.extraPortals = with pkgs; [ xdg-desktop-portal-gtk ];
    xdg.mime.defaultApplications = {
      "text/html" = [ "firefox.desktop" ];
      "application/pdf" = [ "mupdf.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 ];

    services.pipewire = {
      enable = true;
      alsa.enable = true;
      alsa.support32Bit = true;
      pulse.enable = true;
      config.pipewire = {
        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.fonts = 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;

    documentation.man.man-db.enable = true;

    services.snapper.configs = {
      home = {
        subvolume = "/home";
        extraConfig = ''
          ALLOW_GROUPS="users"
          BACKGROUND_COMPARISON="yes"
          EMPTY_PRE_POST_CLEANUP="yes"
          EMPTY_PRE_POST_MIN_AGE="1800"
          FREE_LIMIT="0.2"
          NUMBER_CLEANUP="yes"
          NUMBER_LIMIT="50"
          NUMBER_LIMIT_IMPORTANT="10"
          NUMBER_MIN_AGE="1800"
          SPACE_LIMIT="0.5"
          TIMELINE_CLEANUP="yes"
          TIMELINE_CREATE="yes"
          TIMELINE_LIMIT_DAILY="10"
          TIMELINE_LIMIT_HOURLY="10"
          TIMELINE_LIMIT_MONTHLY="10"
          TIMELINE_LIMIT_WEEKLY="0"
          TIMELINE_LIMIT_YEARLY="10"
          TIMELINE_MIN_AGE="1800"
        '';
      };
    };

    # 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
      '');
    };

    # 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.xkbOptions = "grp:alt_shift_toggle,caps:escape";
    services.gpm.enable = true;

    services.locate.enable = true;

  };
}