From fd0316e588a2bbf3ff7d4e1f0e77187d6236bf60 Mon Sep 17 00:00:00 2001 From: jimjam4real Date: Sun, 8 Sep 2024 21:45:54 -0400 Subject: [PATCH] Add Lenovo laptop --- flake.nix | 14 ++++++++ home-manager/jimbo_deck.nix | 7 ++-- home-manager/jimbo_desktop.nix | 7 ++-- home-manager/jimbo_lenovo.nix | 58 ++++++++++++++++++++++++++++++ home-manager/jimbo_server.nix | 9 ++--- home-manager/jimbo_ssh.nix | 3 +- home-manager/sway/autostart.nix | 2 +- home-manager/sway/rules.nix | 4 +-- nixos/base.nix | 3 -- nixos/deck.nix | 4 +++ nixos/desktop.nix | 4 +++ nixos/hardware/machines/lenovo.nix | 54 ++++++++++++++++++++++++++++ nixos/lenovo.nix | 46 ++++++++++++++++++++++++ nixos/server.nix | 3 ++ 14 files changed, 201 insertions(+), 17 deletions(-) create mode 100644 home-manager/jimbo_lenovo.nix create mode 100644 nixos/hardware/machines/lenovo.nix create mode 100644 nixos/lenovo.nix diff --git a/flake.nix b/flake.nix index 9dd01d8..2a08485 100644 --- a/flake.nix +++ b/flake.nix @@ -68,6 +68,12 @@ jovian-nixos.nixosModules.default ]; }; + JimLenovo = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs outputs;}; + modules = [ + ./nixos/lenovo.nix + ]; + }; }; # Standalone home-manager configuration @@ -96,6 +102,14 @@ nur.nixosModules.nur ]; }; + "jimbo@JimLenovo" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; + extraSpecialArgs = {inherit inputs outputs;}; + modules = [ + ./home-manager/jimbo_lenovo.nix + nur.nixosModules.nur + ]; + }; # Derivation for ssh envrionments on other people's servers "jimbo@SSH" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; diff --git a/home-manager/jimbo_deck.nix b/home-manager/jimbo_deck.nix index 0b4184e..e79c573 100644 --- a/home-manager/jimbo_deck.nix +++ b/home-manager/jimbo_deck.nix @@ -37,13 +37,14 @@ ./services/udiskie.nix ]; - # Rebuild this entire system + # ZSH rebuild commands programs.zsh = { shellAliases = let auth = import ./common/auth.nix; + hostname = "JimDeck"; in { - sysdate = "${auth.method} nixos-rebuild switch --flake /etc/nixos/.#JimDeck"; - homedate = "home-manager switch --flake /etc/nixos/.#jimbo@JimDeck"; + sysdate = "${auth.method} nixos-rebuild switch --flake /etc/nixos/.#${hostname}"; + homedate = "home-manager switch --flake /etc/nixos/.#jimbo@${hostname}"; nixdate = "sysdate; homedate; notify-send 'NixOS switch done.'"; }; }; diff --git a/home-manager/jimbo_desktop.nix b/home-manager/jimbo_desktop.nix index 76fcb84..6a794cc 100644 --- a/home-manager/jimbo_desktop.nix +++ b/home-manager/jimbo_desktop.nix @@ -39,13 +39,14 @@ ./services/udiskie.nix ]; - # Rebuild this entire system + # ZSH rebuild commands programs.zsh = { shellAliases = let auth = import ./common/auth.nix; + hostname = "JimDesktop"; in { - sysdate = "${auth.method} nixos-rebuild switch --flake /etc/nixos/.#JimDesktop"; - homedate = "home-manager switch --flake /etc/nixos/.#jimbo@JimDesktop"; + sysdate = "${auth.method} nixos-rebuild switch --flake /etc/nixos/.#${hostname}"; + homedate = "home-manager switch --flake /etc/nixos/.#jimbo@${hostname}"; nixdate = "sysdate; homedate; notify-send 'NixOS switch done.'"; }; }; diff --git a/home-manager/jimbo_lenovo.nix b/home-manager/jimbo_lenovo.nix new file mode 100644 index 0000000..6514742 --- /dev/null +++ b/home-manager/jimbo_lenovo.nix @@ -0,0 +1,58 @@ +{config, ...}: { + imports = [ + # Common modules + ./home.nix + ./users/jimbo.nix + ./tuiapps/git.nix + + # GUI Apps + ./misc/guifiles.nix + ./sway/sway.nix + ./sway/swaylock.nix + ./guiapps/gtk.nix + ./guiapps/foot.nix + ./guiapps/librewolf.nix + ./guiapps/mangohud.nix + ./guiapps/mpv.nix + ./guiapps/obs.nix + ./guiapps/pcmanfm-qt.nix + ./guiapps/rofi.nix + ./guiapps/swappy.nix + ./guiapps/easyeffects.nix + ./tuiapps/ncmpcpp.nix + + # Misc apps and tools + ./misc/useful.nix + ./misc/avtools.nix + ./misc/filemanager.nix + ./misc/gaming.nix + ./misc/xash3d.nix + ./misc/remotedesktop.nix + ./misc/school.nix + ./misc/variables.nix + + # Services + ./services/gnome-keyring.nix + ./services/mako.nix + ./services/udiskie.nix + ]; + + # ZSH rebuild commands + programs.zsh = { + shellAliases = let + auth = import ./common/auth.nix; + hostname = "JimLenovo"; + in { + sysdate = "${auth.method} nixos-rebuild switch --flake /etc/nixos/.#${hostname}"; + homedate = "home-manager switch --flake /etc/nixos/.#jimbo@${hostname}"; + nixdate = "sysdate; homedate; notify-send 'NixOS switch done.'"; + }; + }; + + # Symlinks + home.file = { + "VMs" = { + source = config.lib.file.mkOutOfStoreSymlink "/etc/libvirt/VMs"; + }; + }; +} diff --git a/home-manager/jimbo_server.nix b/home-manager/jimbo_server.nix index ec037fb..d94f4aa 100644 --- a/home-manager/jimbo_server.nix +++ b/home-manager/jimbo_server.nix @@ -6,14 +6,15 @@ ./tuiapps/git.nix ]; - # Rebuild this entire system + # ZSH rebuild commands programs.zsh = { shellAliases = let auth = import ./common/auth.nix; + hostname = "JimServer"; in { - sysdate = "${auth.method} nixos-rebuild switch --flake /etc/nixos/.#JimServer"; - homedate = "home-manager switch --flake /etc/nixos/.#jimbo@JimServer"; - nixdate = "sysdate; homedate"; + sysdate = "${auth.method} nixos-rebuild switch --flake /etc/nixos/.#${hostname}"; + homedate = "home-manager switch --flake /etc/nixos/.#jimbo@${hostname}"; + nixdate = "sysdate; homedate; notify-send 'NixOS switch done.'"; }; }; } diff --git a/home-manager/jimbo_ssh.nix b/home-manager/jimbo_ssh.nix index 35b588d..5601753 100644 --- a/home-manager/jimbo_ssh.nix +++ b/home-manager/jimbo_ssh.nix @@ -9,8 +9,9 @@ programs.zsh = { shellAliases = let auth = import ./common/auth.nix; + hostname = "SSH"; in { - homedate = "home-manager switch --flake ~/.home-manager/.#jimbo@SSH --extra-experimental-features 'nix-command flakes'"; + homedate = "home-manager switch --flake ~/.home-manager/.#jimbo@${hostname} --extra-experimental-features 'nix-command flakes'"; }; }; } diff --git a/home-manager/sway/autostart.nix b/home-manager/sway/autostart.nix index 1c727c3..6b08007 100644 --- a/home-manager/sway/autostart.nix +++ b/home-manager/sway/autostart.nix @@ -23,7 +23,7 @@ # Foreground apps {command = "librewolf -P Misc --name=MiscBrowser";} - {command = "vesktop --ozone-platform-hint=auto";} + {command = "vesktop";} {command = "element-desktop";} {command = "thunderbird";} ]; diff --git a/home-manager/sway/rules.nix b/home-manager/sway/rules.nix index 016aece..59b901e 100644 --- a/home-manager/sway/rules.nix +++ b/home-manager/sway/rules.nix @@ -97,8 +97,8 @@ # Communication "${ws.w3a}" = [{class = "zoom";}]; - "${ws.w7}" = [{app_id = "MiscBrowser";} {app_id = "vesktop";}]; - "${ws.w8}" = [{app_id = "Element";}]; + "${ws.w7}" = [{app_id = "MiscBrowser";} {app_id = "vesktop";} {class = "vesktop";}]; + "${ws.w8}" = [{app_id = "Element";} {class = "Element";}]; "${ws.w9}" = [{app_id = "thunderbird";}]; # Else diff --git a/nixos/base.nix b/nixos/base.nix index 28fdaae..559e1fc 100644 --- a/nixos/base.nix +++ b/nixos/base.nix @@ -73,7 +73,4 @@ # Allow binary firmware hardware.enableRedistributableFirmware = true; - - # Force Electron to use Wayland - environment.sessionVariables.NIXOS_OZONE_WL = "1"; } diff --git a/nixos/deck.nix b/nixos/deck.nix index e2b9197..f970ef0 100644 --- a/nixos/deck.nix +++ b/nixos/deck.nix @@ -35,8 +35,12 @@ ./services/mpd.nix ]; + # Set hostname networking.hostName = "JimDeck"; + # Force Electron to use Wayland + environment.sessionVariables.NIXOS_OZONE_WL = "1"; + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion system.stateVersion = "24.11"; } diff --git a/nixos/desktop.nix b/nixos/desktop.nix index d5d13f5..139814d 100644 --- a/nixos/desktop.nix +++ b/nixos/desktop.nix @@ -38,8 +38,12 @@ ./services/mpd.nix ]; + # Set hostname networking.hostName = "JimDesktop"; + # Force Electron to use Wayland + environment.sessionVariables.NIXOS_OZONE_WL = "1"; + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion system.stateVersion = "24.05"; } diff --git a/nixos/hardware/machines/lenovo.nix b/nixos/hardware/machines/lenovo.nix new file mode 100644 index 0000000..8eefd74 --- /dev/null +++ b/nixos/hardware/machines/lenovo.nix @@ -0,0 +1,54 @@ +# This file was initially made by 'nixos-generate-config', try not to edit too much +{ config, lib, pkgs, modulesPath, ... }: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + # Set all boot options + boot = { + # Set a kernel version and load/blacklist drivers + kernelPackages = pkgs.linuxPackages_zen; + blacklistedKernelModules = [ + "pcspkr" + ]; + kernel.sysctl."vm.max_map_count" = 2147483642; + initrd = { + availableKernelModules = [ + "nvme" + "xhci_pci" + "usbhid" + "usb_storage" + "sd_mod" + "sdhci_pci" + ]; + kernelModules = [ + "kvm-amd" + ]; + }; + + # Manage supported filesystems + supportedFilesystems = { + ntfs = true; + zfs = lib.mkForce false; + }; + }; + + # Mount everything as necessary + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/c0fe8419-88f9-48a0-8c5b-acd4c11f8037"; + fsType = "ext4"; + }; + "/boot" = { + device = "/dev/disk/by-uuid/5669-7EF6"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + }; + + # Enables DHCP on each ethernet and wireless interface. + networking.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/nixos/lenovo.nix b/nixos/lenovo.nix new file mode 100644 index 0000000..a714972 --- /dev/null +++ b/nixos/lenovo.nix @@ -0,0 +1,46 @@ +{ + imports = [ + # Base configs + ./base.nix + + # Import users and groups + ./users/jimbo.nix + ./users/groups.nix + + # Desktop only + ./desktop/misc.nix + ./desktop/sway.nix + ./desktop/greetd-sway.nix + ./desktop/printing.nix + ./desktop/gaming.nix + ./desktop/pipewire.nix + ./desktop/bluetooth.nix + ./desktop/firewall.nix + ./desktop/fonts.nix + ./desktop/qt.nix + + # Laptop/Portable only + ./hardware/wireless.nix + + # Modules + ./modules/security.nix + ./modules/legacy.nix + + # Hardware + ./hardware/machines/lenovo.nix + ./hardware/systemdboot.nix + ./hardware/opengl.nix + + # Services + ./services/openssh.nix + ./services/udev.nix + ./services/sunshine.nix + ./services/mpd.nix + ]; + + # Set hostname + networking.hostName = "JimLenovo"; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = "24.05"; +} diff --git a/nixos/server.nix b/nixos/server.nix index 6d64bfb..557c26b 100644 --- a/nixos/server.nix +++ b/nixos/server.nix @@ -45,7 +45,10 @@ ./server/matrix-discord.nix ]; + # Set custom openssh port services.openssh.ports = [ 2222 ]; + + # Set hostname networking.hostName = "JimServer"; # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion