Skip to content

Instantly share code, notes, and snippets.

@AcouBass
Last active March 6, 2024 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AcouBass/12b148d98b21347ba562aa3a2df074f3 to your computer and use it in GitHub Desktop.
Save AcouBass/12b148d98b21347ba562aa3a2df074f3 to your computer and use it in GitHub Desktop.
Nixos GPD Win Max 2 setup
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, inputs, ... }:
{
chaotic.linux_hdr.specialisation. enable = true;
chaotic.mesa-git.enable = true;
chaotic.mesa-git.fallbackSpecialisation = true;
chaotic.appmenu-gtk3-module.enable = true;
chaotic.steam.extraCompatPackages = with pkgs; [ proton-ge-custom ];
programs.gamescope = {
env = { ENABLE_GAMESCOPE_WSI = "1"; __GLX_VENDOR_LIBRARY_NAME = "mesa"; };
enable = true;
package = pkgs.gamescope;
args = [ "--rt" ];
};
imports =
[ # Include the results of the hardware scan.
./pipewire.nix
./hardware-configuration.nix
#./acpioverride
#./custom-systemd-units
];
fonts = {
fontDir.enable = true;
packages = [ pkgs.corefonts ];
};
xdg.portal.enable = true;
zramSwap.enable = true;
systemd = {
user.extraConfig = "DefaultLimitNOFILE=524288";
tmpfiles.rules =
[ "L+ /opt/rocm/hip - - - - ${pkgs.rocmPackages.clr}" ];
};
powerManagement = {
enable = true;
cpuFreqGovernor = pkgs.lib.mkDefault "powersave";
};
security = {
pam.loginLimits = [
{ domain = "*"; item = "nofile"; type = "-"; value = "524288"; }
{ domain = "*"; item = "memlock"; type = "-"; value = "524288"; }
];
pam.u2f = {
enable = true;
cue = true;
};
sudo.wheelNeedsPassword = false;
rtkit.enable = true;
};
nix = {
nixPath = [
"nixpkgs=/etc/channels/nixos"
"nixos-config=/home/eddie/gits/nixos/nixos-wm2/configuration.nix"
"/nix/var/nix/profiles/per-user/root/channels"
];
registry.nixpkgs.flake = inputs.nixos;
daemonCPUSchedPolicy = "batch";
package = pkgs.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes
gc-keep-outputs = true
gc-keep-derivations = true
'';
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 14d";
};
optimise.automatic = true;
settings = {
allowed-users = [ "root" "@wheel" "@builders" ];
trusted-users = [ "root" "@wheel" "@builders" ];
auto-optimise-store = true;
substituters = [ "https://nix-gaming.cachix.org" ];
trusted-public-keys = [
"nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4="
];
};
};
networking = {
firewall = {
allowedTCPPorts = [ 2222 ];
allowedUDPPorts = [ 2222 ];
};
hostName = "NixWM2"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking
networkmanager.enable = true;
};
# Set your time zone.
# time.timeZone = "Europe/London";
# Select internationalisation properties.
i18n.defaultLocale = "en_GB.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_GB.UTF-8";
LC_IDENTIFICATION = "en_GB.UTF-8";
LC_MEASUREMENT = "en_GB.UTF-8";
LC_MONETARY = "en_GB.UTF-8";
LC_NAME = "en_GB.UTF-8";
LC_NUMERIC = "en_GB.UTF-8";
LC_PAPER = "en_GB.UTF-8";
LC_TELEPHONE = "en_GB.UTF-8";
LC_TIME = "en_GB.UTF-8";
};
# Enable the X11 windowing system.
services = {
automatic-timezoned.enable = true;
#ofono = {
# enable = true;
# plugins = [ pkgs.modem-manager-gui pkgs.libsForQt5.modemmanager-qt ];
# };
tailscale = {
enable = true;
useRoutingFeatures = "client";
};
udev.packages = [ pkgs.solo2-cli ];
#flatpak.enable = true;
fstrim.enable = true;
auto-cpufreq.enable = true;
power-profiles-daemon.enable = false;
input-remapper.enable = true;
tor = {
enable = true;
client.enable = true;
};
openssh = {
enable = true;
startWhenNeeded = true;
settings = {
PermitRootLogin = "no";
};
};
syncthing = {
enable = true;
dataDir = "/home/eddie/";
openDefaultPorts = true;
user = "eddie";
};
avahi = {
enable = true;
nssmdns = true;
openFirewall = true;
};
xserver = {
enable = true;
# Enable the KDE Plasma Desktop Environment.
displayManager = {
sddm.enable = true;
defaultSession = "plasmawayland";
};
desktopManager.plasma5.enable = true;
layout = "us";
xkbVariant = "";
};
thermald.enable = true;
printing = {
enable = true;
drivers = [ pkgs.gutenprint pkgs.cnijfilter2 ];
};
};
# Configure console keymap
console.keyMap = "uk";
# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
wireplumber.enable = true;
lowLatency.enable = true;
# If you want to use JACK applications, uncomment this
jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
users = {
defaultUserShell = pkgs.fish;
#mutableUsers = false;
groups.builders = {};
users.eddie = {
isNormalUser = true;
#shell = pkgs.fish;
description = "Eddie Baxter";
extraGroups = [
"adbusers"
"libvirtd"
"networkmanager"
"scanner"
"lp"
"wheel"
"i2c"
"video"
"audio"
"input"
];
};
};
# Allow unfree packages
virtualisation = {
waydroid.enable = true;
# spiceUSBRedirection.enable = true;
# libvirtd = {
# onBoot = "ignore";
# enable = true;
# };
};
nixpkgs = {
#overlays = [ acpi_patch { initrd = /home/eddie/gits/nixos/nixos-wm2/acpi_override; } ];
config = {
packageOverrides = pkgs: {
steam = pkgs.steam.override {
extraPkgs = pkgs: with pkgs; [
xorg.libXcursor
xorg.libXi
xorg.libXinerama
xorg.libXScrnSaver
libpng
libpulseaudio
libvorbis
stdenv.cc.cc.lib
libkrb5
keyutils
];
};
};
allowUnfree = true;
# firefox.enablePlasmaBrowserIntegration = true;
permittedInsecurePackages = [ "python-2.7.18.6" ];
};
};
# List packages installed in system profile. To search, run:
# $ nix search wget
environment = {
systemPackages = with pkgs;
[
sbctl
solo2-cli
fido2luks
gamescope mangohud
unstable.heroic legendary-gl
#virt-manager
acpica-tools
ryzenadj
git
unstable.steamtinkerlaunch
unstable.appimage-run
unstable.appimagekit
libreoffice-qt
hunspell
hunspellDicts.en_GB-ize
hunspellDicts.en_GB-ise
unoconv
vopono
unstable.dxvk
winetricks
playonlinux
gimp-with-plugins
ffmpeg-full
vlc
wineWowPackages.stagingFull
## KDE stuff
krita
lxqt.pavucontrol-qt
calibre
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
# wget
] ++ (with libsForQt5; [
drumstick
discover
kaccounts-integration
kaccounts-providers
kalendar
kmail
kmail-account-wizard
korganizer
kaddressbook
akregator
knotes
kontact
kate
kdenlive
krunner-ssh
krunner-symbols
(ark.override { unfreeEnableUnrar = true; })
]);
etc."channels/nixpkgs".source = inputs.nixos.outPath;
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
programs = {
gamemode.enable = true;
dconf.enable = true;
# firefox.enable = true;
xwayland.enable = true;
# droidcam.enable = true;
ccache.enable = true;
adb.enable = true;
fish.enable = true;
kdeconnect.enable = true;
steam = {
gamescopeSession = {
enable = true;
args = [ "--rt" ];
env = { ENABLE_GAMESCOPE_WSI = "1"; };
#steamArgs = [ "-pipewire-dmabuf" ];
};
enable = true;
remotePlay.openFirewall = true;
};
firejail = {
enable = true;
wrappedBinaries = {
#firefoxjail = {
#executable = "${pkgs.firefox}/bin/firefox";
#profile = "${pkgs.firejail}/etc/firejail/firefox.profile";
#};
skypeforlinuxjail = {
executable = "${pkgs.skypeforlinux}/bin/skypeforlinux";
profile = "${pkgs.firejail}/etc/firejail/skypeforlinux.profile";
};
Discord = {
executable = "${pkgs.discord}/bin/discord";
profile = "${pkgs.firejail}/etc/firejail/Discord.profile";
};
#Chromium = {
#executable = "${pkgs.chromium}/bin/chromium";
#profile = "${pkgs.firejail}/etc/firejail/chromium.profile";
#};
};
};
# programs.mtr.enable = true;
gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
};
musnix = {
enable = true;
alsaSeq.enable = true;
soundcardPciId = "0b:00.4";
das_watchdog.enable = true;
};
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system = {
stateVersion = "23.11"; # Did you read the comment?
};
}
{
description = "NixOS configuration with two or more channels";
inputs = {
nur.url = github:nix-community/NUR;
nix-gaming = {
url = "github:fufexan/nix-gaming";
inputs.nixpkgs.follows = "nixos";
};
nixos.url = "github:NixOS/nixpkgs/nixos-23.11";
lanzaboote = {
url = "github:nix-community/lanzaboote";
inputs.nixpkgs.follows = "nixos";
};
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
musnix = {
url = "github:musnix/musnix";
inputs.nixpkgs.follows = "nixos";
};
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixos";
};
#chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable";
};
outputs = inputs @ { self, nix-gaming, nixos, lanzaboote, nixpkgs-unstable, nur, musnix, home-manager }:
let
system = "x86_64-linux";
pkgs = import nixos {
inherit system;
config = {
permittedInsecurePackages = [ "openssl-1.1.1t" ];
allowUnfree = true;
};
overlays = [];
};
#unstable = nixpkgs-unstable.legacyPackages.${prev.system};
# use this variant if unfree packages are needed:
overlay-unstable = final: prev: {
unstable = import nixpkgs-unstable {
inherit system;
config = {
permittedInsecurePackages = [ "openssl-1.1.1t" ];
allowUnfree = true;
};
};
};
in {
nixosConfigurations."NixWM2" = nixos.lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs self nix-gaming; };
modules = let
nur-modules = import nur {
nurpkgs = nixos.legacyPackages.x86_64-linux;
pkgs = nixos.legacyPackages.x86_64-linux;
};
in [
# ];
# modules = [
#chaotic.nixosModules.default
musnix.nixosModules.musnix
lanzaboote.nixosModules.lanzaboote
# Overlays-module makes "pkgs.unstable" available in configuration.nix
({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-unstable nur.overlay ]; })
./configuration.nix
inputs.nix-gaming.nixosModules.pipewireLowLatency
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.eddie = import ./home.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") ];
systemd.targets.ac = {
conflicts = [ "battery.target" ];
description = "On AC power";
unitConfig = { DefaultDependencies = "false"; };
};
systemd.targets.battery = {
conflicts = [ "ac.target" ];
description = "On battery power";
unitConfig = { DefaultDependencies = "false"; };
};
systemd.services.power-maximum-tdp = {
description = "Change TDP to maximum TDP when on AC power";
wantedBy = [ "ac.target" ];
unitConfig = { RefuseManualStart = true; };
serviceConfig = {
Type = "oneshot";
ExecStart =
"${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit=28000 --fast-limit=28000 --slow-limit=28000 --tctl-temp=90";
};
};
systemd.services.power-saving-tdp = {
description = "Change TDP to power saving TDP when on battery power";
wantedBy = [ "battery.target" ];
unitConfig = { RefuseManualStart = true; };
serviceConfig = {
Type = "oneshot";
ExecStart =
"${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit=8000 --fast-limit=8000 --slow-limit=8000 --tctl-temp=90";
};
};
systemd.services.powertop = {
description = "Auto-tune Power Management with powertop";
unitConfig = { RefuseManualStart = true; };
wantedBy = [ "battery.target" "ac.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.powertop}/bin/powertop --auto-tune";
};
};
systemd.services."inhibit-suspension@" = {
description = "Inhibit suspension for one hour";
serviceConfig = {
Type = "oneshot";
ExecStart =
"${pkgs.systemd}/bin/systemd-inhibit --what=sleep --why=PreventSuspension --who=system /usr/bin/sleep %ih";
};
};
boot = {
blacklistedKernelModules = [ "bmi160_core" "bmi160_i2c" "bmi160_spi" ];
bootspec.enable = true;
kernelPackages = pkgs.linuxPackages_zen;
#kernelPackages = pkgs.linuxPackages_zen;
kernelParams = [ "quiet" "splash" "iomem=relaxed" "amd_pstate=guided" ];
plymouth = {
enable = true;
themePackages = with pkgs; [ breeze-plymouth ];
theme = "breeze";
};
lanzaboote = {
enable = true;
pkiBundle = "/etc/secureboot";
};
loader = {
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi";
};
systemd-boot = {
enable = lib.mkForce false;
#configurationLimit = 5;
};
};
initrd = {
secrets."/crypto_keyfile.bin" = null;
systemd.enable = true;
availableKernelModules =
[ "nvme" "xhci_pci" "thunderbolt" "usbhid" "usb_storage" "sd_mod" ];
kernelModules = [ "amdgpu" ];
luks = {
#fido2Support = true;
devices."luks-c42f2366-e265-4ffa-b500-93eddc5302af" = {
device ="/dev/disk/by-uuid/c42f2366-e265-4ffa-b500-93eddc5302af";
crypttabExtraOpts = ["fido2-device=auto"];
fido2.passwordLess = true;
};
};
};
kernelModules = [ "kvm-amd" "i2c_dev" ];
extraModulePackages = [ ];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/b60b0a30-5a65-4fbf-9288-db1d6f167277";
fsType = "ext4";
};
"/boot/efi" = {
device = "/dev/disk/by-uuid/A7D4-ED72";
fsType = "vfat";
};
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp1s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wwan0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware = {
i2c.enable = true;
sensor.iio.enable = true;
sane = {
enable = true;
extraBackends = [ pkgs.sane-airscan ];
};
opengl = {
driSupport = true;
driSupport32Bit = true;
extraPackages = with pkgs; [
rocm-opencl-icd
vaapiVdpau
rocm-opencl-runtime
libvdpau-va-gl
];
#extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
};
enableAllFirmware = true;
bluetooth = { enable = true; };
cpu.amd.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware;
steam-hardware.enable = true;
};
}
{ config, pkgs, lib, ... }:
{
nixpkgs.config = {
allowUnfree = true;
permittedInsecurePackages = [ "openssl-1.1.1u" ];
};
# Home Manager needs a bit of information about you and the
# paths it should manage.
home = {
enableNixpkgsReleaseCheck = true;
username = "eddie";
homeDirectory = "/home/eddie";
stateVersion = "23.11";
packages = with pkgs; [
mednafen
mednaffe
retroarchFull
wget
discord
skypeforlinux
openrct2
#unstable.runescape
wireguard-tools
chromium
lutris
grc
prusa-slicer
super-slicer-latest
cura
blender
openscad
freecad
## Audio stuff
kapitonov-plugins-pack
ladspaPlugins
distrho
swh_lv2
x42-plugins
mda_lv2
tunefish
infamousPlugins
talentedhack
kapitonov-plugins-pack
eq10q
zam-plugins
wineasio
giada
luppp
freewheeling
reaper
timemachine
easyeffects
musescore
lilypond
carla
calf
unstable.yabridge
unstable.yabridgectl
ardour
tuxguitar
audacity
bespokesynth
surge-XT
surge
lsp-plugins
vocproc
sorcer
odin2
freepats
helm
fluidsynth
zynaddsubfx
yoshimi
infamousPlugins
qsynth
lmms
guitarix
];
# Let Home Manager install and manage itself.
};
#gtk = {
# enable = true;
# iconTheme = {
# name = "breeze-dark";
# package = pkgs.libsForQt5.breeze-icons;
# };
# theme = {
# name = "Breeze-Dark";
# package = pkgs.libsForQt5.breeze-gtk;
# };
#};
programs = {
command-not-found.enable = false;
nix-index = { enable = true; };
yt-dlp = { enable = true; };
htop = { enable = true; };
obs-studio = {
enable = true;
package = pkgs.unstable.obs-studio;
plugins = with pkgs.unstable.obs-studio-plugins; [
obs-vaapi
obs-vkcapture
obs-pipewire-audio-capture
obs-gstreamer
];
};
rbw = {
enable = true;
settings = {
base_url = "https://vault.piecemaker.rocks";
email = "pieceredd@gmail.com";
pinentry = "qt";
};
};
firefox = {
enable = true;
profiles = {
eddie = {
#search.default = "DuckDuckGo";
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
floccus
auto-tab-discard
bitwarden
consent-o-matic
darkreader
duckduckgo-privacy-essentials
facebook-container
firefox-translations
multi-account-containers
musescore-downloader
plasma-integration
privacy-badger
privacy-pass
profile-switcher
reddit-enhancement-suite
sponsorblock
streetpass-for-mastodon
temporary-containers
ublock-origin
fediact
];
};
};
};
fish = {
enable = true;
interactiveShellInit = ''
set fish_greeting # Disable greeting
'';
plugins = [
# Enable a plugin (here grc for colorized command output) from nixpkgs
{
name = "grc";
src = pkgs.fishPlugins.grc.src;
}
{
name = "done";
src = pkgs.fishPlugins.done.src;
}
{
name = "sponge";
src = pkgs.fishPlugins.sponge.src;
}
];
};
home-manager.enable = true;
};
xdg.systemDirs.data = [ "/usr/share" "/var/lib/flatpak/exports/share" "$HOME/.local/share/flatpak/exports/share" ];
#services = {
#easyeffects.enable = true;
# };
systemd.user = {
sessionVariables = {
CLUTTER_BACKEND = "wayland";
GDK_BACKEND = "wayland,x11";
QT_QPA_PLATFORM = "wayland;xcb";
MOZ_ENABLE_WAYLAND = "1";
_JAVA_AWT_WM_NONREPARENTING = "1";
STEAM_EXTRA_COMPAT_TOOL_PATHS = "/home/eddie/.local/share/Steam/compatibilitytools.d/SteamTinkerLaunch/";
};
};
}
{ config, lib, pkgs, modulesPath, ... }:
{
environment.etc = {
"pipewire/client-rt.conf" = {
text = ''
"context.properties" = {
"link.max-buffers" = 16 # version < 3 clients can't handle more than this
"log.level" = 2 # https://docs.pipewire.org/page_daemon.html
"default.clock.rate" = 48000
"default.clock.allowed-rates" = [ 48000 44100 ]
"default.clock.quantum" = 32
#"default.clock.min-quantum" = 32;
"core.daemon" = true
"core.name" = "pipewire-0"
"default.clock.max-quantum" = 8192
}
"context.modules" = [
{
name = "libpipewire-module-rtkit"
args = {
"nice.level" = -15
"rt.prio" = 88
"rt.time.soft" = 200000
"rt.time.hard" = 200000
}
flags = [ "ifexists" "nofail" ]
}
{ name = "libpipewire-module-protocol-native" }
{ name = "libpipewire-module-profiler" }
{ name = "libpipewire-module-metadata" }
{ name = "libpipewire-module-spa-device-factory" }
{ name = "libpipewire-module-spa-node-factory" }
{ name = "libpipewire-module-client-node" }
{ name = "libpipewire-module-client-device" }
{
name = "libpipewire-module-portal"
flags = [ "ifexists" "nofail" ]
}
{
name = "libpipewire-module-access"
args = { }
}
{ name = "libpipewire-module-adapter" }
{ name = "libpipewire-module-link-factory" }
{ name = "libpipewire-module-session-manager" }
]
'';
};
};
}
@simonwjackson
Copy link

Any chance you could post your acpioverride.nix file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment