~ruther/nixos-config

85c5df7eafc236f500a460a74b9f45850fbf5201 — Rutherther 1 year, 6 months ago 6d88e6a
chore: prepare laptop, desktop configs
6 files changed, 20 insertions(+), 296 deletions(-)

M hosts/desktop/default.nix
D hosts/desktop/hardware-configuration.nix
M hosts/desktop/home.nix
M hosts/laptop/default.nix
D hosts/laptop/hardware-configuration.nix
M hosts/laptop/home.nix
M hosts/desktop/default.nix => hosts/desktop/default.nix +15 -40
@@ 24,9 24,7 @@
  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/programs/games.nix)] ++        # Gaming
    [(import ../../modules/programs/flatpak.nix)] ++        # Gaming
    [(import ../../modules/desktop/hyprland/default.nix)] ++ # Window Manager
    [(import ../../modules/hardware/dslr.nix)] ++         # Temp Fix DSLR Webcam
    [(import ../../modules/desktop/qtile/default.nix)] ++ # Window Manager
    (import ../../modules/desktop/virtualisation) ++      # Virtual Machines & VNC
    (import ../../modules/hardware);                      # Hardware devices



@@ 52,14 50,8 @@
    opengl = {
      enable = true;
      extraPackages = with pkgs; [
        #intel-media-driver                     # iGPU
        #vaapiIntel
      #  rocm-opencl-icd                         # AMD
      #  rocm-opencl-runtime
      amdvlk
      ];
      extraPackages32 = with pkgs; [
        driversi686Linux.amdvlk
        linuxKernel.packages.linux_latest_libre.amdgpu-pro
        xorg.xf86videoamdgpu
      ];
      driSupport = true;
      driSupport32Bit = true;


@@ 68,31 60,14 @@

  environment = {                               # Packages installed system wide
    systemPackages = with pkgs; [               # This is because some options need to be configured.
      discord
      #plex
      simple-scan
      x11vnc
      wacomtablet
      clinfo
      xorg.xf86videoamdgpu
    ];
    #variables = {
    #  LIBVA_DRIVER_NAME = "i965";
    #};
  };

  services = {
    blueman.enable = true;                      # Bluetooth
    samba = {                                   # File Sharing over local network
      enable = true;                            # Don't forget to set a password:  $ smbpasswd -a <user>
      shares = {
        share = {
          "path" = "/home/${user}";
          "guest ok" = "yes";
          "read only" = "no";
        };
      };
      openFirewall = true;
    };
    xserver.videoDrivers = [ "amdgpu" ];
  };

  networking.wireguard.interfaces = {


@@ 101,14 76,14 @@
    };
  };

  nixpkgs.overlays = [                          # This overlay will pull the latest version of Discord
    (self: super: {
      discord = super.discord.overrideAttrs (
        _: { src = builtins.fetchTarball {
          url = "https://discord.com/api/download?platform=linux&format=tar.gz";
          sha256 = "1z980p3zmwmy29cdz2v8c36ywrybr7saw8n0w7wlb74m63zb9gpi";
        };}
      );
    })
  ];
  # nixpkgs.overlays = [                          # This overlay will pull the latest version of Discord
  #   (self: super: {
  #     discord = super.discord.overrideAttrs (
  #       _: { src = builtins.fetchTarball {
  #         url = "https://discord.com/api/download?platform=linux&format=tar.gz";
  #         sha256 = "1z980p3zmwmy29cdz2v8c36ywrybr7saw8n0w7wlb74m63zb9gpi";
  #       };}
  #     );
  #   })
  # ];
}

