aboutsummaryrefslogtreecommitdiff
path: root/nixos/default.nix
blob: 47eeca65513cfb07770fd125ed9f5aa9d8e65890 (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
{ config, lib, pkgs, inputs, ... }:
let 
  cfg = config.nixos; 
in
{
  imports = [
    ./bluetooth.nix
    ./osu.nix
    ./keyd.nix
    ./yubikey.nix
  ];

  options.nixos = with lib.options; {
    hostname = mkOption { 
      type = lib.types.str;
      description = "Hostname for the system";
      default = "nixos";
    };

    # timezone = mkOption {
    #   type = lib.types.str;
    #   description = "Fallback timezone if location cannot be determined";
    #   default = "America/New_York";
    # };

    username = mkOption {
      type = lib.types.str;
      description = "Username for the main user";
      default = "stefan";
    };

    shell = mkOption {
      type = lib.types.package;
      default = pkgs.zsh;
      description = "Interactive shell for main user";
    };

    wifi = mkOption {
      type = lib.types.bool;
      description = "Whether to enable wireless networking via NetworkManager";
      default = true;
    };
  };

  config = {
    # nixos = {
    # };
    nix = {
      settings.experimental-features = [ "nix-command" "flakes" ];
    };

    # time.timeZone = lib.mkDefault cfg.timezone;
    services.automatic-timezoned.enable = true;

    nixpkgs.config.allowUnfree = true;

    boot = {
      consoleLogLevel=0;
      initrd.verbose = false;
      initrd.systemd.enable = true; # required for early stuff
      kernelPackages = pkgs.linuxPackages_latest;
      kernelParams = ["quiet" "splash"  "rd.systemd.show_status=false" "rd.udev.log_level=3" "udev.log_priority=3" "boot.shell_on_fail"];
      loader = {
        timeout = 0;
        systemd-boot = {
          enable = true;
          consoleMode = "auto";
          editor = false;
        };
        efi.canTouchEfiVariables = true;
      };
      plymouth = {
        enable = true;
      };
    };

    networking = {
      hostName = cfg.hostname;
      networkmanager.enable = cfg.wifi;
    };

    documentation.dev.enable = true;

    users.users."${cfg.username}" = {
      isNormalUser = true;
      extraGroups = [
        "wheel"
        "input" # TODO: remove;
        "uinput"
        "networkmanager"
        "gamemode"
      ];
        # ++ (lib.optional cfg.wifi "networkmanager")
        # ++ (lib.optional cfg.gaming "gamemode");
      packages = with pkgs; [
        unzip
        tree
        ungoogled-chromium
      ];
      shell = cfg.shell;
    };

    environment.systemPackages = with pkgs; [
      neovim
      wl-clipboard
      wmenu
      gnupg
      pinentry-qt
      btop
      man-pages
      man-pages-posix
      cage
      zsh
      discord-ptb
    ]; # TODO


    services.greetd = {
      enable = false;
      settings = {
        initial_session = {
          command = "sway --unsupported-gpu";
          user = "${cfg.username}";
        };
        default_session = {
          command = "${pkgs.greetd.greetd}/bin/agreety --cmd 'sway --unsupported-gpu'"; 
        };
      };
    };

    programs.zsh = {
      enable = true;
      # TODO
      shellInit = ''
        # autoload -Uz add-zsh-hook # avoids an error with system prompt
      '';
      # promptInit = "";
    };
    # TODO
    programs.foot.enable = true;
    programs.foot.enableZshIntegration = false; # TODO: https://github.com/NixOS/nixpkgs/pull/409627
    programs.sway.enable = true;
    programs.sway.package = pkgs.sway;

    programs.steam = {
      enable = true;
    };
    programs.gamescope = {
      enable = true;
      capSysNice = true;
    };

    security = {
      polkit.enable = true;
      rtkit.enable = true;
      doas = {
        enable = true;
        extraRules = [{
          users = ["${cfg.username}"];
          keepEnv = true;
          persist = true;
        }];
      };
    };

		i18n.defaultLocale = "en_US.UTF-8";

		i18n.extraLocaleSettings = {
			LC_ADDRESS = "en_US.UTF-8";
			LC_IDENTIFICATION = "en_US.UTF-8";
			LC_MEASUREMENT = "en_US.UTF-8";
			LC_MONETARY = "en_US.UTF-8";
			LC_NAME = "en_US.UTF-8";
			LC_NUMERIC = "en_US.UTF-8";
			LC_PAPER = "en_US.UTF-8";
			LC_TELEPHONE = "en_US.UTF-8";
			LC_TIME = "en_US.UTF-8";
		};
    
    services.xserver.xkb.layout = "us";
    services.xserver.xkb.variant = "colemak_dh,";

    services.pipewire = {
      enable = true;
      alsa.enable = true;
      wireplumber.enable = true;
      pulse.enable = true;
    };

    services.libinput.enable = true;

    # environment.pathsToLink = [ "/share/zsh" ];
    console = {
      packages = [
        pkgs.cozette
      ];
      earlySetup = true;
      useXkbConfig = true;
      font = "${pkgs.cozette}/share/consolefonts/cozette12x26.psfu";
      colors = [
        "0f0f0f"
        "ac8a8c"
        "8aac8b"
        "aca98a"
        "8f8aac"
        "ac8aac"
        "8aabac"
        "cacaca"
        "4c4c4c"
        "ac8a8c"
        "8aac8b"
        "aca98a"
        "8f8aac"
        "ac8aac"
        "8aabac"
        "f0f0f0"
      ];
    };

    services.printing.enable = true;
    services.printing.drivers = [ pkgs.gutenprint pkgs.brlaser pkgs.brgenml1lpr pkgs.brgenml1cupswrapper ];
  };
}