From 6b43f84933f37fec7ad30b103f5b0b6c411fc9ba Mon Sep 17 00:00:00 2001 From: Swarsel Date: Wed, 17 Jul 2024 04:13:51 +0200 Subject: [PATCH] feat: preliminary setup for work laptop --- SwarselSystems.org | 68 ++++++----------- flake.nix | 14 ++++ profiles/winters/home.nix | 118 ++++++++++++++++++++++++++++++ profiles/winters/nixos.nix | 145 +++++++++++++++++++++++++++++++++++++ 4 files changed, 298 insertions(+), 47 deletions(-) create mode 100644 profiles/winters/home.nix create mode 100644 profiles/winters/nixos.nix diff --git a/SwarselSystems.org b/SwarselSystems.org index f826802..0ccc007 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -1369,7 +1369,7 @@ My work machine. Mostly just sets some opened ports for several games, enables virtualbox (which I do not want everywhere because of resource considerations) and enables thinkfan, which allows for better fan control on Lenovo Thinkpad machines. -#+begin_src nix :noweb yes :tangle profiles/fourside/nixos.nix +#+begin_src nix :noweb yes :tangle profiles/winters/nixos.nix { config, lib, pkgs, inputs, ... }: @@ -1389,25 +1389,21 @@ Mostly just sets some opened ports for several games, enables virtualbox (which boot = { loader.systemd-boot.enable = true; loader.efi.canTouchEfiVariables = true; - # kernelPackages = pkgs.linuxPackages_latest; + kernelPackages = pkgs.linuxPackages_latest; }; networking = { - hostName = "fourside"; # Define your hostname. + hostName = "winters"; # Define your hostname. nftables.enable = true; - enableIPv6 = false; - firewall.checkReversePath = false; + enableIPv6 = true; + firewall.checkReversePath = "strict"; firewall = { enable = true; - allowedUDPPorts = [ 4380 27036 14242 34197 51820 ]; # 34197: factorio; 4380 27036 14242: barotrauma; 51820: wireguard - allowedTCPPorts = [ ]; # 34197: factorio; 4380 27036 14242: barotrauma; 51820: wireguard + allowedUDPPorts = [ ]; + allowedTCPPorts = [ ]; allowedTCPPortRanges = [ - {from = 27015; to = 27030;} # barotrauma - {from = 27036; to = 27037;} # barotrauma ]; allowedUDPPortRanges = [ - {from = 27000; to = 27031;} # barotrauma - {from = 58962; to = 58964;} # barotrauma ]; }; }; @@ -1431,16 +1427,9 @@ Mostly just sets some opened ports for several games, enables virtualbox (which enable = true; enable32Bit = true; extraPackages = with pkgs; [ - vulkan-loader - vulkan-validation-layers - vulkan-extension-layer ]; }; bluetooth.enable = true; - trackpoint = { - enable = true; - device = "TPPS/2 Elan TrackPoint"; - }; }; programs.steam = { @@ -1450,11 +1439,6 @@ Mostly just sets some opened ports for several games, enables virtualbox (which ]; }; - # Configure keymap in X11 (only used for login) - - services.thinkfan = { - enable = false; - }; services.power-profiles-daemon.enable = true; users.users.swarsel = { @@ -1465,13 +1449,14 @@ Mostly just sets some opened ports for several games, enables virtualbox (which }; environment.systemPackages = with pkgs; [ - # gog games installing - heroic - # minecraft - temurin-bin-17 - (prismlauncher.override { - glfw = pkgs.glfw-wayland-minecraft; - }) + sbctl + # gog games installing + heroic + # minecraft + temurin-bin-17 + (prismlauncher.override { + glfw = pkgs.glfw-wayland-minecraft; + }) ]; system.stateVersion = "23.05"; @@ -1481,14 +1466,14 @@ Mostly just sets some opened ports for several games, enables virtualbox (which #+end_src -***** Home Manager +***** TODO Home Manager :PROPERTIES: :CUSTOM_ID: h:85f7110c-2f25-4506-b64a-fce29f29d0d0 :END: -This is basically just adjusted to the core count, path to the =hwmon= (this was very bothersome on this machine due to changing address), as well as making use of the top-row function keys. +TODO: Adjust =hwmon= path, I/O modules and XF86 keys once laptop arrives. -#+begin_src nix :noweb yes :tangle profiles/fourside/home.nix +#+begin_src nix :noweb yes :tangle profiles/winters/home.nix { config, pkgs, lib, fetchFromGitHub, ... }: @@ -1508,7 +1493,7 @@ This is basically just adjusted to the core count, path to the =hwmon= (this was # waybar config - TEMPLATE - update for cores and temp programs.waybar.settings.mainBar = { cpu.format = "{icon0} {icon1} {icon2} {icon3} {icon4} {icon5} {icon6} {icon7}"; - # temperature.hwmon-path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon4/temp1_input"; + temperature.hwmon-path.abs = "/sys/devices/platform/thinkpad_hwmon/hwmon/"; temperature.input-filename = "temp1_input"; }; @@ -1544,6 +1529,7 @@ This is basically just adjusted to the core count, path to the =hwmon= (this was position = "1920,0"; # bg = "~/.dotfiles/wallpaper/lenovowp.png fill"; }; + # external monitor HDMI-A-1 = { mode = "2560x1440"; scale = "1"; @@ -1561,19 +1547,7 @@ This is basically just adjusted to the core count, path to the =hwmon= (this was keybindings = let modifier = config.wayland.windowManager.sway.config.modifier; in { - "${modifier}+w" = "exec \"bash ~/.dotfiles/scripts/checkelement.sh\""; - "XF86MonBrightnessUp" = "exec brightnessctl set +5%"; - "XF86MonBrightnessDown"= "exec brightnessctl set 5%-"; - "XF86Display" = "exec wl-mirror eDP-1"; - # these are left open to use - # "XF86WLAN" = "exec wl-mirror eDP-1"; - # "XF86Messenger" = "exec wl-mirror eDP-1"; - # "XF86Go" = "exec wl-mirror eDP-1"; - # "XF86Favorites" = "exec wl-mirror eDP-1"; - # "XF86HomePage" = "exec wtype -P Escape -p Escape"; - # "XF86AudioLowerVolume" = "pactl set-sink-volume alsa_output.pci-0000_08_00.6.HiFi__hw_Generic_1__sink -5%"; - # "XF86AudioRaiseVolume" = "pactl set-sink-volume alsa_output.pci-0000_08_00.6.HiFi__hw_Generic_1__sink +5% "; - "XF86AudioMute" = "pactl set-sink-mute alsa_output.pci-0000_08_00.6.HiFi__hw_Generic_1__sink toggle"; + }; startup = [ diff --git a/flake.nix b/flake.nix index 529b9ca..06d1f6b 100644 --- a/flake.nix +++ b/flake.nix @@ -205,6 +205,20 @@ ]; }; + winters = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs pkgs; }; + modules = nixModules ++ [ + nixos-hardware.nixosModules.framework-16-inch-7040-amd + ./profiles/winters/nixos.nix + home-manager.nixosModules.home-manager + { + home-manager.users.swarsel.imports = mixedModules ++ [ + ./profiles/winters/home.nix + ]; + } + ]; + }; + stand = nixpkgs.lib.nixosSystem { specialArgs = {inherit inputs pkgs; }; modules = nixModules ++ [ diff --git a/profiles/winters/home.nix b/profiles/winters/home.nix new file mode 100644 index 0000000..1d009b5 --- /dev/null +++ b/profiles/winters/home.nix @@ -0,0 +1,118 @@ +{ config, pkgs, lib, fetchFromGitHub, ... }: + +{ + + + services.gpg-agent = { + enable = true; + enableSshSupport = true; + enableExtraSocket = true; + pinentryPackage = pkgs.pinentry.gtk2; + defaultCacheTtl = 600; + maxCacheTtl = 7200; + extraConfig = '' + allow-loopback-pinentry + allow-emacs-pinentry + ''; + }; + + home = { + username = "swarsel"; + homeDirectory = "/home/swarsel"; + stateVersion = "23.05"; # TEMPLATE -- Please read the comment before changing. + keyboard.layout = "us"; # TEMPLATE + packages = with pkgs; [ + ]; + }; + sops.age.sshKeyPaths = [ "${config.home.homeDirectory}/.ssh/sops" ]; + + # waybar config - TEMPLATE - update for cores and temp + programs.waybar.settings.mainBar = { + cpu.format = "{icon0} {icon1} {icon2} {icon3} {icon4} {icon5} {icon6} {icon7}"; + + temperature.hwmon-path.abs = "/sys/devices/platform/thinkpad_hwmon/hwmon/"; + temperature.input-filename = "temp1_input"; + }; + + + programs.waybar.settings.mainBar.modules-right = ["custom/outer-left-arrow-dark" + "mpris" + "custom/left-arrow-light" + "network" + "custom/left-arrow-dark" + "pulseaudio" + "custom/left-arrow-light" + "custom/pseudobat" + "battery" + "custom/left-arrow-dark" + "group/hardware" + "custom/left-arrow-light" + "clock#2" + "custom/left-arrow-dark" + "clock#1" + ]; + + + wayland.windowManager.sway= { + config = rec { + # update for actual inputs here, + input = { + "36125:53060:splitkb.com_Kyria_rev3" = { + xkb_layout = "us"; + xkb_variant = "altgr-intl"; + }; + "1:1:AT_Translated_Set_2_keyboard" = { # TEMPLATE + xkb_layout = "us"; + xkb_options = "grp:win_space_toggle"; + xkb_variant = "altgr-intl"; + }; + "type:touchpad" = { + dwt = "enabled"; + tap = "enabled"; + natural_scroll = "enabled"; + middle_emulation = "enabled"; + }; + + }; + + output = { + eDP-1 = { + mode = "1920x1080"; # TEMPLATE + scale = "1"; + position = "1920,0"; + # bg = "~/.dotfiles/wallpaper/lenovowp.png fill"; + }; + # external monitor + HDMI-A-1 = { + mode = "2560x1440"; + scale = "1"; + # bg = "~/.dotfiles/wallpaper/lenovowp.png fill"; + position = "0,0"; + }; + }; + + workspaceOutputAssign = [ + { output = "eDP-1"; workspace = "1:一";} + { output = "HDMI-A-1"; workspace = "2:二";} + ]; + + + keybindings = let + modifier = config.wayland.windowManager.sway.config.modifier; + in { + + }; + + startup = [ + + { command = "nextcloud --background";} + { command = "discord --start-minimized";} + { command = "element-desktop --hidden -enable-features=UseOzonePlatform -ozone-platform=wayland --disable-gpu-driver-bug-workarounds";} + { command = "ANKI_WAYLAND=1 anki";} + { command = "OBSIDIAN_USE_WAYLAND=1 obsidian";} + { command = "nm-applet";} + + ]; + }; + }; +} diff --git a/profiles/winters/nixos.nix b/profiles/winters/nixos.nix new file mode 100644 index 0000000..083f226 --- /dev/null +++ b/profiles/winters/nixos.nix @@ -0,0 +1,145 @@ +{ config, lib, pkgs, inputs, ... }: + +{ + + # + # imports = + # [ + # ./hardware-configuration.nix + # ]; + # + imports = + [ + ./hardware-configuration.nix + ]; + + services = { + getty.autologinUser = "swarsel"; + greetd.settings.initial_session.user="swarsel"; + }; + + boot = { + loader.systemd-boot.enable = true; + loader.efi.canTouchEfiVariables = true; + kernelPackages = pkgs.linuxPackages_latest; + }; + + networking = { + hostName = "winters"; # Define your hostname. + nftables.enable = true; + enableIPv6 = true; + firewall.checkReversePath = "strict"; + firewall = { + enable = true; + allowedUDPPorts = [ ]; + allowedTCPPorts = [ ]; + allowedTCPPortRanges = [ + ]; + allowedUDPPortRanges = [ + ]; + }; + }; + + virtualisation.virtualbox = { + host = { + enable = true; + enableExtensionPack = true; + }; + # leaving this here for future notice. setting guest.enable = true will make 'restarting sysinit-reactivation.target' take till timeout on nixos-rebuild switch + guest = { + enable = false; + }; + }; + + stylix.image = ../../wallpaper/lenovowp.png; + + stylix = { + enable = true; + base16Scheme = ../../wallpaper/swarsel.yaml; + # base16Scheme = "${pkgs.base16-schemes}/share/themes/shapeshifter.yaml"; + polarity = "dark"; + opacity.popups = 0.5; + cursor = { + package = pkgs.capitaine-cursors; + name = "capitaine-cursors"; + size = 16; + }; + fonts = { + sizes = { + terminal = 10; + applications = 11; + }; + serif = { + # package = (pkgs.nerdfonts.override { fonts = [ "FiraMono" "FiraCode"]; }); + package = pkgs.cantarell-fonts; + # package = pkgs.montserrat; + name = "Cantarell"; + # name = "FiraCode Nerd Font Propo"; + # name = "Montserrat"; + }; + + sansSerif = { + # package = (pkgs.nerdfonts.override { fonts = [ "FiraMono" "FiraCode"]; }); + package = pkgs.cantarell-fonts; + # package = pkgs.montserrat; + name = "Cantarell"; + # name = "FiraCode Nerd Font Propo"; + # name = "Montserrat"; + }; + + monospace = { + package = (pkgs.nerdfonts.override { fonts = [ "FiraCode"]; }); + name = "FiraCode Nerd Font Mono"; + }; + + emoji = { + package = pkgs.noto-fonts-emoji; + name = "Noto Color Emoji"; + }; + }; + }; + + + + + hardware = { + graphics = { + enable = true; + enable32Bit = true; + extraPackages = with pkgs; [ + ]; + }; + bluetooth.enable = true; + }; + + programs.steam = { + enable = true; + extraCompatPackages = [ + pkgs.proton-ge-bin + ]; + }; + + services.power-profiles-daemon.enable = true; + + users.users.swarsel = { + isNormalUser = true; + description = "Leon S"; + extraGroups = [ "networkmanager" "wheel" "lp" "audio" "video" "vboxusers" "scanner" ]; + packages = with pkgs; []; + }; + + environment.systemPackages = with pkgs; [ + sbctl + # gog games installing + heroic + # minecraft + temurin-bin-17 + (prismlauncher.override { + glfw = pkgs.glfw-wayland-minecraft; + }) + ]; + + system.stateVersion = "23.05"; + + +}