-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.nix
373 lines (325 loc) · 10.8 KB
/
configuration.nix
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
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running `nixos-help`).
{
pkgs,
config,
lib,
userOptions,
...
}: {
imports = [
# Include the hardware configuration so that drives can be mounted, etc.
(
if userOptions.device == "pc"
then ./hardware-configs/PC.nix
else if userOptions.device == "laptop"
then ./hardware-configs/laptop.nix
else null
)
];
# Setup the bootloader
boot.loader = {
efi = {
canTouchEfiVariables = true;
# By mounting on `/boot/efi`, extra files (previous generations) can be stored on the root partition rather than the EFI partition
efiSysMountPoint = "/boot/efi";
};
# Use grub as the bootloader
grub = {
enable = true;
# Use OS Prober to detect a windows install
useOSProber = true;
efiSupport = true;
device = "nodev";
# Store 15 previous generations of configs
configurationLimit = 15;
};
};
# Use the latest kernel
boot.kernelPackages =
if userOptions.device == "pc"
then pkgs.linuxPackages_6_6
else pkgs.linuxPackages_latest;
boot.kernelParams =
if userOptions.nvidia
then ["nvidia_drm.fbdev=1"]
else [];
boot.kernelModules =
if userOptions.device == "pc"
then ["r8125"]
else [];
boot.extraModulePackages =
if userOptions.device == "pc"
then [pkgs.linuxPackages_6_6.r8125]
else [];
# Set hostname
networking.hostName = userOptions.hostname;
# Use networkmanager for managing networks. It is easiest to use and the default of most distros.
networking.networkmanager.enable = true;
# Set the time zone
# time.timeZone =
# if userOptions.device == "laptop"
# then "Asia/Tokyo"
# else "Europe/London";
services.automatic-timezoned.enable = true;
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Set internationalisation properties.
i18n = {
# Default locale. Determines the language for most things
defaultLocale = "en_GB.UTF-8";
# Extra locales that the system should support
supportedLocales = [
# The default POSIX locale
"C.UTF-8/UTF-8"
# English (British)
"en_GB.UTF-8/UTF-8"
# Japanese
"ja_JP.UTF-8/UTF-8"
];
# Add a way to input different languages
inputMethod = {
enable = true;
type = "fcitx5";
fcitx5.addons = with pkgs; [
# Japanese input addon
fcitx5-mozc
];
};
# Other environment variables to set, related to i18n
extraLocaleSettings = {
# LANG = "en_GB.UTF-8";
# LC_MESSAGES = "en_GB.UTF-8";
# LC_IDENTIFICATION = "en_GB.UTF-8";
# LC_ALL = "en_GB.UTF-8";
# LC_CTYPE = "en_GB.UTF-8";
# LC_NUMERIC = "en_GB.UTF-8";
# LC_TIME = "en_GB.UTF-8";
# LC_COLLATE = "en_GB.UTF-8";
# LC_NAME = "en_GB.UTF-8";
# LC_MONETARY = "en_GB.UTF-8";
# LC_PAPER = "en_GB.UTF-8";
# LC_ADDRESS = "en_GB.UTF-8";
# LC_TELEPHONE = "en_GB.UTF-8";
# LC_MEASUREMENT = "en_GB.UTF-8";
};
};
# The keyboard mapping for virtual consoles
console.keyMap = "uk";
# Add nerdfonts for different types of symbols
fonts.packages = [pkgs.nerd-fonts.symbols-only pkgs.ipafont pkgs.kochi-substitute pkgs.noto-fonts-cjk-sans pkgs.roboto pkgs.source-sans-pro pkgs.source-sans];
# Enable OpenGL
hardware.graphics = {
enable = true;
enable32Bit = true;
extraPackages =
if userOptions.nvidia
then [pkgs.libvdpau-va-gl pkgs.nvidia-vaapi-driver]
else [];
};
# Enable the Xbox One controller driver
hardware.xone.enable = true;
# Nvidia setup
hardware.nvidia = lib.attrsets.optionalAttrs userOptions.nvidia {
# Modesetting is required
modesetting.enable = true;
powerManagement.enable = false;
powerManagement.finegrained = false;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# Set the kernel package
package = config.boot.kernelPackages.nvidiaPackages.beta; # Use beta as we need Nvidia 555 for Explicit Sync as of right now
# Options include:
# config.boot.kernelPackages.nvidiaPackages.stable
# config.boot.kernelPackages.nvidiaPackages.production
# config.boot.kernelPackages.nvidiaPackages.beta
};
# Enable hyprland (note: I don't know if this actually has any effect since it's defined in home.nix)
programs.hyprland = {
enable = true;
xwayland.enable = true;
portalPackage = pkgs.xdg-desktop-portal-hyprland;
package = pkgs.hyprland;
};
# Tuxclocker
programs.tuxclocker = {
enable = true;
enabledNVIDIADevices = [0];
useUnfree = true;
};
# Sunshine for streaming: https://github.com/LizardByte/Sunshine
services.sunshine = {
enable = true;
autoStart = true;
capSysAdmin = true;
openFirewall = true;
};
# Enable x11 (note: I don't know if this is needed anymore, maybe for XWayland it is?)
services.xserver = {
enable = true;
displayManager.startx.enable = true;
# Set drivers
videoDrivers =
if userOptions.nvidia
then ["nvidia"]
else ["modesetting" "fbdev"];
# Set the layout for xkeyboard
xkb.layout = "gb";
# Enable the wacom tablet driver
wacom.enable = true;
};
# Enable CUPS to print documents.
services.printing = {
enable = true;
drivers = [pkgs.hplip];
};
# Enable sound.
# Use pipewire since it's needed for screensharing, etc. on Hyprland
# Enable basically everything
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
wireplumber.enable = true;
jack.enable = true;
};
# For screensharing
xdg.portal = {
enable = true;
extraPortals = with pkgs; [xdg-desktop-portal-gtk];
};
# OpenRazer to configure a razer mouse
hardware.openrazer = {
enable = true;
# Adds the user to the razer group required for usage
users = ["${userOptions.username}"];
};
# Nix & Nixpkgs config
nix.settings = {
# Enable nix flakes
experimental-features = ["nix-command" "flakes"];
# Enable the Hyprland cachix to prevent having to compile Hyprland from source (when running master)
substituters = ["https://hyprland.cachix.org"];
trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="];
};
nixpkgs.config = {
# Allow unfree packages
allowUnfree = true;
allowBroken = true;
# Add insecure packages that are required here
permittedInsecurePackages = []; # Currently none required
# Accept the nvidia driver license when running nvidia
nvidia.acceptLicense = userOptions.nvidia;
};
nixpkgs.overlays = [
# # Openrazer fix: https://github.com/NixOS/nixpkgs/issues/310205
# (self: super: {
# openrazer-daemon = super.openrazer-daemon.overrideAttrs (oldAttrs: {
# nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [pkgs.gobject-introspection pkgs.wrapGAppsHook3 pkgs.python3Packages.wrapPython];
# });
# })
];
# Environment variables
environment.variables = {
# The `EDITOR` variable if often used when entering edit mode on a program
EDITOR = "nvim";
# Set the shell
SHELL = "fish";
};
# For compatibility - these are bound on most Linux distros, but not on Nix by default
environment.sessionVariables = {
XDG_CACHE_HOME = "$HOME/.cache";
XDG_CONFIG_HOME = "$HOME/.config";
XDG_DATA_HOME = "$HOME/.local/share";
XDG_STATE_HOME = "$HOME/.local/state";
};
environment.systemPackages = [
pkgs.libsForQt5.qt5.qtgraphicaleffects
];
# Change shell to fish
programs.fish.enable = true;
users.defaultUserShell = pkgs.fish;
# Alias lazygit
programs.fish.shellAliases = {
lg = "lazygit";
# Quick entry into a dev shell
dev = "nix-shell --command fish";
neofetch = "fastfetch";
rebuild =
if userOptions.device == "pc"
then "sudo nixos-rebuild switch --flake /etc/nixos#Jeremy-nixos"
else if userOptions.device == "laptop"
then "sudo nixos-rebuild switch --flake /etc/nixos#Jeremy-laptop"
else null;
# Aliases to quickly edit my config
cdconfig = "cd /etc/nixos";
edithome = "sudoedit /etc/nixos/home.nix";
editconfig = "sudoedit /etc/nixos/configuration.nix";
editflake = "sudoedit /etc/nixos/flake.nix";
# For rust programming - I commonly mistype this
# TODO: Maybe bind this in nix-shell?
carog = "cargo";
};
# Define a user account. A password must be set imperatively using `passwd`
users.users."${userOptions.username}" = {
isNormalUser = true;
extraGroups = ["wheel"]; # Enable ‘sudo’ for the user
};
# Enable steam
programs.steam = {
enable = true;
remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
};
# Required for EasyEffects (https://github.com/wwmm/easyeffects)
programs.dconf.enable = true;
# Waydroid for android apps
virtualisation.waydroid.enable = true;
virtualisation.libvirtd.enable = true;
virtualisation.podman = {
enable = true;
dockerCompat = true;
};
# Mullvad (VPN)
services.mullvad-vpn.enable = true;
# Allows Hyprlock to unlock a device
security.pam.services.hyprlock = {};
# Enable the OpenSSH daemon.
services.openssh = {
enable = true;
ports = [696];
};
services.postgresql = {
enable = true;
ensureDatabases = ["edict_test_db"];
};
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [
7777 # Terraria's Port
22000 # Syncthing's TCP listening port
6970
];
networking.firewall.allowedUDPPorts = [
7777 # Terraria's Port
6970
];
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix.
# system.copySystemConfiguration = true;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment?
}