From 7442cb7b952af09bced8615544903083e2f67f1b Mon Sep 17 00:00:00 2001 From: Kabbone Date: Fri, 21 Jul 2023 22:07:21 +0200 Subject: [PATCH] hosts: steamdeck: add initial config --- flake.nix | 9 +- hosts/default.nix | 28 +++- hosts/steamdeck/default.nix | 87 ++++++++++++ hosts/steamdeck/hardware-configuration.nix | 151 +++++++++++++++++++++ hosts/steamdeck/home.nix | 57 ++++++++ 5 files changed, 329 insertions(+), 3 deletions(-) create mode 100644 hosts/steamdeck/default.nix create mode 100644 hosts/steamdeck/hardware-configuration.nix create mode 100644 hosts/steamdeck/home.nix diff --git a/flake.nix b/flake.nix index e2da495..cd3c0bc 100644 --- a/flake.nix +++ b/flake.nix @@ -28,9 +28,14 @@ url = "github:ryantm/agenix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + jovian-nixos = { + url = "github:Jovian-Experiments/Jovian-NixOS/development"; + flake = false; + }; }; - outputs = inputs @ { self, nixpkgs, nixpkgs-stable, nixos-hardware, home-manager, nur, agenix, ... }: # Function that tells my flake which to use and what do what to do with the dependencies. + outputs = inputs @ { self, nixpkgs, nixpkgs-stable, nixos-hardware, home-manager, nur, agenix, jovian-nixos, ... }: # Function that tells my flake which to use and what do what to do with the dependencies. let # Variables that can be used in the config files user = "kabbone"; location = "$HOME/.setup"; @@ -39,7 +44,7 @@ nixosConfigurations = ( # NixOS configurations import ./hosts { # Imports ./hosts/default.nix inherit (nixpkgs) lib; - inherit inputs nixpkgs nixpkgs-stable nixos-hardware home-manager nur user location agenix; # Also inherit home-manager so it does not need to be defined here. + inherit inputs nixpkgs nixpkgs-stable nixos-hardware home-manager nur user location agenix jovian-nixos; # Also inherit home-manager so it does not need to be defined here. } ); }; diff --git a/hosts/default.nix b/hosts/default.nix index 5054bd5..55bc62f 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -11,7 +11,7 @@ # └─ ./home.nix # -{ lib, inputs, nixpkgs, nixos-hardware, home-manager, nur, user, location, agenix, ... }: +{ lib, inputs, nixpkgs, nixos-hardware, home-manager, nur, user, location, agenix, jovian-nixos, ... }: let system = "x86_64-linux"; # System architecture @@ -78,6 +78,32 @@ in ]; }; + steamdeck = lib.nixosSystem { # Laptop profile + inherit system; + specialArgs = { inherit inputs user location nixos-hardware nur agenix jovian-nixos; }; + modules = [ + agenix.nixosModules.default + nur.nixosModules.nur + ./steamdeck + ./configuration_desktop.nix + nixos-hardware.nixosModules.common-cpu-amd + nixos-hardware.nixosModules.common-gpu-amd + nixos-hardware.nixosModules.common-pc-ssd + + home-manager.nixosModules.home-manager { + nixpkgs.overlays = [ + nur.overlay + ]; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { inherit user; }; + home-manager.users.${user} = { + imports = [(import ./home.nix)] ++ [(import ./steamdeck/home.nix)]; + }; + } + ]; + }; + dmz = lib.nixosSystem { # Desktop profile inherit system; #user = "dmz-user"; diff --git a/hosts/steamdeck/default.nix b/hosts/steamdeck/default.nix new file mode 100644 index 0000000..b408a8c --- /dev/null +++ b/hosts/steamdeck/default.nix @@ -0,0 +1,87 @@ +# +# Specific system configuration settings for desktop +# +# flake.nix +# ├─ ./hosts +# │ └─ ./laptop +# │ ├─ default.nix * +# │ └─ hardware-configuration.nix +# └─ ./modules +# ├─ ./desktop +# │ └─ ./hyprland +# │ └─ hyprland.nix +# ├─ ./modules +# │ └─ ./programs +# │ └─ waybar.nix +# └─ ./hardware +# └─ default.nix +# + +{ config, pkgs, user, ... }: + +{ + imports = # For now, if applying to other system, swap files + [(import ./hardware-configuration.nix)] ++ # Current system hardware config @ /etc/nixos/hardware-configuration.nix + #[(import ../../modules/desktop/hyprland/default.nix)] ++ # Window Manager + [(import ../../modules/desktop/sway/default.nix)] ++ # Window Manager + [(import ../../modules/desktop/virtualisation/default.nix)] ++ # Docker + (import ../../modules/hardware); # Hardware devices + + boot = { # Boot options + kernelPackages = pkgs.linuxPackages_latest; + + loader = { # EFI Boot + systemd-boot.enable = true; + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot"; + }; + timeout = 1; # Grub auto select time + }; + }; + +# hardware.sane = { # Used for scanning with Xsane +# enable = false; +# extraBackends = [ pkgs.sane-airscan ]; +# }; + hardware = { + nitrokey.enable = true; + }; + +# environment = { +# systemPackages = with pkgs; [ +## alacritty +# ]; +# }; + + programs = { # No xbacklight, this is the alterantive + dconf.enable = true; + light.enable = true; + ssh.startAgent = false; + gnupg.agent = { + enable = true; + enableSSHSupport = true; + pinentryFlavor = "curses"; + }; + steam.enable = true; + }; + + services = { + blueman.enable = true; + printing = { # Printing and drivers for TS5300 + enable = true; + drivers = [ pkgs.gutenprint ]; + }; + avahi = { # Needed to find wireless printer + enable = true; + nssmdns = true; + publish = { # Needed for detecting the scanner + enable = true; + addresses = true; + userServices = true; + }; + }; + tailscale.enable = true; + + }; +} diff --git a/hosts/steamdeck/hardware-configuration.nix b/hosts/steamdeck/hardware-configuration.nix new file mode 100644 index 0000000..4b9b6b6 --- /dev/null +++ b/hosts/steamdeck/hardware-configuration.nix @@ -0,0 +1,151 @@ +# +# Hardware settings for Teclast F5 10" Laptop +# NixOS @ sda2 +# +# flake.nix +# └─ ./hosts +# └─ ./laptop +# └─ hardware-configuration.nix * +# +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "usbhid" "sd_mod" "sdhci_pci" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.kernelParams = [ ]; + boot.tmp.useTmpfs = true; + zramSwap.enable = true; + + services.btrfs.autoScrub = { + enable = true; + interval = "monthly"; + fileSystems = [ + "/" + ]; + }; + + services.btrbk = { + instances = { + hf = { + onCalendar = "hourly"; + settings = { + incremental = "yes"; + snapshot_create = "ondemand"; + snapshot_dir = "@snapshots"; + timestamp_format = "long"; + + snapshot_preserve = "2m 2w 5d 5h"; + snapshot_preserve_min = "latest"; + + volume = { + "/mnt/snapshots/root" = { + snapshot_create = "always"; + subvolume = { + "@home" = {}; + }; + }; + }; + }; + }; + }; + }; + + fileSystems."/" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@,discard=async" ]; + }; + + fileSystems."/home" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@home,discard=async" ]; + }; + + fileSystems."/srv" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@srv,discard=async" ]; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@nix,discard=async" ]; + }; + + fileSystems."/mnt/snapshots/root" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvolid=5,discard=async" ]; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-label/NIXBOOT"; + fsType = "vfat"; + }; + + fileSystems."/sdcard" = + { device = "/dev/disk/by-label/sdcard"; + fsType = "ext4"; + options = [ "nofail" "x-systemd.automount" ]; + }; + + fileSystems."/mnt/Pluto" = + { device = "nas:/Pluto"; + fsType = "nfs"; + options = [ "noauto,users,x-systemd.automount,x-systemd.device-timeout=10,soft,timeo=14,x-systemd.idle-timeout=1min,sec=sys,exec,nfsvers=4.2" ]; + }; + + fileSystems."/mnt/Mars" = + { device = "nas:/Mars"; + fsType = "nfs"; + options = [ "noauto,users,x-systemd.automount,x-systemd.device-timeout=10,soft,timeo=14,x-systemd.idle-timeout=1min,sec=sys,exec,nfsvers=4.2" ]; + }; + + + swapDevices = [ + { device = "/dev/disk/by-label/NIXSWAP"; } + ]; + + + networking = { + useDHCP = false; # Deprecated + hostName = "nix-steamdeck"; + wireless.iwd.enable = true; + networkmanager = { + enable = true; + wifi = { + backend = "iwd"; + powersave = true; + }; + }; +# interfaces = { +# wlan0 = { +# useDHCP = true; # For versatility sake, manually edit IP on nm-applet. +# #ipv4.addresses = [ { +# # address = "192.168.0.51"; +# # prefixLength = 24; +# #} ]; +# }; +# }; + #defaultGateway = "192.168.0.1"; + #nameservers = [ "192.168.0.4" ]; + firewall = { + checkReversePath = "loose"; + # enable = false; + # #allowedUDPPorts = [ 53 67 ]; + # #allowedTCPPorts = [ 53 80 443 9443 ]; + }; + }; + + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/steamdeck/home.nix b/hosts/steamdeck/home.nix new file mode 100644 index 0000000..ad7f755 --- /dev/null +++ b/hosts/steamdeck/home.nix @@ -0,0 +1,57 @@ +# +# Home-manager configuration for laptop +# +# flake.nix +# ├─ ./hosts +# │ └─ ./laptop +# │ └─ home.nix * +# └─ ./modules +# └─ ./desktop +# └─ ./hyprland +# └─ hyprland.nix +# + +{ pkgs, ... }: + +{ + imports = + [ + #../../modules/desktop/hyprland/home.nix # Window Manager + ../../modules/desktop/sway/home.nix # Window Manager + ../../modules/home.nix # Window Manager + ]; + + home = { # Specific packages for laptop + packages = with pkgs; [ + # Applications + libreoffice # Office packages + #firefox + chromium + thunderbird + streamlink + streamlink-twitch-gui-bin + element-desktop + intel-gpu-tools + pulsemixer + + # Display + light # xorg.xbacklight not supported. Other option is just use xrandr. + + # Power Management + #auto-cpufreq # Power management + #tlp # Power management + ]; + }; + + programs = { + alacritty.settings.font.size = 11; + }; + + services = { # Applets + blueman-applet.enable = true; # Bluetooth + network-manager-applet.enable = true; # Network + }; + + xsession.preferStatusNotifierItems = true; + +}