]> gitweb.ps.run Git - flake_thinkpad/blob - configuration.nix
update
[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       inputs.fakwin.nixosModules.default
26     ];
27
28   # Bootloader.
29   boot.tmp.cleanOnBoot = true;
30   boot.loader.systemd-boot.enable = true;
31   boot.loader.efi.canTouchEfiVariables = true;
32   boot.plymouth.enable = true;
33   boot.plymouth.theme = "bgrt";
34   boot.initrd.verbose = false;
35   boot.initrd.systemd.enable = true;
36   boot.initrd.kernelModules = [ "amdgpu" ];
37   boot.consoleLogLevel = 0;
38   boot.kernelPackages = pkgs.linuxPackages_latest;
39   boot.kernelParams = [ "quiet" "udev.log_level=0" "amdgpu.runpm=0" ];
40
41   # incus admin init --minimal
42   # incus image list images:
43   # incus launch images:ubuntu/noble <name>
44   # incus exec <name> -- /bin/bash
45   # incus exec <name> -- adduser --shell /bin/bash --ingroup sudo ps
46   # incus exec <name> -- su - ps -c 'tmux new-session -A -s main'
47   virtualisation.incus.enable = true;
48   virtualisation.incus.ui.enable = true;
49   networking.nftables.enable = true;
50   networking.firewall.trustedInterfaces = [ "incusbr0" ];
51
52   networking.hostName = "thinkpad"; # Define your hostname.
53   # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
54
55   nix.settings.experimental-features = [ "nix-command" "flakes" ];
56   nix.settings.download-buffer-size = 500000000;
57   nix.settings.trusted-users = ["root" "ps"];
58
59   # Configure network proxy if necessary
60   # networking.proxy.default = "http://user:password@proxy:port/";
61   # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
62
63   # Enable networking
64   networking.networkmanager.enable = true;
65
66   # Set your time zone.
67   time.timeZone = "Europe/Berlin";
68
69   # Select internationalisation properties.
70   i18n.defaultLocale = "de_DE.UTF-8";
71
72   i18n.extraLocaleSettings = {
73     LC_ADDRESS = "de_DE.UTF-8";
74     LC_IDENTIFICATION = "de_DE.UTF-8";
75     LC_MEASUREMENT = "de_DE.UTF-8";
76     LC_MONETARY = "de_DE.UTF-8";
77     LC_NAME = "de_DE.UTF-8";
78     LC_NUMERIC = "de_DE.UTF-8";
79     LC_PAPER = "de_DE.UTF-8";
80     LC_TELEPHONE = "de_DE.UTF-8";
81     LC_TIME = "de_DE.UTF-8";
82   };
83
84   programs.dconf.enable = true;
85   programs.steam.enable = true;
86
87   # Containers
88   containers = {
89     im = {
90       ephemeral = true;
91       # privateNetwork = true;
92       localAddress = "10.23.45.2";
93       hostAddress = "10.23.45.1";
94
95       bindMounts."/per".hostPath = "/var/lib/nixos-containers/im";
96       bindMounts."/per".isReadOnly = false;
97
98       extraFlags = [
99         "--property='MemoryMax=60M'"
100         "--property='MemoryHigh=50M'"
101         "--property='CPUQuota=4%'"
102       ];
103
104       config = { config, pkgs, ... }: {
105         imports = [ inputs.impermanence.nixosModules.impermanence ];
106
107         environment.persistence."/per" = {
108           directories = [
109             "/var/log"
110             "/var/lib"
111             { directory = "/home/ps"; user = "ps"; group = "users"; mode = "0750"; }
112           ];
113           files = [];
114         };
115         environment.systemPackages = with pkgs; [ helix python312 deno ];
116
117         users.users.ps = { isNormalUser = true; };
118
119         networking.firewall.allowedTCPPorts = [ 80 8080 ];
120
121         system.stateVersion = "25.05";
122       };
123     };
124   };
125   networking.nat.enable = true;
126   networking.nat.internalInterfaces = ["ve-+"];
127   networking.nat.externalInterface = "eth0";
128   networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
129
130   # Services
131   services = {
132     displayManager = {
133       sddm.enable = true;
134       sddm.autoLogin.relogin = true;
135       defaultSession = "xfce+i3";
136     };
137     desktopManager = {
138       plasma6.enable = true;
139     };
140     xserver = {
141       enable = true;
142       
143       displayManager = {
144         session = [
145           {
146             manage = "desktop";
147             name = "plasma-i3wm";
148             start = "KDEWM=${pkgs.i3}/bin/i3 /run/current-system/sw/bin/startplasma-x11";
149           }
150         ];
151       };
152
153       desktopManager = {
154         xterm.enable = false;
155         wallpaper.mode = "center";
156         xfce = {
157           enable = true;
158           noDesktop = true;
159           enableXfwm = false;
160         };
161       };
162       windowManager.i3.enable = true;
163       # windowManager.awesome.enable = true;
164       # windowManager.herbstluftwm.enable = true;
165
166       xkb = {
167         layout = "de";
168         variant = "nodeadkeys";
169         options = "caps:ctrl_modifier";
170       };
171       excludePackages = [ pkgs.xterm ];
172       videoDrivers = ["amdgpu"];
173       # libinput.enable = true;
174     };
175   };
176
177   systemd.user.services.plasma-kwin_x11.enable = false;
178   services.fakwin.enable = true;
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-ps.nix;
346       "root" = { home.stateVersion = "24.05"; };
347     };
348     sharedModules = [
349       (import ./home-common.nix)
350     ];
351   };
352
353   # Enable automatic login for the user.
354   # services.displayManager.autoLogin.enable = true;
355   # services.displayManager.autoLogin.user = "ps";
356   # services.getty.autologinUser = "ps";
357
358   # Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229
359   # systemd.services."getty@tty1".enable = false;
360   # systemd.services."autovt@tty1".enable = false;
361
362   # Allow unfree packages
363   nixpkgs.config.allowUnfree = true;
364
365
366   environment.variables = {
367     RUSTICL_ENABLE = "radeonsi";
368   };
369   # List packages installed in system profile. To search, run:
370   # $ nix search wget
371   environment.systemPackages = with pkgs; [
372     args.inputs.zls.inputs.zig-overlay.packages.${pkgs.system}.master
373     args.inputs.zls.packages.${pkgs.system}.zls
374     args.inputs.psch-flakes.packages.${pkgs.system}.resetmsmice
375     args.inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.zuban
376     vim wget file git kitty i3 gdb
377     mosh
378     cmake
379     entr
380     asciinema asciinema-agg
381     shellify
382     deno
383     typst
384     jdt-language-server
385     google-java-format
386
387     scrcpy
388
389     xsel
390     xcwd
391
392     pinta
393     mupdf
394     davinci-resolve
395
396     pavucontrol
397     syncthingtray
398     # xfce plugins
399     xfce.xfce4-panel
400     xfce.xfce4-pulseaudio-plugin
401     # xfce.xfce4-verve-plugin
402     xfce.xfce4-notes-plugin
403     # xfce.xfce4-timer-plugin
404     # xfce.xfce4-windowck-plugin
405     xfce.thunar-archive-plugin
406     # xfce.xfce4-i3-workspaces-plugin
407     # xfce.xfce4-xkb-plugin
408     xfce.xfce4-whiskermenu-plugin
409
410   ];
411
412   programs.xfconf.enable = true;
413   programs.nix-ld.enable = true;
414   programs.direnv.enable = true;
415   programs.direnv.nix-direnv.enable = true;
416
417   services.fwupd.enable = true;
418
419   # Some programs need SUID wrappers, can be configured further or are
420   # started in user sessions.
421   # programs.mtr.enable = true;
422   # programs.gnupg.agent = {
423   #   enable = true;
424   #   enableSSHSupport = true;
425   # };
426
427   # List services that you want to enable:
428
429   # Enable the OpenSSH daemon.
430   services.openssh = {
431     enable = true;
432     ports = [ 22 ];
433     # settings = {
434     #   PasswordAuthentication = false;
435     #   PermitRootLogin = "no";
436     # };
437     # authorizedKeysCommand =
438     #   let keys = pkgs.writers.writePython3Bin "keys" {} ''
439     #       import sys
440     #
441     #       args = sys.argv
442     #
443     #       print(args)
444     #     '';
445     #   in
446     #     "${keys}/bin/keys";
447     # authorizedKeysCommandUser = "ps";
448   };
449
450   # Open ports in the firewall.
451   networking.firewall.allowedTCPPorts = [ 22 1234 5900 6011 6021 6022 8080 53317 7236 7250 ];
452   networking.firewall.allowedUDPPorts = [ 5901 53317 7236 5353 ];
453   # Or disable the firewall altogether.
454   # networking.firewall.enable = false;
455
456   # This value determines the NixOS release from which the default
457   # settings for stateful data, like file locations and database versions
458   # on your system were taken. It‘s perfectly fine and recommended to leave
459   # this value at the release version of the first install of this system.
460   # Before changing this value read the documentation for this option
461   # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
462   system.stateVersion = "24.05"; # Did you read the comment?
463
464 }