Personal Nix setup

Add variations for non aarch64 runtimes

Changed files
+72 -45
modules
+2 -2
modules/games/default.nix
···
-
{ lib, config, ... }:
with lib; let
cfg = config.modules.games;
···
description = "Group to use when running game servers";
};
};
-
config = mkIf cfg.enable {
users.users."${cfg.user}" = {
home = "${cfg.datadir}";
···
+
{ lib, helpers, config, ... }:
with lib; let
cfg = config.modules.games;
···
description = "Group to use when running game servers";
};
};
+
} // helpers.linuxAttrs {
config = mkIf cfg.enable {
users.users."${cfg.user}" = {
home = "${cfg.datadir}";
+21 -2
modules/games/lib/mkSteamPackage.nix
···
-
{ lib, pkgs, ... } @ inputs:
with lib;
let
···
src = fetchSteam {
inherit name appId depotId manifestId hash;
};
dontBuild = true;
dontConfigure = true;
-
dontFixup = true;
installPhase = ''
runHook preInstall
···
+
{ lib, helpers, pkgs, ... } @ inputs:
with lib;
let
···
src = fetchSteam {
inherit name appId depotId manifestId hash;
};
+
dontBuild = true;
dontConfigure = true;
+
dontFixup = helpers.system == "aarch64-linux";
+
+
appendRunpaths = with pkgs; makeLibraryPath [
+
steamworks-sdk-redist
+
glibc
+
libxcrypt
+
libGL
+
libdrm
+
mesa # for libgbm
+
udev
+
libudev0-shim
+
libva
+
vulkan-loader
+
];
+
+
nativeBuildInputs = optionals (helpers.system == "aarch64-linux") [
+
pkgs.autoPatchelfHook
+
];
+
installPhase = ''
runHook preInstall
+47 -34
modules/games/lib/mkWrappedBox64.nix
···
-
{ lib, pkgs, ... } @ inputs:
with lib;
let
inherit ((import ./steamworks.nix) inputs) steamworks-sdk-redist;
-
in {
-
logLevel ? 0,
-
env ? {},
-
libs ? [],
-
extraWrapperArgs ? [],
-
}: let
-
box64Bin = "${pkgs.box64}/bin/box64";
-
runpaths = with pkgs; [
steamworks-sdk-redist
glibc
libxcrypt
···
libva
vulkan-loader
];
-
combinedEnv = {
-
BOX64_DYNAREC_STRONGMEM = 1;
-
BOX64_DYNAREC_BIGBLOCK = 1;
-
BOX64_DYNAREC_SAFEFLAGS = 1;
-
BOX64_DYNAREC_FASTROUND = 1;
-
BOX64_DYNAREC_FASTNAN = 1;
-
BOX64_DYNAREC_X87DOUBLE = 0;
-
} // env;
-
in pkgs.stdenv.mkDerivation rec {
-
name = "box64-wrapped";
-
dontUnpack = true;
-
dontConfigure = true;
-
dontBuild = true;
-
nativeBuildInputs = [ pkgs.makeWrapper ];
-
buildInputs = runpaths ++ libs;
-
installPhase = ''
-
runHook preInstall
-
makeWrapper "${box64Bin}" "$out/bin/box64" \
-
${concatStrings (mapAttrsToList (name: value: "--set ${name} '${toString value}' ") env)} \
-
--set BOX64_LOG "${toString logLevel}" \
-
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} \
-
${lib.strings.concatStringsSep " " extraWrapperArgs}
-
runHook postInstall
-
'';
-
}
···
+
{ lib, helpers, pkgs, ... } @ inputs:
with lib;
let
inherit ((import ./steamworks.nix) inputs) steamworks-sdk-redist;
+
+
defaultLibs = with pkgs; [
steamworks-sdk-redist
glibc
libxcrypt
···
libva
vulkan-loader
];
+
+
defaultNativeLibs = [ pkgs.pkgsCross.gnu64.libgcc ];
+
+
makeWrappedBox64 = {
+
logLevel ? 0,
+
env ? {},
+
libs ? defaultLibs,
+
nativeLibs ? defaultNativeLibs,
+
extraWrapperArgs ? [],
+
}: let
+
box64Bin = "${pkgs.box64}/bin/box64";
+
runpaths = libs ++ nativeLibs;
+
combinedEnv = {
+
BOX64_DYNAREC_STRONGMEM = 1;
+
BOX64_DYNAREC_BIGBLOCK = 1;
+
BOX64_DYNAREC_SAFEFLAGS = 1;
+
BOX64_DYNAREC_FASTROUND = 1;
+
BOX64_DYNAREC_FASTNAN = 1;
+
BOX64_DYNAREC_X87DOUBLE = 0;
+
} // env;
+
in bin:
+
pkgs.stdenv.mkDerivation rec {
+
name = "box64-wrapped";
+
+
dontUnpack = true;
+
dontConfigure = true;
+
dontBuild = true;
+
nativeBuildInputs = [ pkgs.makeWrapper ];
+
buildInputs = runpaths ++ libs;
+
installPhase = ''
+
runHook preInstall
+
makeWrapper "${box64Bin}" "$out/bin/box64" \
+
${concatStrings (mapAttrsToList (name: value: "--set ${name} '${toString value}' ") env)} \
+
--set BOX64_LOG "${toString logLevel}" \
+
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} \
+
${lib.strings.concatStringsSep " " extraWrapperArgs} \
+
--add-flags "$bin"
+
runHook postInstall
+
'';
+
};
+
box64 = makeWrappedBox64 { };
+
identity = bin: bin;
+
in
+
if helpers.system == "aarch64-linux" then box64 else identity
+2 -7
modules/games/palworld.nix
···
OptionSettings=(${concatStringsSep "," optionSettings})
'';
-
wrappedBox64 = mkWrappedBox64 {
-
libs = [ pkgs.pkgsCross.gnu64.libgcc ];
-
};
-
palworld-server = mkSteamPackage {
name = "palworld-server";
version = "17082920";
···
]
++ optionals (cfg.ip != null) [ "-publicip=${cfg.ip}" ]
++ optionals cfg.public [ "-publiclobby" ];
-
executable = "${cfg.datadir}/Pal/Binaries/Linux/PalServer-Linux-Shipping";
-
command = "${wrappedBox64}/bin/box64 ${executable}";
-
in "${command} ${concatStringsSep " " args}";
in {
wantedBy = mkIf cfg.autostart [ "multi-user.target" ];
after = [ "network.target" ];
···
OptionSettings=(${concatStringsSep "," optionSettings})
'';
palworld-server = mkSteamPackage {
name = "palworld-server";
version = "17082920";
···
]
++ optionals (cfg.ip != null) [ "-publicip=${cfg.ip}" ]
++ optionals cfg.public [ "-publiclobby" ];
+
bin = getBin (mkWrappedBox64 "${cfg.datadir}/Pal/Binaries/Linux/PalServer-Linux-Shipping");
+
in "${bin} ${concatStringsSep " " args}";
in {
wantedBy = mkIf cfg.autostart [ "multi-user.target" ];
after = [ "network.target" ];