about summary refs log tree commit diff
path: root/nixos/alpha/configuration.nix
blob: 32babda74ab468430eaac00f96cfbb7f4478ca4b (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
{ config, pkgs, lib, ... }:

{
  imports = [ ];

  security = {
    rtkit.enable = true;
    doas.enable = true;
    doas.wheelNeedsPassword = false;
    sudo.wheelNeedsPassword = false;
  };

  boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
  boot.kernelParams = [
    "nohibernate"
    "nmi_watchdog=0"
    "systemd.watchdog-device/dev/watchdog"
    "console=tty1"
  ];

  boot.initrd.supportedFilesystems = [ "zfs" ];
  boot.supportedFilesystems = [ "zfs" ];
  boot.zfs.enableUnstable = true;

  # GRUB bootloader
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.grub = {
    enable = true;
    version = 2;

    efiSupport = true;
    configurationLimit = 10;
    device = "nodev";
    useOSProber = true;
    copyKernels = true;
    extraEntries = ''
      # os-prober cannot detect QubesOS
      # We don't want to set any complex parameters here,
      # So load the qubes grub instead.
      menuentry "Qubes" {
        search --set=root --fs-uuid C5C1-09F1
        configfile ($root)/EFI/qubes/grub.cfg
      }

      menuentry "Reboot" {
        reboot
      }
      menuentry "Shutdown" {
        halt
      }
    '';
  };

  boot.initrd.postDeviceCommands = lib.mkAfter ''
    zfs rollback -r rpool/local/root@blank
  '';

  networking.hostName = "alpha";
  networking.hostId = "641a7b10";

  networking.networkmanager.enable = true;
  networking.useDHCP = false;
  networking.firewall.enable = true;

  i18n.defaultLocale = "en_US.UTF-8";
  i18n.inputMethod.enabled = "kime";
  i18n.inputMethod.kime.extraConfig = ''
    engine:
      global_hotkeys:
        C-Space:
          behavior: !Toggle
          - Hangul
          - Latin
          result: Consume
        AltR:
          behavior: !Ignore
          - Hangul
          - Latin
          result: Bypass
  '';

  console.keyMap = "us";
  console.colors = [
    "151515"
    "cf6a4c"
    "99ad6a"
    "dfa358"
    "8197bf"
    "b3a3ff"
    "8fbfdc"
    "cbc0ab"
    "333333"
    "d98870"
    "adbd88"
    "e5b579"
    "9aaccc"
    "c2b5ff"
    "a5cce3"
    "d5cdbc"
  ];

  time.timeZone = "Asia/Seoul";

  environment.systemPackages = with pkgs; [ gcc git gnumake ];

  services.zfs.trim.enable = true;
  services.zfs.autoScrub.enable = true;
  services.zfs.autoScrub.pools = [ "rpool" ];

  services.openssh.enable = true;
  services.openssh.settings.passwordAuthentication = false;
  services.openssh.hostKeys = [
    {
      path = "/persist/ssh/ssh_host_ed25519_key";
      type = "ed25519";
    }
    {
      path = "/persist/ssh/ssh_host_rsa_key";
      type = "rsa";
      bits = 4096;
    }
  ];

  sound.enable = false;

  services.pipewire = {
    enable = true;

    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };

  hardware.bluetooth.enable = true;

  services.printing.enable = true;
  services.printing.drivers = [ pkgs.gutenprint pkgs.samsung-unified-linux-driver pkgs.brgenml1lpr pkgs.brgenml1cupswrapper ];

  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem
    (lib.getName pkg) [
    "samsung-UnifiedLinuxDriver"
    "brgenml1lpr"
  ];

  services.pcscd.enable = true;

  programs.dconf.enable = true;
  services.gnome.gnome-keyring.enable = true;

  services.greetd = {
    enable = true;
    vt = 2;

    settings.default_session.command = "${pkgs.greetd.tuigreet}/bin/tuigreet -t -c sway";
  };

  services.journald.extraConfig = lib.mkForce "";

  systemd.extraConfig = "RebootWatchdogSec=5";

  fonts = {
    fontDir.enable = true;

    fonts = with pkgs; [
      cozette
      dina-font
      envypn-font
      nanum
      sarasa-gothic
      siji
      jetbrains-mono
      tamzen
      twemoji-color-font
      emacs-all-the-icons-fonts
      (nerdfonts.override { fonts = [ "Iosevka" "JetBrainsMono" ]; })
    ];

    fontconfig = {
      enable = true;

      defaultFonts = {
        serif = [
          "Sarasa Gothic C"
          "Sarasa Gothic J"
          "Sarasa Gothic K"
        ];

        sansSerif = [
          "Sarasa Gothic C"
          "Sarasa Gothic J"
          "Sarasa Gothic K"
        ];

        monospace = [
          "Dina"
          "Terminus"
          "Iosevka Nerd Font"
          "JetBrainsMono Nerd Font"
        ];

        emoji = [
          "Siji"
          "Twitter Color Emoji"
        ];
      };
    };
  };

  programs = {
    sway.enable = true;
    sway.extraPackages = lib.mkForce [ ];

    zsh.enable = true;
    zsh.enableCompletion = false;
  };

  hardware.opengl.enable = true;
  hardware.opengl.driSupport32Bit = true;
  hardware.opengl.extraPackages = with pkgs; [ vaapiVdpau libvdpau-va-gl ];

  xdg.portal = {
    enable = true;
    extraPortals = with pkgs; [
      xdg-desktop-portal-gtk
      xdg-desktop-portal-wlr
    ];
  };

  sops.defaultSopsFile = ./secrets/secrets.yaml;
  sops.secrets.root-password.neededForUsers = true;
  sops.secrets.sefidel-password.neededForUsers = true;

  users.mutableUsers = false;

  fileSystems."/persist".neededForBoot = true;

  users.users = {
    root.passwordFile = config.sops.secrets.root-password.path;
    sefidel = {
      isNormalUser = true;
      shell = pkgs.zsh;
      passwordFile = config.sops.secrets.sefidel-password.path;

      extraGroups = [
        "wheel"
        "audio"
        "networkmanager"
      ];
    };
  };

  # This value determines the NixOS release with which your system is to be
  # compatible, in order to avoid breaking some software such as database
  # servers. You should change this only after NixOS release notes say you
  # should.
  system.stateVersion = "22.05"; # Did you read the comment?
}