]> gitweb.ps.run Git - flake_thinkpad/blob - configuration.nix
4a277d1c877f46687a85973cd79545608d6bc4cb
[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.settings.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         plasma6.enable = true;
166       };
167       windowManager.i3.enable = true;
168       windowManager.awesome.enable = true;
169       windowManager.herbstluftwm.enable = true;
170
171       xkb = {
172         layout = "de";
173         variant = "nodeadkeys";
174         options = "caps:ctrl_modifier";
175       };
176       excludePackages = [ pkgs.xterm ];
177       videoDrivers = ["amdgpu"];
178       # libinput.enable = true;
179     };
180   };
181
182   systemd.user.services.plasma-i3wm = {
183     wantedBy = [ "plasma-workspace-x11.target" ];
184     description = "Launch Plasma with i3wm.";
185     environment = lib.mkForce {};
186     serviceConfig = {
187       ExecStart = "${pkgs.i3}/bin/i3";
188       Restart = "on-failure";
189     };
190   };
191   systemd.user.services.plasma-workspace-x11.after = [ "plasma-i3wm.target" ];
192   systemd.user.services.plasma-kwin_x11.enable = false;
193
194   services.autorandr = {
195     enable = true;
196     matchEdid = true;
197     hooks = {
198       postswitch = {
199         "set-wallpaper" = "set-wallpaper";
200       };
201     };
202   };
203   
204   services.syncthing = {
205     enable = true;
206     user = "ps";
207     dataDir = "/home/ps/sync";
208     configDir = "/home/ps/.config/syncthing";
209   };
210   
211   # services.auto-cpufreq.enable = true;
212   services.auto-cpufreq.settings = {
213     battery = {
214        governor = "powersave";
215        turbo = "never";
216     };
217     charger = {
218        governor = "performance";
219        turbo = "auto";
220     };
221   };
222
223   # services.tlp = {
224   #   enable = true;
225   #   settings = {
226   #     CPU_SCALING_GOVERNOR_ON_AC = "performance";
227   #     CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
228   #
229   #     CPU_ENERGY_PERF_POLICY_ON_AC = "balance_performance";
230   #     CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
231   #
232   #     PLATFORM_PROFILE_ON_AC = "balanced";
233   #     PLATFORM_PROFILE_ON_BAT = "low-power";
234   #
235   #     CPU_BOOST_ON_AC = "1";
236   #     CPU_BOOST_ON_BAT = "0";
237   #
238   #     AMDGPU_ABM_LEVEL_ON_AC = "0";
239   #     AMDGPU_ABM_LEVEL_ON_BAT = "3";
240   #
241   #     CPU_MIN_PERF_ON_AC = 0;
242   #     CPU_MAX_PERF_ON_AC = 100;
243   #     CPU_MIN_PERF_ON_BAT = 0;
244   #     CPU_MAX_PERF_ON_BAT = 20;
245   #
246   #     # START_CHARGE_THRESH_BAT0 = 40; # 40 and below it starts to charge
247   #     STOP_CHARGE_THRESH_BAT0 = 90; # 85 and above it stops charging
248   #   };
249   # };
250
251   services.udev.extraRules = ''
252     KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{serial}=="*vial:f64c2b3c*", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl"
253   '';
254
255   # OpenGL
256   hardware = {
257     graphics = {
258         enable = true;
259         enable32Bit = true;
260         extraPackages = with pkgs; [
261           rocmPackages.clr.icd
262           mesa.opencl
263           amf
264         ];
265     };
266
267     amdgpu.amdvlk = {
268         enable = true;
269         support32Bit.enable = true;
270     };
271   };
272
273   # services.logind = {
274   #   extraConfig = "HandlePowerKey=suspend";
275   #   lidSwitch = "suspend";
276   # }; 
277
278   # Configure console keymap
279   console.keyMap = "de-latin1-nodeadkeys";
280
281   # Enable CUPS to print documents.
282   services.printing.enable = true;
283   services.printing.drivers = [ pkgs.gutenprint ];
284
285   # Enable scanners
286   hardware.sane.enable = true;
287   hardware.sane.extraBackends = [ pkgs.hplipWithPlugin pkgs.sane-airscan ];
288   services.avahi.enable = true;
289   services.avahi.nssmdns4 = true;
290   services.avahi.reflector = true;
291   services.udev.packages = [ pkgs.sane-airscan ];
292
293   # Enable Bluetooth
294   hardware.bluetooth.enable = true;
295   hardware.bluetooth.powerOnBoot = false;
296   # services.blueman.enable = true;
297
298   # Enable sound with pipewire.
299   services.pulseaudio.enable = false;
300   security.rtkit.enable = true;
301   services.pipewire = {
302     enable = true;
303     alsa.enable = true;
304     alsa.support32Bit = true;
305     pulse.enable = true;
306     # If you want to use JACK applications, uncomment this
307     #jack.enable = true;
308
309     # use the example session manager (no others are packaged yet so this is enabled by default,
310     # no need to redefine it in your config for now)
311     #media-session.enable = true;
312   };
313   services.jack = {
314     jackd.enable = true;
315   };
316
317   # Enable touchpad support (enabled default in most desktopManager).
318   # services.libinput.touchpad = {
319   #   naturalScrolling = false;
320   # };
321
322   # Define a user account. Don't forget to set a password with ‘passwd’.
323   users.groups.ssh = {};
324   users.users = {
325     ps = {
326       isNormalUser = true;
327       description = "Patrick";
328       shell = pkgs.bash;
329       extraGroups = [ "networkmanager" "wheel" "dialout" "jackaudio" "lp" "incus-admin" ];
330     };
331     # sshd = {
332     #   isSystemUser = true;
333     #   packages = [
334     #     pkgs.python3
335     #   ];
336     #   group = "ssh";
337     # };
338     chirp = {
339       isSystemUser = true;
340       packages = [
341         pkgs.python3
342       ];
343       group = "ssh";
344       shell = pkgs.bash;
345       initialPassword = "chirp";
346     };
347   };
348   
349   security.polkit.enable = true;
350   security.sudo.wheelNeedsPassword = false;
351
352   home-manager = {
353     backupFileExtension = "backup";
354     extraSpecialArgs = {
355       inherit inputs;
356       inherit wallpaper;
357     };
358     users = {
359       "ps" = import ./home.nix;
360     };
361   };
362
363   # Enable automatic login for the user.
364   # services.displayManager.autoLogin.enable = true;
365   # services.displayManager.autoLogin.user = "ps";
366   # services.getty.autologinUser = "ps";
367
368   # Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229
369   # systemd.services."getty@tty1".enable = false;
370   # systemd.services."autovt@tty1".enable = false;
371
372   # Allow unfree packages
373   nixpkgs.config.allowUnfree = true;
374
375
376   environment.variables = {
377     RUSTICL_ENABLE = "radeonsi";
378   };
379   # List packages installed in system profile. To search, run:
380   # $ nix search wget
381   environment.systemPackages = with pkgs; [
382     args.inputs.zls.inputs.zig-overlay.packages.${pkgs.system}.master
383     args.inputs.zls.packages.${pkgs.system}.zls
384     args.inputs.psch-flakes.packages.${pkgs.system}.resetmsmice
385     args.inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.zuban
386     vim wget file git kitty i3 gdb
387     mosh
388     cmake
389     entr
390     asciinema asciinema-agg
391     shellify
392
393     scrcpy
394
395     xsel
396     xcwd
397
398     pinta
399     mupdf
400     davinci-resolve
401
402     pavucontrol
403     syncthingtray
404     # xfce plugins
405     xfce.xfce4-panel
406     xfce.xfce4-pulseaudio-plugin
407     # xfce.xfce4-verve-plugin
408     xfce.xfce4-notes-plugin
409     # xfce.xfce4-timer-plugin
410     # xfce.xfce4-windowck-plugin
411     xfce.thunar-archive-plugin
412     # xfce.xfce4-i3-workspaces-plugin
413     # xfce.xfce4-xkb-plugin
414     xfce.xfce4-whiskermenu-plugin
415
416   ];
417
418   programs.xfconf.enable = true;
419   programs.nix-ld.enable = true;
420
421   services.fwupd.enable = true;
422
423   # Some programs need SUID wrappers, can be configured further or are
424   # started in user sessions.
425   # programs.mtr.enable = true;
426   # programs.gnupg.agent = {
427   #   enable = true;
428   #   enableSSHSupport = true;
429   # };
430
431   # List services that you want to enable:
432
433   # Enable the OpenSSH daemon.
434   services.openssh = {
435     enable = true;
436     ports = [ 22 ];
437     # settings = {
438     #   PasswordAuthentication = false;
439     #   PermitRootLogin = "no";
440     # };
441     # authorizedKeysCommand =
442     #   let keys = pkgs.writers.writePython3Bin "keys" {} ''
443     #       import sys
444     #
445     #       args = sys.argv
446     #
447     #       print(args)
448     #     '';
449     #   in
450     #     "${keys}/bin/keys";
451     # authorizedKeysCommandUser = "ps";
452   };
453
454   # Open ports in the firewall.
455   networking.firewall.allowedTCPPorts = [ 22 1234 5900 6011 6021 6022 8080 53317 7236 7250 ];
456   networking.firewall.allowedUDPPorts = [ 5901 53317 7236 5353 ];
457   # Or disable the firewall altogether.
458   # networking.firewall.enable = false;
459
460   # This value determines the NixOS release from which the default
461   # settings for stateful data, like file locations and database versions
462   # on your system were taken. It‘s perfectly fine and recommended to leave
463   # this value at the release version of the first install of this system.
464   # Before changing this value read the documentation for this option
465   # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
466   system.stateVersion = "24.05"; # Did you read the comment?
467
468 }