]> gitweb.ps.run Git - flake_thinkpad/blob - configuration.nix
add Mod-b shortcut to i3; this creates a new tabbed child layer
[flake_thinkpad] / configuration.nix
1 # Edit this configuration file to define what should be installed on
2 # your system.  Help is available in the configuration.nix(5) man page
3 # and in the NixOS manual (accessible by running ‘nixos-help’).
4
5 { config, pkgs, inputs, lib, ... } @ args:
6
7
8 let
9   # tuigreet = "${pkgs.greetd.tuigreet}/bin/tuigreet";
10   # session = "${pkgs.sway}/bin/sway";
11   # username = "ps";
12   wallpaper = pkgs.fetchurl {
13     url = "https://w.wallhaven.cc/full/ex/wallhaven-exrqrr.jpg";
14     sha256 = "sha256-RYN8KwJPDMfxrcosbpmjON0Y+I58IhB1Ke36LdohsxA=";
15   };
16 in
17
18 {
19   imports =
20     [ # Include the results of the hardware scan.
21       ./hardware-configuration.nix
22       inputs.home-manager.nixosModules.default
23       inputs.extra-container.nixosModules.default
24       inputs.microvm.nixosModules.host
25     ];
26
27   # Bootloader.
28   boot.tmp.cleanOnBoot = true;
29   boot.loader.systemd-boot.enable = true;
30   boot.loader.efi.canTouchEfiVariables = true;
31   boot.plymouth.enable = true;
32   boot.plymouth.theme = "bgrt";
33   boot.initrd.verbose = false;
34   boot.initrd.systemd.enable = true;
35   boot.initrd.kernelModules = [ "amdgpu" ];
36   boot.consoleLogLevel = 0;
37   boot.kernelPackages = pkgs.linuxPackages_latest;
38   boot.kernelParams = [ "quiet" "udev.log_level=0" "amdgpu.runpm=0" ];
39
40   # incus admin init --minimal
41   # incus image list images:
42   # incus launch images:ubuntu/noble <name>
43   # incus exec <name> -- /bin/bash
44   # incus exec <name> -- adduser --shell /bin/bash --ingroup sudo ps
45   # incus exec <name> -- su - ps -c 'tmux new-session -A -s main'
46   virtualisation.incus.enable = true;
47   virtualisation.incus.ui.enable = true;
48   networking.nftables.enable = true;
49   networking.firewall.trustedInterfaces = [ "incusbr0" ];
50
51   networking.hostName = "thinkpad"; # Define your hostname.
52   # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
53
54   nix.settings.experimental-features = [ "nix-command" "flakes" ];
55   nix.settings.download-buffer-size = 500000000;
56   nix.config.trusted-users = ["root" "ps"];
57
58   # Configure network proxy if necessary
59   # networking.proxy.default = "http://user:password@proxy:port/";
60   # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
61
62   # Enable networking
63   networking.networkmanager.enable = true;
64
65   # Set your time zone.
66   time.timeZone = "Europe/Berlin";
67
68   # Select internationalisation properties.
69   i18n.defaultLocale = "de_DE.UTF-8";
70
71   i18n.extraLocaleSettings = {
72     LC_ADDRESS = "de_DE.UTF-8";
73     LC_IDENTIFICATION = "de_DE.UTF-8";
74     LC_MEASUREMENT = "de_DE.UTF-8";
75     LC_MONETARY = "de_DE.UTF-8";
76     LC_NAME = "de_DE.UTF-8";
77     LC_NUMERIC = "de_DE.UTF-8";
78     LC_PAPER = "de_DE.UTF-8";
79     LC_TELEPHONE = "de_DE.UTF-8";
80     LC_TIME = "de_DE.UTF-8";
81   };
82
83   programs.dconf.enable = true;
84   programs.steam.enable = true;
85
86   # Containers
87   containers = {
88     im = {
89       ephemeral = true;
90       # privateNetwork = true;
91       localAddress = "10.23.45.2";
92       hostAddress = "10.23.45.1";
93
94       bindMounts."/per".hostPath = "/var/lib/nixos-containers/im";
95       bindMounts."/per".isReadOnly = false;
96
97       extraFlags = [
98         "--property='MemoryMax=60M'"
99         "--property='MemoryHigh=50M'"
100         "--property='CPUQuota=4%'"
101       ];
102
103       config = { config, pkgs, ... }: {
104         imports = [ inputs.impermanence.nixosModules.impermanence ];
105
106         environment.persistence."/per" = {
107           directories = [
108             "/var/log"
109             "/var/lib"
110             { directory = "/home/ps"; user = "ps"; group = "users"; mode = "0750"; }
111           ];
112           files = [];
113         };
114         environment.systemPackages = with pkgs; [ helix python312 deno ];
115
116         users.users.ps = { isNormalUser = true; };
117
118         networking.firewall.allowedTCPPorts = [ 80 8080 ];
119
120         system.stateVersion = "25.05";
121       };
122     };
123   };
124   networking.nat.enable = true;
125   networking.nat.internalInterfaces = ["ve-+"];
126   networking.nat.externalInterface = "eth0";
127   networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
128
129   # Services
130   services = {
131     displayManager = {
132       defaultSession = "xfce+i3";
133     };
134     xserver = {
135       enable = true;
136       
137       displayManager = {
138         lightdm = {
139           enable = true;
140           greeters.gtk = {
141             theme = {
142               name = "Qogir-Dark";
143               package = pkgs.qogir-theme;
144             };
145             iconTheme = {
146               name = "Qogir-dark";
147               package = pkgs.qogir-icon-theme;
148             };
149             cursorTheme = {
150               name = "volantes_light_cursors";
151               package = pkgs.volantes-cursors;
152             };
153           };
154           background = "${wallpaper}";
155         };
156       };
157
158       desktopManager = {
159         xterm.enable = false;
160         xfce = {
161           enable = true;
162           noDesktop = true;
163           enableXfwm = false;
164         };
165       };
166       windowManager.i3.enable = true;
167       windowManager.awesome.enable = true;
168
169       xkb = {
170         layout = "de";
171         variant = "nodeadkeys";
172         options = "caps:ctrl_modifier";
173       };
174       excludePackages = [ pkgs.xterm ];
175       videoDrivers = ["amdgpu"];
176       # libinput.enable = true;
177     };
178   };
179
180   services.autorandr = {
181     enable = true;
182     matchEdid = true;
183     hooks = {
184       postswitch = {
185         "set-wallpaper" = "set-wallpaper";
186       };
187     };
188   };
189   
190   services.syncthing = {
191     enable = true;
192     user = "ps";
193     dataDir = "/home/ps/sync";
194     configDir = "/home/ps/.config/syncthing";
195   };
196   
197   services.auto-cpufreq.enable = true;
198   services.auto-cpufreq.settings = {
199     battery = {
200        governor = "powersave";
201        turbo = "never";
202     };
203     charger = {
204        governor = "performance";
205        turbo = "auto";
206     };
207   };
208
209   # services.tlp = {
210   #   enable = true;
211   #   settings = {
212   #     CPU_SCALING_GOVERNOR_ON_AC = "performance";
213   #     CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
214   #
215   #     CPU_ENERGY_PERF_POLICY_ON_AC = "balance_performance";
216   #     CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
217   #
218   #     PLATFORM_PROFILE_ON_AC = "balanced";
219   #     PLATFORM_PROFILE_ON_BAT = "low-power";
220   #
221   #     CPU_BOOST_ON_AC = "1";
222   #     CPU_BOOST_ON_BAT = "0";
223   #
224   #     AMDGPU_ABM_LEVEL_ON_AC = "0";
225   #     AMDGPU_ABM_LEVEL_ON_BAT = "3";
226   #
227   #     CPU_MIN_PERF_ON_AC = 0;
228   #     CPU_MAX_PERF_ON_AC = 100;
229   #     CPU_MIN_PERF_ON_BAT = 0;
230   #     CPU_MAX_PERF_ON_BAT = 20;
231   #
232   #     # START_CHARGE_THRESH_BAT0 = 40; # 40 and below it starts to charge
233   #     STOP_CHARGE_THRESH_BAT0 = 90; # 85 and above it stops charging
234   #   };
235   # };
236
237   services.udev.extraRules = ''
238     KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{serial}=="*vial:f64c2b3c*", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl"
239   '';
240
241   # OpenGL
242   hardware = {
243     graphics = {
244         enable = true;
245         enable32Bit = true;
246         extraPackages = with pkgs; [
247           rocmPackages.clr.icd
248           mesa.opencl
249           amf
250         ];
251     };
252
253     amdgpu.amdvlk = {
254         enable = true;
255         support32Bit.enable = true;
256     };
257   };
258
259   # services.logind = {
260   #   extraConfig = "HandlePowerKey=suspend";
261   #   lidSwitch = "suspend";
262   # }; 
263
264   # Configure console keymap
265   console.keyMap = "de-latin1-nodeadkeys";
266
267   # Enable CUPS to print documents.
268   services.printing.enable = true;
269   services.printing.drivers = [ pkgs.gutenprint ];
270
271   # Enable scanners
272   hardware.sane.enable = true;
273   hardware.sane.extraBackends = [ pkgs.hplipWithPlugin pkgs.sane-airscan ];
274   services.avahi.enable = true;
275   services.avahi.nssmdns4 = true;
276   services.avahi.reflector = true;
277   services.udev.packages = [ pkgs.sane-airscan ];
278
279   # Enable Bluetooth
280   hardware.bluetooth.enable = true;
281   hardware.bluetooth.powerOnBoot = false;
282   services.blueman.enable = true;
283
284   # Enable sound with pipewire.
285   services.pulseaudio.enable = false;
286   security.rtkit.enable = true;
287   services.pipewire = {
288     enable = true;
289     alsa.enable = true;
290     alsa.support32Bit = true;
291     pulse.enable = true;
292     # If you want to use JACK applications, uncomment this
293     #jack.enable = true;
294
295     # use the example session manager (no others are packaged yet so this is enabled by default,
296     # no need to redefine it in your config for now)
297     #media-session.enable = true;
298   };
299   services.jack = {
300     jackd.enable = true;
301   };
302
303   # Enable touchpad support (enabled default in most desktopManager).
304   # services.libinput.touchpad = {
305   #   naturalScrolling = false;
306   # };
307
308   # Define a user account. Don't forget to set a password with ‘passwd’.
309   users.groups.ssh = {};
310   users.users = {
311     ps = {
312       isNormalUser = true;
313       description = "Patrick";
314       shell = pkgs.bash;
315       extraGroups = [ "networkmanager" "wheel" "dialout" "jackaudio" "lp" "incus-admin" ];
316     };
317     # sshd = {
318     #   isSystemUser = true;
319     #   packages = [
320     #     pkgs.python3
321     #   ];
322     #   group = "ssh";
323     # };
324     chirp = {
325       isSystemUser = true;
326       packages = [
327         pkgs.python3
328       ];
329       group = "ssh";
330       shell = pkgs.bash;
331       initialPassword = "chirp";
332     };
333   };
334   
335   security.polkit.enable = true;
336   security.sudo.wheelNeedsPassword = false;
337
338   home-manager = {
339     backupFileExtension = "backup";
340     extraSpecialArgs = {
341       inherit inputs;
342       inherit wallpaper;
343     };
344     users = {
345       "ps" = import ./home.nix;
346     };
347   };
348
349   # Enable automatic login for the user.
350   # services.displayManager.autoLogin.enable = true;
351   # services.displayManager.autoLogin.user = "ps";
352   # services.getty.autologinUser = "ps";
353
354   # Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229
355   # systemd.services."getty@tty1".enable = false;
356   # systemd.services."autovt@tty1".enable = false;
357
358   # Allow unfree packages
359   nixpkgs.config.allowUnfree = true;
360
361
362   environment.variables = {
363     RUSTICL_ENABLE = "radeonsi";
364   };
365   # List packages installed in system profile. To search, run:
366   # $ nix search wget
367   environment.systemPackages = with pkgs; [
368     args.inputs.zls.inputs.zig-overlay.packages.${pkgs.system}.master
369     args.inputs.zls.packages.${pkgs.system}.zls
370     args.inputs.psch-flakes.packages.${pkgs.system}.resetmsmice
371     args.inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.zuban
372     vim wget file git kitty i3 gdb
373     mosh
374     cmake
375     entr
376     asciinema asciinema-agg
377     shellify
378
379     scrcpy
380
381     xsel
382     xcwd
383
384     pinta
385     mupdf
386     davinci-resolve
387
388     pavucontrol
389     syncthingtray
390     # xfce plugins
391     xfce.xfce4-panel
392     xfce.xfce4-pulseaudio-plugin
393       # xfce.xfce4-verve-plugin
394     xfce.xfce4-notes-plugin
395     # xfce.xfce4-timer-plugin
396     # xfce.xfce4-windowck-plugin
397     xfce.thunar-archive-plugin
398     # xfce.xfce4-i3-workspaces-plugin
399     # xfce.xfce4-xkb-plugin
400     xfce.xfce4-whiskermenu-plugin
401
402   ];
403
404   programs.xfconf.enable = true;
405   programs.nix-ld.enable = true;
406
407   services.fwupd.enable = true;
408
409   # Some programs need SUID wrappers, can be configured further or are
410   # started in user sessions.
411   # programs.mtr.enable = true;
412   # programs.gnupg.agent = {
413   #   enable = true;
414   #   enableSSHSupport = true;
415   # };
416
417   # List services that you want to enable:
418
419   # Enable the OpenSSH daemon.
420   services.openssh = {
421     enable = true;
422     ports = [ 22 ];
423     # settings = {
424     #   PasswordAuthentication = false;
425     #   PermitRootLogin = "no";
426     # };
427     # authorizedKeysCommand =
428     #   let keys = pkgs.writers.writePython3Bin "keys" {} ''
429     #       import sys
430     #
431     #       args = sys.argv
432     #
433     #       print(args)
434     #     '';
435     #   in
436     #     "${keys}/bin/keys";
437     # authorizedKeysCommandUser = "ps";
438   };
439
440   # Open ports in the firewall.
441   networking.firewall.allowedTCPPorts = [ 22 1234 5900 6011 6021 6022 8080 53317 7236 7250 ];
442   networking.firewall.allowedUDPPorts = [ 5901 53317 7236 5353 ];
443   # Or disable the firewall altogether.
444   # networking.firewall.enable = false;
445
446   # This value determines the NixOS release from which the default
447   # settings for stateful data, like file locations and database versions
448   # on your system were taken. It‘s perfectly fine and recommended to leave
449   # this value at the release version of the first install of this system.
450   # Before changing this value read the documentation for this option
451   # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
452   system.stateVersion = "24.05"; # Did you read the comment?
453
454 }