summaryrefslogtreecommitdiff
path: root/hosts/demiurge/default.nix
blob: 236c726b765fc35a0ed3f0816ac7a2abb6d56565 (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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
{
  config,
  home-manager,
  lib,
  pkgs,
  inputs,
  llama-cpp,
  ...
}:

{
  imports = [
    ./hardware.nix
    home-manager.nixosModules.default
  ];

  # nixpkgs stuff
  nixpkgs = {
    config = {
      # selectively allow unfree packages
      allowUnfreePredicate =
        pkg:
        builtins.elem (lib.getName pkg) [
          "open-webui"
          "steam"
          "steam-unwrapped"
        ];

      # selectively allow insecure packages
      permittedInsecurePackages = [
        "dotnet-sdk-6.0.428"
        "aspnetcore-runtime-6.0.36"
      ];

      cudaSupport = false;
    };

    overlays = [
      (self: super: {
        alvr = super.alvr.overrideAttrs (old: {
          buildInputs = old.buildInputs ++ [
            super.android-tools
            super.usbutils
          ];
          nativeBuildInputs = old.nativeBuildInputs ++ [ super.makeWrapper ];
          postInstall = (old.postInstall or "") + ''
            wrapProgram $out/bin/alvr_dashboard --prefix PATH : "${
              super.lib.makeBinPath [
                super.android-tools
                super.usbutils
              ]
            }"
          '';
        });
      })
    ];
  };

  # decrypt agenix secrets
  age.secrets = {
    wg0_demiurge.file = ../../secrets/wg0_demiurge.age;
    tailscale_demiurge.file = ../../secrets/tailscale_demiurge.age;
  };

  # boot options
  boot = {
    kernel.sysctl = {
      "net.ipv4.ip_forward" = true;
      "net.ipv6.conf.all.forwarding" = true;
    };

    kernelPackages = pkgs.linuxPackages_6_12;

    loader = {
      systemd-boot.enable = true;
      efi.canTouchEfiVariables = true;
    };

    supportedFilesystems = [ "zfs" ];

    zfs = {
      devNodes = "/dev/disk/by-partuuid";
      extraPools = [
        "data_nvme"
        "data_wd"
      ];
      forceImportRoot = false;
    };
  };

  # disable wifi and open some ports
  networking = {
    hostName = "demiurge";
    hostId = "cafebabe";

    # I like my ethX/wlanX names
    usePredictableInterfaceNames = false;

    wireless.enable = false;

    firewall = {
      allowedTCPPorts = [
        22
        80
        443
      ];
      allowedUDPPorts = [ 51413 ];
    };

    interfaces.eth0 = {
      ipv4.addresses = [
        {
          address = "192.168.1.2";
          prefixLength = 24;
        }
      ];
    };
    defaultGateway = {
      address = "192.168.1.1";
      interface = "eth0";
    };

    # mullvad
    wg-quick.interfaces.wg0 = {
      address = [
        "10.68.117.111/32"
        "fc00:bbbb:bbbb:bb01::5:756e/128"
      ];
      privateKeyFile = config.age.secrets.wg0_demiurge.path;

      # supposed to be done by tailscale instead \_(:/)_/
      postUp = ''
        ip route add 100.64.0.0/24 dev tailscale0
        ip route add 100.100.100.100/32 dev tailscale0
      '';
      postDown = ''
        ip route del 100.64.0.0/24 dev tailscale0
        ip route del 100.100.100.100/32 dev tailscale0
      '';

      peers = [
        {
          allowedIPs = [
            "0.0.0.0/0"
            "::0/0"
          ];
          endpoint = "45.134.142.206:51820";
          publicKey = "H5t7PsMDnUAHrR8D2Jt3Mh6N6w43WmCzrOHShlEU+zw=";
        }
      ];
    };
  };

  # Set your time zone.
  time.timeZone = "America/Toronto";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";
  console = {
    font = "Lat2-Terminus16";
  };

  # enable flakes and nix cli
  nix.settings.experimental-features = [
    "nix-command"
    "flakes"
  ];

  # Define a user account.
  users.users = {
    vin = {
      isNormalUser = true;

      extraGroups = [
        "transmission"
        "wheel"
      ];

      shell = pkgs.zsh;

      openssh.authorizedKeys.keys = [
        "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEvM0xCLziR+ZT/SYE1aZM6dklbw4fEC17TWqbADIZRH vin@demiurge"
      ];

      packages = with pkgs; [
        alvr
        bs-manager
        (llama-cpp.packages.x86_64-linux.rocm.override { useMetalKit = false; useVulkan = true; })
        #(vllm.override { cudaSupport = false; rocmSupport = true; gpuTargets = [ "gfx906" "gfx1100" ]; })
      ];
    };

    radarr.extraGroups = [ "transmission" ];
    sonarr.extraGroups = [ "transmission" ];
  };

  # default packages for both me and root
  environment = {
    systemPackages = with pkgs; [
      doas-sudo-shim
      git
      wget
    ];

    pathsToLink = [ "/share/zsh" ];
  };

  # enable bluetooth and add some udev rules
  hardware = {
    bluetooth.enable = true;
    flipperzero.enable = true;
    keyboard.qmk.enable = true;
  };

  programs = {
    # for gtk in home-manager
    dconf.enable = true;

    # gpg
    gnupg.agent = {
      enable = true;
      enableSSHSupport = false;
      pinentryPackage = pkgs.pinentry-rofi;
      settings.default-cache-ttl = 600;
    };

    # disable nano. I don't like nano.
    nano.enable = false;

    # steam, proprietary. I sometimes like playing nonfree games too.
    steam.enable = true;

    # configuration in home-manager
    zsh.enable = true;
    zsh.promptInit = "PS1='$ '";
  };

  security = {
    # I prefer doas over sudo for simplicity
    doas = {
      enable = true;
      extraRules = [
        {
          users = [ "vin" ];
          keepEnv = true;
          persist = true;
        }
      ];
    };
    sudo.enable = false;

    # needed to give realtime privileges to pipewire
    rtkit.enable = true;
  };

  services = {
    # dns
    unbound = {
      enable = true;
      settings = {
        server = {
          interface = [
            "127.0.0.1"
            "100.64.0.2"
            #"fd00:b0ba:cafe:babe::2"
            "::1"
          ];
          access-control = [
            "0.0.0.0/0 allow"
            "::0/0 allow"
          ];

          hide-identity = true;
          hide-version = true;

          # Synthesize NXDOMAINs from DNSSEC NSEC chains.
          # https://tools.ietf.org/html/rfc8198
          aggressive-nsec = false;

          module-config = "\"respip validator iterator\"";

          local-data = [
            "\"saklas.epistemia. 86400 IN A 100.64.0.1\""
            "\"demiurge.epistemia. 86400 IN A 100.64.0.2\""
            "\"hastur.epistemia. 86400 IN A 100.64.0.3\""
            "\"iphonebob.epistemia. 86400 IN A 100.64.0.4\""
            "\"lab.epistemia. 86400 IN A 100.64.0.5\""
          ];

          local-zone = [
            "\"saklas.epistemia.\" redirect"
            "\"demiurge.epistemia.\" redirect"
            "\"hastur.epistemia.\" redirect"
            "\"iphonebob.epistemia.\" redirect"
            "\"lab.epistemia.\" redirect"
          ];
        };

        # hagezi for dns-based adblocking (in addition to others)
        rpz = {
          name = "hagezi.ultimate";
          zonefile = "hagezi.ultimate";
          url = "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/rpz/ultimate.txt";
        };

        # go through mullvad for regular dns queries
        forward-zone = {
          name = ".";
          forward-addr = [ "194.242.2.2" ];
        };
      };
    };

    # vpn
    tailscale = {
      enable = true;
      authKeyFile = config.age.secrets.tailscale_demiurge.path;
      disableTaildrop = true;
      disableUpstreamLogging = true;
      extraSetFlags = [ "--advertise-exit-node" ];
      #extraUpFlags = [ "--login-server=https://headscale.13f0.net" ];
      extraUpFlags = [ "--login-server=https://controlplane.tailscale.com" ];
      openFirewall = true;
      useRoutingFeatures = "both";
    };

    # automatically scrub zfs pools (every week by default)
    zfs.autoScrub.enable = true;

    # media server
    jellyfin = {
      enable = true;
      openFirewall = true;
    };

    lidarr = {
      enable = true;
      openFirewall = true;
    };

    prowlarr = {
      enable = true;
      openFirewall = true;
    };

    radarr = {
      enable = true;
      openFirewall = true;
    };

    sonarr = {
      enable = true;
      openFirewall = true;
    };

    transmission = {
      enable = true;
      downloadDirPermissions = "770";
      openPeerPorts = true;
      user = "vin";

      settings = {
        download-dir = "/data_wd/torrents/complete/";
        incomplete-dir = "/data_wd/torrents/incomplete/";
        incomplete-dir-enabled = true;
        peer-port = 51413;
        umask = 2;
      };
    };

    # graphical input
    libinput = {
      enable = true;

      mouse.accelProfile = "flat";

      touchpad = {
        accelProfile = "flat";
        tapping = true;
        tappingButtonMap = "lrm";
      };
    };

    # music streaming to phone
    navidrome = {
      enable = true;
      settings = {
        MusicFolder = "/data_wd/music";
        EnableInsightsCollector = false;
      };
    };

    # reverse proxy
    nginx = {
      enable = true;

      defaultListenAddresses = [
        "100.64.0.2"
        #"10.0.13.2"
        #"fd00:b0ba:cafe:babe::2"
      ];

      recommendedGzipSettings = true;
      recommendedOptimisation = true;
      recommendedProxySettings = true;
      recommendedTlsSettings = true;

      virtualHosts = {
        "searx.demiurge.epistemia" = {
          addSSL = true;
          sslCertificate = "/var/demiurge.epistemia.crt";
          sslCertificateKey = "/var/demiurge.epistemia.key";
          locations."/".proxyPass = "http://127.0.0.1:8081";
        };

        "redlib.demiurge.epistemia" = {
          addSSL = true;
          sslCertificate = "/var/demiurge.epistemia.crt";
          sslCertificateKey = "/var/demiurge.epistemia.key";
          locations."/".proxyPass = "http://127.0.0.1:8085";
        };

        "llm.demiurge.epistemia" = {
          addSSL = true;
          sslCertificate = "/var/demiurge.epistemia.crt";
          sslCertificateKey = "/var/demiurge.epistemia.key";
          locations."/" = {
            proxyPass = "http://127.0.0.1:8083";
            proxyWebsockets = true;
          };
        };

        "navidrome.demiurge.epistemia" = {
          addSSL = true;
          sslCertificate = "/var/demiurge.epistemia.crt";
          sslCertificateKey = "/var/demiurge.epistemia.key";
          locations."/".proxyPass = "http://127.0.0.1:4533";
        };

        "sdui.demiurge.epistemia" = {
          addSSL = true;
          sslCertificate = "/var/demiurge.epistemia.crt";
          sslCertificateKey = "/var/demiurge.epistemia.key";
          locations."/" = {
            proxyPass = "http://127.0.0.1:7860";
            proxyWebsockets = true;
          };
        };
      };
    };

    # ssh
    openssh = {
      enable = true;

      listenAddresses = [
        { addr = "127.0.0.1"; port = 22; }
        { addr = "192.168.1.2"; port = 22; }
        { addr = "100.64.0.2"; port = 22; }
      ];

      settings = {
        KbdInteractiveAuthentication = false;
        PasswordAuthentication = true;
        PermitRootLogin = "no";
        X11Forwarding = true;
      };
    };

    # llm
    open-webui = {
      enable = true;
      environment = {
        REQUESTS_CA_BUNDLE = "/etc/ssl/certs/ca-bundle.crt";
        WEBUI_AUTH = "False";
      };
      port = 8083;
    };

    # for yubikey
    pcscd.enable = true;

    # sound. for some reason, pipewire enabled itself when I tried
    # using pulseaudio and home-manager, so had to disable pulseaudio.
    pipewire = {
      enable = true;
      alsa.enable = true;
      audio.enable = true;
      pulse.enable = true;
      wireplumber = {
        enable = true;
        extraConfig = {
          "51-set-default-eq.conf" = {
            text = ''
              monitor.rules = [
                {
                  matches = [
                    {
                      # This rule matches the node with the name of your sink (node 35)
                      "node.name" = "effect_input.eq6"
                    }
                  ]
                  actions = {
                    update-props = {
                      # This sets a very high priority, making it the default.
                      # Standard hardware is usually around 1000.
                      "priority.session" = 2001
                    }
                  }
                }
              ]
            '';
          };
        };
      };
    };

    # reddit
    redlib = {
      enable = true;

      address = "127.0.0.1";
      port = 8085;

      settings = {
        # Instance-specific settings
        # Enable SFW-only mode for the instance
        REDLIB_SFW_ONLY = false;
        # Set a banner message for the instance
        REDLIB_BANNER = "";
        # Disable search engine indexing
        REDLIB_ROBOTS_DISABLE_INDEXING = true;
        # Set the Pushshift frontend for "removed" links
        REDLIB_PUSHSHIFT_FRONTEND = "undelete.pullpush.io";

        # Default user settings
        # Set the default theme (options: system, light, dark, black, dracula, nord, laserwave, violet, gold, rosebox, gruvboxdark, gruvboxlight)
        REDLIB_DEFAULT_THEME = "black";
        # Set the default front page (options: default, popular, all)
        REDLIB_DEFAULT_FRONT_PAGE = "default";
        # Set the default layout (options: card, clean, compact)
        REDLIB_DEFAULT_LAYOUT = "compact";
        # Enable wide mode by default
        REDLIB_DEFAULT_WIDE = true;
        # Set the default post sort method (options: hot, new, top, rising, controversial)
        REDLIB_DEFAULT_POST_SORT = "hot";
        # Set the default comment sort method (options: confidence, top, new, controversial, old)
        REDLIB_DEFAULT_COMMENT_SORT = "confidence";
        # Enable blurring Spoiler content by default
        REDLIB_DEFAULT_BLUR_SPOILER = false;
        # Enable showing NSFW content by default
        REDLIB_DEFAULT_SHOW_NSFW = false;
        # Enable blurring NSFW content by default
        REDLIB_DEFAULT_BLUR_NSFW = false;
        # Enable HLS video format by default
        REDLIB_DEFAULT_USE_HLS = false;
        # Hide HLS notification by default
        REDLIB_DEFAULT_HIDE_HLS_NOTIFICATION = false;
        # Disable autoplay videos by default
        REDLIB_DEFAULT_AUTOPLAY_VIDEOS = false;
        # Define a default list of subreddit subscriptions (format: sub1+sub2+sub3)
        REDLIB_DEFAULT_SUBSCRIPTIONS = "ergomechkeyboards+localllama+elitedangerous";
        # Define a default list of subreddit filters (format: sub1+sub2+sub3)
        REDLIB_DEFAULT_FILTERS = "popular+all+funny+memes";
        # Hide awards by default
        REDLIB_DEFAULT_HIDE_AWARDS = true;
        # Hide sidebar and summary
        REDLIB_DEFAULT_HIDE_SIDEBAR_AND_SUMMARY = false;
        # Disable the confirmation before visiting Reddit
        REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION = false;
        # Hide score by default
        REDLIB_DEFAULT_HIDE_SCORE = false;
        # Enable fixed navbar by default
        REDLIB_DEFAULT_FIXED_NAVBAR = true;
      };
    };

    # monero node
    monero = {
      enable = true;
      dataDir = "/data_wd/monero";
    };

    # searching
    searx = {
      enable = true;

      settings = {
        use_default_settings = false;
        general.debug = true;

        search.default_lang = "en";

        server = {
          base_url = "https://searx.demiurge.epistemia";
          bind_address = "127.0.0.1";
          port = 8081;
          secret_key = "sJ8oFeH9sC+wriftl2DqVaPC0QDoBDBpqrcOw4Ixw1M=";
        };

        ui.theme_args.simple_style = "dark";

        enabled_plugins = [
          "Hostnames plugin"
          "Open Access DOI rewrite"
          "Tracker URL remover"
        ];

        hostnames = {
          replace = {
            "(.*\.)?youtube\.com$" = "yewtu.be";
            "(.*\.)?youtu\.be$" = "yewtu.be";
            "(.*\.)?reddit\.com$" = "redlib.demiurge.epistemia";
            "(.*\.)?redd\.it$" = "redlib.demiurge.epistemia";
          };

          remove = [
            "geeksforgeeks.org"
            "tutorialpoint.com"
            "chegg.com"
            "numerade.com"
            "study.com"
          ];
        };

        engines = [
          {
            name = "arch linux wiki";
            engine = "archlinux";
            shortcut = "al";
            categories = "it";
          }

          {
            name = "arxiv";
            engine = "arxiv";
            shortcut = "arx";
            timeout = 4.0;
            categories = "science";
          }

          {
            name = "wikipedia";
            engine = "wikipedia";
            shortcut = "wp";
            # add "list" to the array to get results in the results list
            display_type = "infobox";
            categories = "general";
          }

          {
            name = "btdigg";
            engine = "btdigg";
            shortcut = "bt";
            categories = "files";
          }

          {
            name = "cppreference";
            engine = "cppreference";
            shortcut = "cpp";
            paging = false;
            categories = "it";
          }

          {
            name = "free software directory";
            engine = "mediawiki";
            shortcut = "fsd";
            categories = [
              "it"
              "software wikis"
            ];
            base_url = "https://directory.fsf.org/";
            search_type = "title";
            timeout = 5.0;
            about = {
              website = "https://directory.fsf.org/";
              wikidata_id = "Q2470288";
            };
          }

          {
            name = "gentoo";
            engine = "mediawiki";
            shortcut = "ge";
            categories = [
              "it"
              "software wikis"
            ];
            base_url = "https://wiki.gentoo.org/";
            api_path = "api.php";
            search_type = "text";
            timeout = 10;
          }

          {
            name = "gitlab";
            engine = "gitlab";
            base_url = "https://gitlab.com";
            shortcut = "gl";
            about = {
              website = "https://gitlab.com/";
              wikidata_id = "Q16639197";
            };
          }

          {
            name = "github";
            engine = "github";
            shortcut = "gh";
          }

          {
            name = "codeberg";
            # https://docs.searxng.org/dev/engines/online/gitea.html
            engine = "gitea";
            base_url = "https://codeberg.org";
            shortcut = "cb";
          }

          {
            name = "gitea.com";
            engine = "gitea";
            base_url = "https://gitea.com";
            shortcut = "gitea";
          }

          {
            name = "google images";
            engine = "google_images";
            shortcut = "goi";
          }

          {
            name = "google scholar";
            engine = "google_scholar";
            shortcut = "gos";
          }

          {
            name = "invidious";
            engine = "invidious";
            base_url = [
              "https://invidious.demiurge.epistemia"
            ];
            shortcut = "iv";
            timeout = 3.0;
          }

          {
            name = "library genesis";
            engine = "xpath";
            search_url = "https://libgen.is/search.php?req={query}";
            url_xpath = "//a[contains(@href,\"book/index.php?md5\")]/@href";
            title_xpath = "//a[contains(@href,\"book/\")]/text()[1]";
            content_xpath = "//td/a[1][contains(@href,\"=author\")]/text()";
            categories = "files";
            timeout = 7.0;
            shortcut = "lg";
            about = {
              website = "https://libgen.fun/";
              wikidata_id = "Q22017206";
              official_api_documentation = "";
              use_official_api = false;
              require_api_key = false;
              results = "HTML";
            };
          }

          {
            name = "z-library";
            engine = "zlibrary";
            shortcut = "zlib";
            categories = "files";
            timeout = 7.0;
          }

          {
            name = "nyaa";
            engine = "nyaa";
            shortcut = "nt";
          }

          {
            name = "openlibrary";
            engine = "openlibrary";
            shortcut = "ol";
            timeout = 5;
          }

          {
            name = "stackoverflow";
            engine = "stackexchange";
            shortcut = "st";
            api_site = "stackoverflow";
            categories = [
              "it"
              "q&a"
            ];
          }

          {
            name = "askubuntu";
            engine = "stackexchange";
            shortcut = "ubuntu";
            api_site = "askubuntu";
            categories = [
              "it"
              "q&a"
            ];
          }

          {
            name = "superuser";
            engine = "stackexchange";
            shortcut = "su";
            api_site = "superuser";
            categories = [
              "it"
              "q&a"
            ];
          }

          {
            name = "nixos.discourse";
            engine = "discourse";
            shortcut = "dnos";
            base_url = "https://discourse.nixos.org";
            categories = [
              "it"
              "q&a"
            ];
          }

          {
            name = "unsplash";
            engine = "unsplash";
            shortcut = "us";
          }

          {
            name = "wiby";
            engine = "json_engine";
            paging = true;
            weight = 0.5;
            search_url = "https://wiby.me/json/?q={query}&p={pageno}";
            url_query = "URL";
            title_query = "Title";
            content_query = "Snippet";
            categories = [
              "general"
              "web"
            ];
            shortcut = "wib";
            about.website = "https://wiby.me/";
          }

          {
            name = "wikibooks";
            engine = "mediawiki";
            weight = 0.5;
            shortcut = "wb";
            categories = [
              "general"
              "wikimedia"
            ];
            base_url = "https://{language}.wikibooks.org/";
            search_type = "text";
            about = {
              website = "https://www.wikibooks.org/";
              wikidata_id = "Q367";
            };
          }

          {
            name = "wiktionary";
            engine = "mediawiki";
            shortcut = "wt";
            categories = [
              "dictionaries"
              "wikimedia"
            ];
            base_url = "https://{language}.wiktionary.org/";
            search_type = "text";
            about = {
              website = "https://www.wiktionary.org/";
              wikidata_id = "Q151";
            };
          }

          {
            name = "wikiversity";
            engine = "mediawiki";
            weight = 0.5;
            shortcut = "wv";
            categories = [
              "general"
              "wikimedia"
            ];
            base_url = "https://{language}.wikiversity.org/";
            search_type = "text";
            about = {
              website = "https://www.wikiversity.org/";
              wikidata_id = "Q370";
            };
          }

          {
            name = "peertube";
            engine = "peertube";
            shortcut = "ptb";
            paging = true;
            # alternatives see = "https://instances.joinpeertube.org/instances
            # base_url = "https://tube.4aem.com
            categories = "videos";
            timeout = 6.0;
          }

          {
            name = "brave";
            engine = "brave";
            shortcut = "br";
            time_range_support = true;
            paging = true;
            categories = [
              "general"
              "web"
            ];
            brave_category = "search";
          }

          {
            name = "brave.images";
            engine = "brave";
            network = "brave";
            shortcut = "brimg";
            categories = [
              "images"
              "web"
            ];
            brave_category = "images";
          }

          {
            name = "sourcehut";
            shortcut = "srht";
            engine = "xpath";
            paging = true;
            search_url = "https://sr.ht/projects?page={pageno}&search={query}";
            results_xpath = "(//div[@class=\"event-list\"])[1]/div[@class=\"event\"]";
            url_xpath = "./h4/a[2]/@href";
            title_xpath = "./h4/a[2]";
            content_xpath = "./p";
            first_page_num = 1;
            categories = [
              "it"
              "repos"
            ];
            about = {
              website = "https://sr.ht";
              wikidata_id = "Q78514485";
              official_api_documentation = "https://man.sr.ht/";
              use_official_api = false;
              require_api_key = false;
              results = "HTML";
            };
          }
        ];

        doi_resolvers = {
          "oadoi.org" = "https://oadoi.org/";
          "doi.org" = "https://doi.org/";
          "sci-hub.se" = "https://sci-hub.se/";
          "sci-hub.st" = "https://sci-hub.st/";
          "sci-hub.ru" = "https://sci-hub.ru/";
        };

        default_doi_resolver = "sci-hub.st";
      };
    };

    # udev rules
    udev = {
      enable = true;
      extraRules = ''
        # Oculus Quest 2
        SUBSYSTEM=="usb", ATTR{idVendor}=="2833", ATTR{idProduct}=="0186", MODE="0660",
        GROUP="input", SYMLINK+="ocuquest%n"
      '';
    };

    # to get startx and use amdgpu driver
    # WM in home-manager
    xserver = {
      enable = true;
      autorun = false;
      displayManager.startx.enable = true;
      modules = [ pkgs.xf86_input_wacom ];
      videoDrivers = [ "amdgpu" ];
      wacom.enable = true;
    };
  };

  # extra systemd stuff
  systemd.services = {
    nginx.after = [ "tailscaled-autoconnect.service" ];
  };

  # create caches and use mandoc
  documentation.man = {
    enable = true;
    generateCaches = true;
    man-db.enable = false;
    mandoc.enable = true;
  };

  system.stateVersion = "24.05";
}