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