D hosts/desktop/hardware-configuration.nix => hosts/desktop/hardware-configuration.nix +0 -145
@@ 1,145 0,0 @@
#
# Hardware settings for my H310M S2H Desktop
#
# flake.nix
#  └─ ./hosts
#      └─ ./desktop
#          └─ 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 = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "uas" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel"];
  boot.extraModulePackages = with config.boot.kernelPackages; [ ];

  fileSystems."/" =
    { #device = "/dev/disk/by-uuid/80e0d316-954b-4959-8c5d-06be7255a036";
      device = "/dev/disk/by-label/nixos";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { #device = "/dev/disk/by-uuid/FCCC-9ECD";
      device = "/dev/disk/by-label/boot";
      fsType = "vfat";
    };

  #fileSystems."/ssd" =
  #  { #device = "/dev/disk/by-uuid/748e6628-0f4e-4479-8940-daa8531d3390";
  #    device = "/dev/disk/by-label/ssd";
  #    fsType = "ntfs";
  #    options = [ "nofail" ];
  #  };

  #fileSystems."/hdd" =
  #  { #device = "/dev/disk/by-uuid/bbab0f8a-50f4-4a7c-a0d3-0ccb036f11d5";
  #    device = "/dev/disk/by-label/hdd";
  #    fsType = "ext4";
  #    options = [ "nofail" ];
  #  };

  fileSystems."/mnt/toshiba1" =
    { #device = "/dev/disk/by-uuid/7491ea96-a62d-4202-ada7-8d0310dfc967";
      device = "/dev/disk/by-label/toshiba";
      fsType = "ext4";
      options = [ "nofail" ];
    };

  fileSystems."/mnt/toshiba2" =
    { #device = "/dev/disk/by-uuid/21307718-de74-4a24-aaa7-dd09f7e89e32";
      device = "/dev/disk/by-label/toshiba2";
      fsType = "ext4";
      options = [ "nofail" ];
    };

  fileSystems."/mnt/toshiba3" =
    { #device = "/dev/disk/by-uuid/7f5e9ea1-2bc3-44c5-9b6a-d8fe2a311b73"; 
      device = "/dev/disk/by-label/toshiba3";
      fsType = "ext4";
      options = [ "nofail" ];
    };

  fileSystems."/mnt/maxtor" =
    { #device = "/dev/disk/by-uuid/36E6613DE660FE8D";
      device = "/dev/disk/by-label/maxtor";
      fsType = "ntfs";
      options = [ "nofail" ];
    };

  fileSystems."/storage" =
    { #truenas smb storage
      device = "//192.168.0.3/storage";
      fsType = "cifs";
      options = let
        automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
      in ["${automount_opts},mfsymlinks,uid=1000,gid=100,credentials=/home/matthias/smb"];
    };

  fileSystems."/media" =
    { #truenas smb storage
      device = "//192.168.0.3/media";
      fsType = "cifs";
      options = let
        automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
      in ["${automount_opts},mfsymlinks,uid=1000,gid=100,credentials=/home/matthias/smb"];
    };

  #swapDevices =
  #  [
  #    { #device = "/dev/disk/by-uuid/7d0c3f66-c6eb-413c-956f-dfdd8ceb0cae";
  #      device = "/dev/disk/by-label/swap";
  #    }
  #  ];

  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;

  networking = {
    useDHCP = false;                            # Deprecated
    hostName = "desktop";
    enableIPv6 = false;
    bridges = {                                 # Bridge so interface can be used with virtual machines
      "br0" = {
        interfaces = [ "enp3s0" ];              # enp2s0 without 16x PCI-e populated
      };
    };
    interfaces = {
      # enp2s0 = {                              # Change to correct network driver
      #   #useDHCP = true;                      # Disabled because fixed ip
      #   ipv4.addresses = [ {                  # Ip settings: *.0.50 for main machine
      #     address = "192.168.0.50";
      #     prefixLength = 24;
      #   } ];
      # };
      # wlp1s0.useDHCP = true;                  # Wireless card
      br0.ipv4.addresses = [{
        address = "192.168.0.50";
        prefixLength = 24;
      } ];
    };
    defaultGateway = "192.168.0.1";
    nameservers = [ "192.168.0.4" "1.1.1.1"];   # Pi-Hole DNS
    #nameservers = [ "1.1.1.1" "1.0.0.1" ];     # Cloudflare (when Pi-Hole is down)
  };

  #services.hostapd = {                          # Wifi hotspot 
  #  enable = true;
  #  interface = "wlp1s0";
  #  ssid = "desktop";
  #  wpaPassphrase = "<password>";
  #  extraConfig = ''
  #    bridge=br0
  #  '';
  #};
}

