From 6fc90dcdec0e7dbb3b68e0b6791959aced4ca642 Mon Sep 17 00:00:00 2001 From: Christian Harke Date: Fri, 22 Sep 2023 16:31:55 +0200 Subject: [PATCH] Add steambox role --- home/base/default.nix | 2 - hosts/nixos-vm/default.nix | 8 ++- hosts/nixos-vm/home-christian.nix | 2 + hosts/nixos-vm/home-demo.nix | 2 + hosts/nixos-vm/state-version.nix | 1 + hosts/non-nixos-vm/home-christian.nix | 2 + hosts/non-nixos-vm/home-demo.nix | 2 + hosts/non-nixos-vm/state-version.nix | 1 + .../{roles/desktop => base}/input/default.nix | 10 ---- nixos/base/system/network/default.nix | 5 +- nixos/programs/direnv/default.nix | 25 ++++++++ nixos/roles/desktop/default.nix | 10 +++- nixos/roles/desktop/direnv/default.nix | 7 --- nixos/roles/desktop/gaming/default.nix | 22 ------- nixos/roles/desktop/printing/default.nix | 39 ------------- nixos/roles/desktop/sound/default.nix | 13 ----- nixos/roles/gaming/default.nix | 34 +++++++++++ nixos/roles/{desktop => }/mobile/default.nix | 21 ++++++- nixos/roles/printing/default.nix | 48 +++++++++++++++ nixos/roles/sound/default.nix | 29 ++++++++++ nixos/roles/steambox/default.nix | 58 +++++++++++++++++++ 21 files changed, 242 insertions(+), 99 deletions(-) create mode 100644 hosts/nixos-vm/state-version.nix create mode 100644 hosts/non-nixos-vm/state-version.nix rename nixos/{roles/desktop => base}/input/default.nix (67%) create mode 100644 nixos/programs/direnv/default.nix delete mode 100644 nixos/roles/desktop/direnv/default.nix delete mode 100644 nixos/roles/desktop/gaming/default.nix delete mode 100644 nixos/roles/desktop/printing/default.nix delete mode 100644 nixos/roles/desktop/sound/default.nix create mode 100644 nixos/roles/gaming/default.nix rename nixos/roles/{desktop => }/mobile/default.nix (71%) create mode 100644 nixos/roles/printing/default.nix create mode 100644 nixos/roles/sound/default.nix create mode 100644 nixos/roles/steambox/default.nix diff --git a/home/base/default.nix b/home/base/default.nix index ac965afe..083be35a 100644 --- a/home/base/default.nix +++ b/home/base/default.nix @@ -9,8 +9,6 @@ ]; enableNixpkgsReleaseCheck = true; - - stateVersion = "22.11"; }; xdg.userDirs = { diff --git a/hosts/nixos-vm/default.nix b/hosts/nixos-vm/default.nix index 9aafb0b5..18e82e3c 100644 --- a/hosts/nixos-vm/default.nix +++ b/hosts/nixos-vm/default.nix @@ -5,12 +5,16 @@ custom = { base.users = [ "demo" "christian" ]; - roles.desktop.enable = true; + roles = { + desktop.enable = true; + gaming.enable = true; + printing.enable = true; + }; }; # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - system.stateVersion = "22.11"; + system.stateVersion = import ./state-version.nix; } diff --git a/hosts/nixos-vm/home-christian.nix b/hosts/nixos-vm/home-christian.nix index 8fc1da12..f9bdf066 100644 --- a/hosts/nixos-vm/home-christian.nix +++ b/hosts/nixos-vm/home-christian.nix @@ -2,4 +2,6 @@ custom = { users.christian.enable = true; }; + + home.stateVersion = import ./state-version.nix; } diff --git a/hosts/nixos-vm/home-demo.nix b/hosts/nixos-vm/home-demo.nix index 2080edef..956bd700 100644 --- a/hosts/nixos-vm/home-demo.nix +++ b/hosts/nixos-vm/home-demo.nix @@ -3,4 +3,6 @@ users.demo.enable = true; roles.desktop.enable = true; }; + + home.stateVersion = import ./state-version.nix; } diff --git a/hosts/nixos-vm/state-version.nix b/hosts/nixos-vm/state-version.nix new file mode 100644 index 00000000..861e8611 --- /dev/null +++ b/hosts/nixos-vm/state-version.nix @@ -0,0 +1 @@ +"23.05" diff --git a/hosts/non-nixos-vm/home-christian.nix b/hosts/non-nixos-vm/home-christian.nix index d7aa128a..cbd42af5 100644 --- a/hosts/non-nixos-vm/home-christian.nix +++ b/hosts/non-nixos-vm/home-christian.nix @@ -3,4 +3,6 @@ base.non-nixos.enable = true; users.christian.enable = true; }; + + home.stateVersion = import ./state-version.nix; } diff --git a/hosts/non-nixos-vm/home-demo.nix b/hosts/non-nixos-vm/home-demo.nix index 6dd917f6..8902231e 100644 --- a/hosts/non-nixos-vm/home-demo.nix +++ b/hosts/non-nixos-vm/home-demo.nix @@ -11,4 +11,6 @@ web.enable = true; }; }; + + home.stateVersion = import ./state-version.nix; } diff --git a/hosts/non-nixos-vm/state-version.nix b/hosts/non-nixos-vm/state-version.nix new file mode 100644 index 00000000..861e8611 --- /dev/null +++ b/hosts/non-nixos-vm/state-version.nix @@ -0,0 +1 @@ +"23.05" diff --git a/nixos/roles/desktop/input/default.nix b/nixos/base/input/default.nix similarity index 67% rename from nixos/roles/desktop/input/default.nix rename to nixos/base/input/default.nix index c84f3a30..7f539dfd 100644 --- a/nixos/roles/desktop/input/default.nix +++ b/nixos/base/input/default.nix @@ -12,16 +12,6 @@ in services = { xserver = { layout = "ch"; - - # Touchpad settings - libinput = { - enable = true; - touchpad = { - naturalScrolling = true; - disableWhileTyping = true; - sendEventsMode = "disabled-on-external-mouse"; - }; - }; }; udev.extraRules = '' diff --git a/nixos/base/system/network/default.nix b/nixos/base/system/network/default.nix index 8ce34177..a7027a4a 100644 --- a/nixos/base/system/network/default.nix +++ b/nixos/base/system/network/default.nix @@ -10,5 +10,8 @@ programs.nm-applet.enable = true; # Enable the OpenSSH daemon. - services.openssh.enable = true; + services.openssh = { + enable = true; + settings.PasswordAuthentication = false; + }; } diff --git a/nixos/programs/direnv/default.nix b/nixos/programs/direnv/default.nix new file mode 100644 index 00000000..e790a609 --- /dev/null +++ b/nixos/programs/direnv/default.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, ... } @ args: + +with lib; + +let + + cfg = config.custom.programs.direnv; + +in + +{ + options = { + custom.programs.direnv = { + enable = mkEnableOption "Direnv config"; + }; + }; + + config = mkIf cfg.enable { + # Nix options for derivations to persist garbage collection + nix.extraOptions = '' + keep-outputs = true + keep-derivations = true + ''; + }; +} diff --git a/nixos/roles/desktop/default.nix b/nixos/roles/desktop/default.nix index 25f227d2..cc44e52b 100644 --- a/nixos/roles/desktop/default.nix +++ b/nixos/roles/desktop/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... } @ args: +{ config, lib, pkgs, ... }: with lib; @@ -16,6 +16,14 @@ in }; config = mkIf cfg.enable { + custom = { + programs.direnv.enable = true; + roles = { + printing.enable = true; + sound.enable = true; + }; + }; + services = { xserver = { enable = true; diff --git a/nixos/roles/desktop/direnv/default.nix b/nixos/roles/desktop/direnv/default.nix deleted file mode 100644 index a2a5b214..00000000 --- a/nixos/roles/desktop/direnv/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ - # Nix options for derivations to persist garbage collection - nix.extraOptions = '' - keep-outputs = true - keep-derivations = true - ''; -} diff --git a/nixos/roles/desktop/gaming/default.nix b/nixos/roles/desktop/gaming/default.nix deleted file mode 100644 index eea87640..00000000 --- a/nixos/roles/desktop/gaming/default.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - - cfg = config.custom.roles.desktop.gaming; - -in - -{ - options = { - custom.roles.desktop.gaming = { - enable = mkEnableOption "Gaming computer config"; - }; - }; - - config = mkIf cfg.enable { - programs.steam.enable = true; - hardware.xpadneo.enable = true; - }; -} diff --git a/nixos/roles/desktop/printing/default.nix b/nixos/roles/desktop/printing/default.nix deleted file mode 100644 index 4c66cb4a..00000000 --- a/nixos/roles/desktop/printing/default.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ pkgs, ... }: - -let - - hplip = pkgs.unstable.hplipWithPlugin; - -in - -{ - - services.printing = { - enable = true; - drivers = [ hplip ]; - }; - - hardware = { - printers.ensurePrinters = [{ - name = "pr-hp-chr"; - location = "Home Office"; - description = "HP Officejet Pro 8600 Plus"; - deviceUri = "hp:/net/Officejet_Pro_8600?hostname=pr-hp-chr"; - model = "drv:///hp/hpcups.drv/hp-officejet_pro_8600.ppd"; - ppdOptions = { - "PageSize" = "A4"; - "Duplex" = "DuplexNoTumble"; - "InputSlot" = "Tray2"; - "ColorModel" = "KGray"; - "MediaType" = "Plain"; - "OutputMode" = "Normal"; - "OptionDuplex" = "True"; - }; - }]; - - sane = { - enable = true; - extraBackends = [ hplip ]; - }; - }; -} diff --git a/nixos/roles/desktop/sound/default.nix b/nixos/roles/desktop/sound/default.nix deleted file mode 100644 index 792feea4..00000000 --- a/nixos/roles/desktop/sound/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ pkgs, ... }: - -{ - sound.enable = true; - hardware = { - bluetooth.enable = true; - pulseaudio = { - enable = true; - package = pkgs.pulseaudioFull; - }; - }; - environment.systemPackages = [ pkgs.pavucontrol ]; -} diff --git a/nixos/roles/gaming/default.nix b/nixos/roles/gaming/default.nix new file mode 100644 index 00000000..452c5670 --- /dev/null +++ b/nixos/roles/gaming/default.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.custom.roles.gaming; + +in + +{ + options = { + custom.roles.gaming = { + enable = mkEnableOption "Gaming computer config"; + }; + }; + + config = mkIf cfg.enable { + # open ports for steam stream and some games + networking.firewall.allowedTCPPorts = [ 27036 27037 ] ++ (range 27015 27030); + networking.firewall.allowedUDPPorts = [ 4380 27036 ] ++ (range 27000 27031); + + programs.steam.enable = true; + + # Gaming 32bit + #hardware.opengl.driSupport32Bit = true; + #hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ]; + #hardware.pulseaudio.support32Bit = true; + + # Xbox controller + hardware.xpadneo.enable = true; + #boot.extraModprobeConfig = '' options bluetooth disable_ertm=1 ''; + }; +} diff --git a/nixos/roles/desktop/mobile/default.nix b/nixos/roles/mobile/default.nix similarity index 71% rename from nixos/roles/desktop/mobile/default.nix rename to nixos/roles/mobile/default.nix index 7bdd3da3..0258a16c 100644 --- a/nixos/roles/desktop/mobile/default.nix +++ b/nixos/roles/mobile/default.nix @@ -4,25 +4,42 @@ with lib; let - cfg = config.custom.roles.desktop.mobile; + cfg = config.custom.roles.mobile; in { options = { - custom.roles.desktop.mobile = { + custom.roles.mobile = { enable = mkEnableOption "Mobile computer config"; }; }; config = mkIf cfg.enable { + custom.programs = { + direnv.enable = true; + }; + services = { logind = { lidSwitch = "suspend-then-hibernate"; lidSwitchDocked = "ignore"; lidSwitchExternalPower = "lock"; }; + upower.enable = true; + + xserver = { + # Touchpad settings + libinput = { + enable = true; + touchpad = { + naturalScrolling = true; + disableWhileTyping = true; + sendEventsMode = "disabled-on-external-mouse"; + }; + }; + }; }; networking.networkmanager.dispatcherScripts = [{ diff --git a/nixos/roles/printing/default.nix b/nixos/roles/printing/default.nix new file mode 100644 index 00000000..dae06804 --- /dev/null +++ b/nixos/roles/printing/default.nix @@ -0,0 +1,48 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.custom.roles.printing; + +in + +{ + options = { + custom.roles.printing = { + enable = mkEnableOption "Printing config"; + }; + }; + + config = mkIf cfg.enable { + services.printing = { + enable = true; + drivers = [ pkgs.hplip ]; + }; + + hardware = { + printers.ensurePrinters = [{ + name = "pr-hp-chr"; + location = "Home Office"; + description = "HP Officejet Pro 8600 Plus"; + deviceUri = "hp:/net/Officejet_Pro_8600?hostname=pr-hp-chr"; + model = "drv:///hp/hpcups.drv/hp-officejet_pro_8600.ppd"; + ppdOptions = { + "PageSize" = "A4"; + "Duplex" = "DuplexNoTumble"; + "InputSlot" = "Tray2"; + "ColorModel" = "KGray"; + "MediaType" = "Plain"; + "OutputMode" = "Normal"; + "OptionDuplex" = "True"; + }; + }]; + + sane = { + enable = true; + extraBackends = [ pkgs.hplip ]; + }; + }; + }; +} diff --git a/nixos/roles/sound/default.nix b/nixos/roles/sound/default.nix new file mode 100644 index 00000000..319bfd1e --- /dev/null +++ b/nixos/roles/sound/default.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.custom.roles.sound; + +in + +{ + options = { + custom.roles.sound = { + enable = mkEnableOption "Audio config"; + }; + }; + + config = mkIf cfg.enable { + sound.enable = true; + hardware = { + bluetooth.enable = true; + pulseaudio = { + enable = true; + package = pkgs.pulseaudioFull; + }; + }; + environment.systemPackages = [ pkgs.pavucontrol ]; + }; +} diff --git a/nixos/roles/steambox/default.nix b/nixos/roles/steambox/default.nix new file mode 100644 index 00000000..dbdfef93 --- /dev/null +++ b/nixos/roles/steambox/default.nix @@ -0,0 +1,58 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.custom.roles.steambox; + steam_autostart = pkgs.makeAutostartItem { + name = "steam"; + package = pkgs.steam; + }; + +in + +{ + options = { + custom.roles.steambox = { + enable = mkEnableOption "Steam box config"; + }; + }; + + config = mkIf cfg.enable { + custom.roles = { + gaming.enable = true; + sound.enable = true; + }; + + environment.systemPackages = with pkgs; [ + steam_autostart + steam-run + ]; + + # Enable the KDE Desktop Environment. + services.xserver = { + enable = true; + desktopManager.plasma5.enable = true; + displayManager.sddm = { + enable = true; + autoLogin = { + enable = true; + user = "gamer"; + }; + }; + }; + + users = { + users = { + gamer = { + password = ""; + isNormalUser = true; + }; + }; + }; + + #systemd.extraConfig = "DefaultLimitNOFILE=1048576"; + #boot.kernelPackages = pkgs.linuxPackages_latest; + }; +}