Compare commits

...

4 Commits

13 changed files with 135 additions and 9 deletions

View File

@ -48,7 +48,6 @@
let
system = "x86_64-linux";
username = "josh";
profile = "desktop";
homePath = ./. + "/users/${username}/home.nix";
pkgs = import nixpkgs {
@ -60,6 +59,7 @@
mkHost =
{
host,
profile,
extraModules ? [ ],
}:
nixpkgs.lib.nixosSystem {
@ -79,12 +79,19 @@
in
{
nixosConfigurations = {
laptop = mkHost { host = "laptop"; };
laptop = mkHost {
host = "laptop";
profile = "gaming";
};
vm = mkHost { host = "vm"; };
vm = mkHost {
host = "vm";
profile = "desktop";
};
live = mkHost {
host = "installation-iso";
profile = "desktop";
extraModules = [
(nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix")
{ environment.systemPackages = [ install-system.packages.${system}.default ]; }
@ -94,7 +101,8 @@
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = {
inherit inputs profile username;
inherit inputs username;
profile = "desktop";
};
inherit pkgs;
modules = [

View File

@ -1,9 +1,10 @@
{
profile,
...
}:
{
imports = [
../../profiles/desktop
../../profiles/${profile}
../../modules/nixos
../../modules/drivers

View File

@ -1,9 +1,10 @@
{
profile,
...
}:
{
imports = [
../../profiles/desktop
../../profiles/${profile}
../../modules/nixos
../../modules/drivers

View File

@ -1,9 +1,10 @@
{
profile,
...
}:
{
imports = [
../../profiles/desktop
../../profiles/${profile}
../../modules/nixos
../../modules/drivers

View File

@ -0,0 +1,48 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.battlenet;
yq = "${pkgs.yq}/bin/yq";
jq = "${pkgs.jq}/bin/jq";
in
{
config = mkIf cfg.enable {
# Battle.net is installed manually through Lutris, which creates the game
# config and wine prefix outside of Home Manager's control. The Lutris
# installer script writes HardwareAcceleration "false" (software rendering,
# which breaks Battle.net's CEF UI repainting under XWayland), so patch it
# and the game env after every rebuild. Re-run the rebuild after installing
# Battle.net for these tweaks to land.
home.activation.battlenetClientTweaks = hm.dag.entryAfter [ "writeBoundary" ] ''
shopt -s nullglob
for game in "$HOME"/.local/share/lutris/games/battlenet*.yml; do
prefix=$(${yq} -r '.game.prefix // ""' "$game" 2>/dev/null) || continue
for configFile in "$prefix"/drive_c/users/*/AppData/Roaming/Battle.net/Battle.net.config; do
[ -e "$configFile" ] || continue
if [ "$(${jq} -r '.Client.HardwareAcceleration // ""' "$configFile" 2>/dev/null)" != "true" ]; then
${jq} '.Client.HardwareAcceleration = "true"' "$configFile" > "$configFile.tmp" && mv "$configFile.tmp" "$configFile"
fi
done
# GE-Proton's Wayland driver breaks Battle.net's CEF window sizing and
# painting, and Xalia misrenders the client, so pin both off.
if [ "$(${yq} -r '.system.env.PROTON_USE_XALIA // ""' "$game" 2>/dev/null)" != "0" ]; then
${yq} --in-place --yaml-output '.system.env.PROTON_USE_XALIA = "0"' "$game"
fi
if [ "$(${yq} -r '.system.env.WINE_SIMULATE_WRITECOPY // ""' "$game" 2>/dev/null)" != "1" ]; then
${yq} --in-place --yaml-output '.system.env.WINE_SIMULATE_WRITECOPY = "1"' "$game"
fi
if [ -n "$(${yq} -r '.system.env.PROTON_ENABLE_WAYLAND // ""' "$game" 2>/dev/null)" ]; then
${yq} --in-place --yaml-output 'del(.system.env.PROTON_ENABLE_WAYLAND)' "$game"
fi
done
shopt -u nullglob
'';
};
}

View File

@ -3,6 +3,7 @@
}:
{
imports = [
./battlenet.nix
./direnv.nix
./discord.nix
./dictation.nix

View File

@ -0,0 +1,23 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.battlenet;
in
{
config = mkIf cfg.enable {
# Battle.net games rely on 32-bit graphics libraries; Steam would
# normally force this on, but enable it independently as a fallback.
hardware.graphics.enable32Bit = mkDefault true;
environment.systemPackages = with pkgs; [
lutris
wineWow64Packages.staging
winetricks
];
};
}

View File

@ -3,6 +3,7 @@
}:
{
imports = [
./battlenet.nix
./boot.nix
./dev.nix
./fonts.nix

View File

@ -19,6 +19,27 @@ in
jack.enable = true;
};
# Re-enable PulseAudio-style auto profile switching (ACP), since
# WirePlumber 0.5 disables it and never reacts to HDMI hotplug events,
# leaving audio stuck on analog when a dock/TV is connected.
services.pipewire.wireplumber.extraConfig."99-acp-auto-profile" = {
"monitor.alsa.rules" = [
{
matches = [
{
"device.name" = "~alsa_card.*";
}
];
actions = {
update-props = {
"api.acp.auto-profile" = true;
"api.acp.auto-port" = true;
};
};
}
];
};
# Allows Pipewire to use the realtime scheduler for increased performance
security.rtkit.enable = true;
};

View File

@ -0,0 +1,10 @@
{
lib,
...
}:
with lib;
{
options.modules.battlenet = {
enable = mkEnableOption "Battle.net via Lutris/Wine";
};
}

View File

@ -3,6 +3,7 @@
}:
{
imports = [
./battlenet.nix
./discord.nix
./dictation.nix
./dev.nix

View File

@ -29,6 +29,4 @@
modules.screenshot.enable = true;
modules.tailscale.enable = true;
modules.steam.enable = true;
}

View File

@ -0,0 +1,12 @@
{
...
}:
{
imports = [
../desktop
];
modules.steam.enable = true;
modules.battlenet.enable = true;
}