M hosts/desktop/home.nix => hosts/desktop/home.nix +1 -1
@@ 16,7 16,7 @@
{
  imports =
    [
      ../../modules/desktop/gnome/home.nix  # Window Manager
      ../../modules/desktop/qtile/home.nix  # Window Manager
    ];

  home = {                                # Specific packages for desktop

M hosts/laptop/default.nix => hosts/laptop/default.nix +3 -40
@@ 21,8 21,7 @@
{
  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/bspwm/default.nix)] ++ # Window Manager
    [(import ../../modules/desktop/virtualisation/docker.nix)] ++  # Docker
    [(import ../../modules/desktop/qtile/default.nix)] ++ # Window Manager
    (import ../../modules/hardware);                      # Hardware devices

  boot = {                                  # Boot options


@@ 44,51 43,21 @@
    };
  };

  hardware.sane = {                         # Used for scanning with Xsane
    enable = true;
    extraBackends = [ pkgs.sane-airscan ];
  };

  environment = {
    systemPackages = with pkgs; [
      simple-scan
      xorg.xf86videointel
    ];
  };

  programs = {                              # No xbacklight, this is the alterantive
    dconf.enable = true;
    light.enable = true;
  };

  services = {
    tlp.enable = true;                      # TLP and auto-cpufreq for power management
    #logind.lidSwitch = "ignore";           # Laptop does not go to sleep when lid is closed
    logind.lidSwitch = "ignore";           # Laptop does not go to sleep when lid is closed
    auto-cpufreq.enable = true;
    blueman.enable = true;
    printing = {                            # Printing and drivers for TS5300
      enable = true;
      drivers = [ pkgs.cnijfilter2 ];
    };
    avahi = {                               # Needed to find wireless printer
      enable = true;
      nssmdns = true;
      publish = {                           # Needed for detecting the scanner
        enable = true;
        addresses = true;
        userServices = true;
      };
    };
    samba = {
      enable = true;
      shares = {
        share = {
          "path" = "/home/${user}";
          "guest ok" = "no";
          "read only" = "no";
        };
      };
      openFirewall = true;
    };
  };

  networking.wireguard.interfaces = {


@@ 96,10 65,4 @@
      ips = [ "${inputs.semi-secrets.wg.lan.laptopIp}/32" ];
    };
  };

  #temporary bluetooth fix
  systemd.tmpfiles.rules = [
    "d /var/lib/bluetooth 700 root root - -"
  ];
  systemd.targets."bluetooth".after = ["systemd-tmpfiles-setup.service"];
}

D hosts/laptop/hardware-configuration.nix => hosts/laptop/hardware-configuration.nix +0 -69
@@ 1,69 0,0 @@
#
# Hardware settings for HP ProBook 650 G1 15.6" Laptop
# Dual boot active. Windows @ sda4 / NixOS @ sda5
#
# 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 = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-label/nixos";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/6E06-6221";
      fsType = "vfat";
    };

  swapDevices = [ ];
  
  networking = {
    useDHCP = false;                        # Deprecated
    hostName = "laptop";
    networkmanager.enable = true;
    interfaces = {
      enp0s25 = {
        useDHCP = true;                     # For versatility sake, manually edit IP on nm-applet.
        #ipv4.addresses = [ {
        #    address = "192.168.0.51";
        #    prefixLength = 24;
        #} ];
      };
      wlo1 = {
        useDHCP = true;
        #ipv4.addresses = [ {
        #  address = "192.168.0.51";
        #  prefixLength = 24;
        #} ];  
      };
    };
    defaultGateway = "192.168.0.1";
    nameservers = [ "192.168.0.4" ];
    firewall = {
      enable = false;
      #allowedUDPPorts = [ 53 67 ];
      #allowedTCPPorts = [ 53 80 443 9443 ];
    };
  };

  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

M hosts/laptop/home.nix => hosts/laptop/home.nix +1 -1
@@ 16,7 16,7 @@
{
  imports =
    [
      ../../modules/desktop/bspwm/home.nix # Window Manager
      ../../modules/desktop/qtile/home.nix # Window Manager
    ];

  home = {                                # Specific packages for laptop

Do not follow this link