Personal Nix setup
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move palworld helpers and package to local overlay

+261 -260
+17 -3
flake.nix
··· 73 73 }; 74 74 }; 75 75 76 - outputs = inputs: let 76 + outputs = inputs @ { self, ... }: let 77 77 inherit (inputs.nixpkgs) lib; 78 78 inherit (import ./lib/system.nix inputs) mkSystem; 79 79 eachSystem = lib.genAttrs ["aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux"]; ··· 82 82 inputs.nvim-plugins.overlays.default 83 83 inputs.android-sdk.overlays.default 84 84 inputs.language-servers.overlays.default 85 + self.overlays.default 85 86 ]; 86 87 in { 87 88 darwinConfigurations."sprite" = mkSystem { ··· 114 115 hostname = "ramune"; 115 116 }; 116 117 117 - packages = eachSystem (system: { 118 + overlays = { 119 + default = import ./lib/pkgs; 120 + }; 121 + 122 + packages = eachSystem (system: let 123 + pkgs = import inputs.nixpkgs { 124 + inherit system; 125 + overlays = [ self.overlays.default ]; 126 + }; 127 + in { 118 128 inherit (inputs.agenix.packages.${system}) agenix; 119 129 inherit (inputs.darwin.packages.${system}) darwin-rebuild; 120 - } // (import ./lib/pkgs inputs.nixpkgs.legacyPackages.${system})); 130 + } // { 131 + inherit (pkgs) 132 + steamworks-sdk-redist 133 + systemd-transparent-udp-forwarderd; 134 + }); 121 135 122 136 apps = eachSystem (system: import ./lib/apps { 123 137 inherit lib;
+7 -2
lib/pkgs/default.nix
··· 1 - pkgs: { 2 - yeetmouse = import ./yeetmouse.nix pkgs; 1 + self: super: { 2 + fetchSteam = import ./fetch-steam.nix self super; 3 + mkSteamPackage = import ./mk-steam-package.nix self super; 4 + mkSteamWrapper = import ./mk-steam-wrapper.nix self super; 5 + systemd-transparent-udp-forwarderd = import ./systemd-transparent-udp-forwarderd.nix self super; 6 + steamworks-sdk-redist = import ./steamworks-sdk-redist.nix self super; 7 + palworld-server = import ./palworld-server.nix self super; 3 8 }
+56
lib/pkgs/mk-steam-package.nix
··· 1 + self: pkgs @ { 2 + lib, 3 + stdenv, 4 + autoPatchelfHook, 5 + ... 6 + }: 7 + 8 + with lib; 9 + let 10 + inherit (stdenv.hostPlatform) isAarch64; 11 + in 12 + { 13 + name, 14 + hash ? "", 15 + version, 16 + appId, 17 + depotId, 18 + manifestId, 19 + ... 20 + } @ args: let 21 + derivationArgs = builtins.removeAttrs args [ "name" "appId" "depotId" "manifestId" "hash" ]; 22 + in 23 + stdenv.mkDerivation (rec { 24 + pname = name; 25 + src = self.fetchSteam { 26 + inherit name appId depotId manifestId hash; 27 + }; 28 + 29 + dontBuild = true; 30 + dontConfigure = true; 31 + dontFixup = isAarch64; 32 + 33 + nativeBuildInputs = optionals (!isAarch64) [ autoPatchelfHook ]; 34 + appendRunpaths = with self; makeLibraryPath [ 35 + steamworks-sdk-redist 36 + glibc 37 + libxcrypt 38 + libGL 39 + libdrm 40 + mesa # for libgbm 41 + udev 42 + libudev0-shim 43 + libva 44 + vulkan-loader 45 + ]; 46 + 47 + installPhase = '' 48 + runHook preInstall 49 + 50 + mkdir -p $out 51 + mv ./* $out 52 + chmod 755 -R $out 53 + 54 + runHook postInstall 55 + ''; 56 + } // derivationArgs)
+74
lib/pkgs/mk-steam-wrapper.nix
··· 1 + self: pkgs @ { 2 + lib, 3 + box64, 4 + makeWrapper, 5 + pkgsCross, 6 + stdenv, 7 + ... 8 + }: 9 + 10 + with lib; 11 + let 12 + useBox64 = stdenv.hostPlatform.isAarch64; 13 + 14 + defaultLibs = with self; [ 15 + steamworks-sdk-redist 16 + glibc 17 + libxcrypt 18 + libGL 19 + libdrm 20 + mesa # for libgbm 21 + udev 22 + libudev0-shim 23 + libva 24 + vulkan-loader 25 + ]; 26 + 27 + defaultNativeLibs = optionals useBox64 [ pkgsCross.gnu64.libgcc ]; 28 + 29 + mkSteamWrapper = makeOverridable ( 30 + { 31 + logLevel ? 0, 32 + env ? {}, 33 + libs ? defaultLibs, 34 + nativeLibs ? defaultNativeLibs, 35 + extraWrapperArgs ? [], 36 + }: let 37 + runpaths = libs ++ optionals useBox64 nativeLibs; 38 + combinedEnv = optionalAttrs useBox64 { 39 + BOX64_LOG = logLevel; 40 + BOX64_DYNAREC_STRONGMEM = 1; 41 + BOX64_DYNAREC_BIGBLOCK = 1; 42 + BOX64_DYNAREC_SAFEFLAGS = 1; 43 + BOX64_DYNAREC_FASTROUND = 1; 44 + BOX64_DYNAREC_FASTNAN = 1; 45 + BOX64_DYNAREC_X87DOUBLE = 0; 46 + } // env; 47 + in bin: 48 + stdenv.mkDerivation rec { 49 + name = "box64-wrapper"; 50 + meta.mainProgram = name; 51 + 52 + dontUnpack = true; 53 + dontConfigure = true; 54 + dontBuild = true; 55 + 56 + nativeBuildInputs = [ makeWrapper ]; 57 + buildInputs = runpaths; 58 + 59 + installPhase = let 60 + outBin = if useBox64 then "${box64}/bin/box64" else bin; 61 + targetBinFlag = if useBox64 then "--add-flags ${escapeShellArg bin}" else ""; 62 + in '' 63 + runHook preInstall 64 + makeWrapper "${outBin}" "$out/bin/${name}" \ 65 + ${concatStrings (mapAttrsToList (name: value: "--set ${name} '${toString value}' ") combinedEnv)} \ 66 + --prefix LD_LIBRARY_PATH : ${makeLibraryPath runpaths} \ 67 + ${targetBinFlag} \ 68 + ${lib.strings.concatStringsSep " " extraWrapperArgs} 69 + runHook postInstall 70 + ''; 71 + } 72 + ); 73 + in 74 + mkSteamWrapper { }
+20
lib/pkgs/palworld-server.nix
··· 1 + self: { 2 + lib, 3 + ... 4 + }: 5 + 6 + with lib; 7 + self.mkSteamPackage { 8 + name = "palworld-server"; 9 + version = "17082920"; 10 + appId = "2394010"; 11 + depotId = "2394012"; 12 + manifestId = "2423583208459052375"; 13 + hash = "sha256-gAFEDf/rKPQ5zTH8EJ93e4KKHUGi8uiYlPS7G2lWGWk="; 14 + meta = { 15 + description = "Palworld Dedicated Server"; 16 + homepage = "https://steamdb.info/app/2394010/"; 17 + changelog = "https://store.steampowered.com/news/app/1623730?updates=true"; 18 + sourceProvenance = with sourceTypes; [ sourceTypes.binaryNativeCode ]; 19 + }; 20 + }
+42
lib/pkgs/steamworks-sdk-redist.nix
··· 1 + self: pkgs @ { 2 + lib, 3 + stdenv, 4 + ... 5 + }: 6 + 7 + with lib; 8 + stdenv.mkDerivation { 9 + pname = "steamworks-sdk-redist"; 10 + version = "unstable-2024-05-30"; 11 + 12 + # Steamworks SDK Redist with steamclient.so. 13 + # https://steamdb.info/app/1007/depots 14 + src = self.fetchSteam { 15 + appId = "1007"; 16 + depotId = "1006"; 17 + manifestId = "7138471031118904166"; 18 + hash = "sha256-OtPI1kAx6+9G09IEr2kYchyvxlPl3rzx/ai/xEVG4oM="; 19 + }; 20 + 21 + dontConfigure = true; 22 + dontBuild = true; 23 + 24 + installPhase = '' 25 + runHook preInstall 26 + 27 + mkdir -p $out/lib 28 + cp linux64/steamclient.so $out/lib 29 + chmod +x $out/lib/steamclient.so 30 + 31 + runHook postInstall 32 + ''; 33 + 34 + meta = { 35 + description = "Steamworks SDK Redist"; 36 + sourceProvenance = [ sourceTypes.binaryNativeCode ]; 37 + license = licenses.unfree; 38 + badPlatforms = [ 39 + { hasSharedLibraries = false; } 40 + ]; 41 + }; 42 + }
+27
lib/pkgs/systemd-transparent-udp-forwarderd.nix
··· 1 + pkgs @ { 2 + stdenv, 3 + cmake, 4 + pkg-config, 5 + fetchFromGitHub, 6 + systemdLibs, 7 + ... 8 + }: 9 + 10 + stdenv.mkDerivation { 11 + pname = "systemd-transparent-udp-forwarderd"; 12 + version = "0.0.1-add-activity-timeout-shutdown"; 13 + nativeBuildInputs = [ cmake pkg-config ]; 14 + buildInputs = [ systemdLibs ]; 15 + src = fetchFromGitHub { 16 + owner = "cecton"; 17 + repo = "systemd-transparent-udp-forwarderd"; 18 + rev = "69072ef1271f013cefa91c239455d197f68d3f8e"; 19 + sha256 = "sha256-c4pui1aHw35Jw1pjCBgLQTHrjt5nYI2IUD4FqkyEd/M="; 20 + }; 21 + 22 + installPhase = '' 23 + runHook preInstall 24 + install -Dm755 systemd-transparent-udp-forwarderd "$out/bin/$pname" 25 + runHook postInstall 26 + ''; 27 + }
-65
lib/pkgs/yeetmouse.nix
··· 1 - pkgs @ { 2 - lib, 3 - bash, 4 - stdenv, 5 - coreutils, 6 - fetchFromGitHub, 7 - kernel ? pkgs.linuxPackages_latest.kernel, 8 - ... 9 - }: 10 - 11 - stdenv.mkDerivation rec { 12 - pname = "yeetmouse"; 13 - version = "ed39ee0457d330c751b689fe6e410acae8c40d4f"; 14 - 15 - src = fetchFromGitHub { 16 - owner = "andyfilter"; 17 - repo = "yeetmouse"; 18 - rev = version; 19 - sha256 = "sha256-8cr4WYX09ej81tRJOfEytnPGj51voDQA9tEH91ukC+s="; 20 - }; 21 - 22 - setSourceRoot = "export sourceRoot=$(pwd)/source"; 23 - nativeBuildInputs = kernel.moduleBuildDependencies ++ [ pkgs.makeWrapper ]; 24 - buildInputs = [ pkgs.glfw3 ]; 25 - 26 - makeFlags = kernel.makeFlags ++ [ 27 - "-C" 28 - "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" 29 - "M=$(sourceRoot)/driver" 30 - ]; 31 - 32 - postUnpack = '' 33 - cp -r $src/gui $sourceRoot/gui 34 - chmod 755 -R $sourceRoot/gui 35 - substituteInPlace $sourceRoot/driver/util.c \ 36 - --replace "#define NUM_USAGES 32" "#define NUM_USAGES 90" 37 - ''; 38 - 39 - preBuild = '' 40 - cp $sourceRoot/driver/config.sample.h $sourceRoot/driver/config.h 41 - ''; 42 - 43 - LD_LIBRARY_PATH = "/run/opengl-driver/lib:${lib.makeLibraryPath buildInputs}"; 44 - 45 - postBuild = '' 46 - make "-j$NIX_BUILD_CORES" -C $sourceRoot/gui "M=$sourceRoot/gui" "LIBS=-lglfw -lGL" 47 - ''; 48 - 49 - postInstall = '' 50 - install -Dm755 $sourceRoot/gui/YeetMouseGui $out/bin/yeetmouse 51 - install -D $src/install_files/udev/99-leetmouse.rules $out/lib/udev/rules.d/98-leetmouse.rules 52 - install -Dm755 $src/install_files/udev/leetmouse_bind $out/lib/udev/rules.d/leetmouse_bind 53 - substituteInPlace $out/lib/udev/rules.d/98-leetmouse.rules \ 54 - --replace "PATH='/sbin:/bin:/usr/sbin:/usr/bin'" "" 55 - patchShebangs $out/lib/udev/rules.d/leetmouse_bind 56 - wrapProgram $out/lib/udev/rules.d/leetmouse_bind \ 57 - --prefix PATH : ${lib.makeBinPath [ bash coreutils ]} 58 - substituteInPlace $out/lib/udev/rules.d/98-leetmouse.rules \ 59 - --replace "leetmouse_bind" "$out/lib/udev/rules.d/leetmouse_bind" 60 - ''; 61 - 62 - buildFlags = [ "modules" ]; 63 - installFlags = [ "INSTALL_MOD_PATH=${placeholder "out"}" ]; 64 - installTargets = [ "modules_install" ]; 65 - }
+12 -5
modules/games/lib/fetchSteam.nix lib/pkgs/fetch-steam.nix
··· 1 - { lib, pkgs, ... }: 1 + self: pkgs @ { 2 + lib, 3 + runCommand, 4 + depotdownloader, 5 + cacert, 6 + ... 7 + }: 2 8 3 - with lib; makeOverridable ( 9 + with lib; 10 + makeOverridable ( 4 11 { 5 12 name ? "steamapp-${appId}-${depotId}-${manifestId}", 6 13 appId, ··· 31 38 ++ optionals debug [ "-debug" ]; 32 39 33 40 drvArgs = { 34 - depsBuildBuild = [ pkgs.depotdownloader ]; 41 + depsBuildBuild = [ depotdownloader ]; 35 42 36 43 strictDeps = true; 37 44 ··· 39 46 outputHashMode = "recursive"; 40 47 outputHash = if hash != "" then hash else fakeHash; 41 48 42 - env.SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; 49 + env.SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; 43 50 44 51 pos = builtins.unsafeGetAttrPos "manifestId" args; 45 52 46 53 inherit passthru; 47 54 } // optionalAttrs (args ? meta) { inherit meta; }; 48 55 in 49 - pkgs.runCommand name drvArgs '' 56 + runCommand name drvArgs '' 50 57 HOME=$PWD DepotDownloader -dir "$out" ${escapeShellArgs downloadArgs} 51 58 rm -r "$out"/.DepotDownloader 52 59 ''
-54
modules/games/lib/mkSteamPackage.nix
··· 1 - { lib, helpers, pkgs, ... } @ inputs: 2 - 3 - with lib; 4 - let 5 - fetchSteam = (import ./fetchSteam.nix) inputs; 6 - inherit ((import ./steamworks.nix) inputs) steamworks-sdk-redist; 7 - in 8 - { 9 - name, 10 - hash ? "", 11 - version, 12 - appId, 13 - depotId, 14 - manifestId, 15 - ... 16 - } @ args: let 17 - mkDerivationArgs = builtins.removeAttrs args [ "name" "appId" "depotId" "manifestId" "hash" ]; 18 - in pkgs.stdenv.mkDerivation (rec { 19 - pname = name; 20 - src = fetchSteam { 21 - inherit name appId depotId manifestId hash; 22 - }; 23 - 24 - dontBuild = true; 25 - dontConfigure = true; 26 - dontFixup = helpers.system == "aarch64-linux"; 27 - 28 - appendRunpaths = with pkgs; makeLibraryPath [ 29 - steamworks-sdk-redist 30 - glibc 31 - libxcrypt 32 - libGL 33 - libdrm 34 - mesa # for libgbm 35 - udev 36 - libudev0-shim 37 - libva 38 - vulkan-loader 39 - ]; 40 - 41 - nativeBuildInputs = optionals (helpers.system == "aarch64-linux") [ 42 - pkgs.autoPatchelfHook 43 - ]; 44 - 45 - installPhase = '' 46 - runHook preInstall 47 - 48 - mkdir -p $out 49 - mv ./* $out 50 - chmod 755 -R $out 51 - 52 - runHook postInstall 53 - ''; 54 - } // mkDerivationArgs)
-65
modules/games/lib/mkWrappedBox64.nix
··· 1 - { lib, helpers, pkgs, ... } @ inputs: 2 - 3 - with lib; 4 - let 5 - inherit ((import ./steamworks.nix) inputs) steamworks-sdk-redist; 6 - 7 - defaultLibs = with pkgs; [ 8 - steamworks-sdk-redist 9 - glibc 10 - libxcrypt 11 - libGL 12 - libdrm 13 - mesa # for libgbm 14 - udev 15 - libudev0-shim 16 - libva 17 - vulkan-loader 18 - ]; 19 - 20 - defaultNativeLibs = [ pkgs.pkgsCross.gnu64.libgcc ]; 21 - 22 - makeWrappedBox64 = { 23 - logLevel ? 0, 24 - env ? {}, 25 - libs ? defaultLibs, 26 - nativeLibs ? defaultNativeLibs, 27 - extraWrapperArgs ? [], 28 - }: let 29 - box64Bin = "${pkgs.box64}/bin/box64"; 30 - runpaths = libs ++ nativeLibs; 31 - combinedEnv = { 32 - BOX64_DYNAREC_STRONGMEM = 1; 33 - BOX64_DYNAREC_BIGBLOCK = 1; 34 - BOX64_DYNAREC_SAFEFLAGS = 1; 35 - BOX64_DYNAREC_FASTROUND = 1; 36 - BOX64_DYNAREC_FASTNAN = 1; 37 - BOX64_DYNAREC_X87DOUBLE = 0; 38 - } // env; 39 - in bin: 40 - pkgs.stdenv.mkDerivation rec { 41 - name = "box64-wrapped"; 42 - 43 - dontUnpack = true; 44 - dontConfigure = true; 45 - dontBuild = true; 46 - 47 - nativeBuildInputs = [ pkgs.makeWrapper ]; 48 - buildInputs = runpaths ++ libs; 49 - 50 - installPhase = '' 51 - runHook preInstall 52 - makeWrapper "${box64Bin}" "$out/bin/box64" \ 53 - ${concatStrings (mapAttrsToList (name: value: "--set ${name} '${toString value}' ") env)} \ 54 - --set BOX64_LOG "${toString logLevel}" \ 55 - --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} \ 56 - ${lib.strings.concatStringsSep " " extraWrapperArgs} \ 57 - --add-flags "$bin" 58 - runHook postInstall 59 - ''; 60 - }; 61 - 62 - box64 = makeWrappedBox64 { }; 63 - identity = bin: bin; 64 - in 65 - if helpers.system == "aarch64-linux" then box64 else identity
modules/games/lib/serverScripts.nix modules/games/lib/scripts.nix
-42
modules/games/lib/steamworks.nix
··· 1 - { lib, pkgs, ... } @ inputs: 2 - 3 - with lib; 4 - let 5 - fetchSteam = (import ./fetchSteam.nix) inputs; 6 - in { 7 - steamworks-sdk-redist = pkgs.stdenv.mkDerivation { 8 - pname = "steamworks-sdk-redist"; 9 - version = "unstable-2024-05-30"; 10 - 11 - # Steamworks SDK Redist with steamclient.so. 12 - # https://steamdb.info/app/1007/depots 13 - src = fetchSteam { 14 - appId = "1007"; 15 - depotId = "1006"; 16 - manifestId = "7138471031118904166"; 17 - hash = "sha256-OtPI1kAx6+9G09IEr2kYchyvxlPl3rzx/ai/xEVG4oM="; 18 - }; 19 - 20 - dontConfigure = true; 21 - dontBuild = true; 22 - 23 - installPhase = '' 24 - runHook preInstall 25 - 26 - mkdir -p $out/lib 27 - cp linux64/steamclient.so $out/lib 28 - chmod +x $out/lib/steamclient.so 29 - 30 - runHook postInstall 31 - ''; 32 - 33 - meta = { 34 - description = "Steamworks SDK Redist"; 35 - sourceProvenance = [ sourceTypes.binaryNativeCode ]; 36 - license = licenses.unfree; 37 - badPlatforms = [ 38 - { hasSharedLibraries = false; } 39 - ]; 40 - }; 41 - }; 42 - }
+6 -24
modules/games/palworld.nix
··· 7 7 cfg = config.modules.games.palworld; 8 8 9 9 name = "palworld-server"; 10 - serverScripts = (import ./lib/serverScripts.nix) args; 11 - mkWrappedBox64 = (import ./lib/mkWrappedBox64.nix) args; 12 - mkSteamPackage = (import ./lib/mkSteamPackage.nix) args; 13 - inherit ((import ./lib/steamworks.nix) args) steamworks-sdk-redist; 10 + scripts = (import ./lib/scripts.nix) args; 14 11 15 12 generateSettings = name: value: let 16 13 optionSettings = ··· 34 31 OptionSettings=(${concatStringsSep "," optionSettings}) 35 32 ''; 36 33 37 - palworld-server = mkSteamPackage { 38 - name = "palworld-server"; 39 - version = "17082920"; 40 - appId = "2394010"; 41 - depotId = "2394012"; 42 - manifestId = "2423583208459052375"; 43 - hash = "sha256-gAFEDf/rKPQ5zTH8EJ93e4KKHUGi8uiYlPS7G2lWGWk="; 44 - meta = { 45 - description = "Palworld Dedicated Server"; 46 - homepage = "https://steamdb.info/app/2394010/"; 47 - changelog = "https://store.steampowered.com/news/app/1623730?updates=true"; 48 - sourceProvenance = with sourceTypes; [ sourceTypes.binaryNativeCode ]; 49 - }; 50 - }; 51 - 52 34 baseSettings = { 53 35 ServerName = "Unnamed Server"; 54 36 AllowConnectPlatform = "Steam"; ··· 157 139 158 140 package = mkOption { 159 141 type = types.package; 160 - default = palworld-server; 142 + default = pkgs.palworld-server; 161 143 }; 162 144 163 145 public = mkOption { ··· 219 201 files = let 220 202 settings = baseSettings // cfg.settings; 221 203 in { 222 - "Pal/Binaries/Linux/steamclient.so" = "${steamworks-sdk-redist}/lib/steamclient.so"; 204 + "Pal/Binaries/Linux/steamclient.so" = "${pkgs.steamworks-sdk-redist}/lib/steamclient.so"; 223 205 "Pal/Saved/Config/LinuxServer/PalWorldSettings.ini" = generateSettings "PalWorldSettings.ini" settings; 224 206 "Pal/Saved/Config/LinuxServer/Engine.ini" = builtins.toFile "Engine.ini" engineSettings; 225 207 }; ··· 236 218 ] 237 219 ++ optionals (cfg.ip != null) [ "-publicip=${cfg.ip}" ] 238 220 ++ optionals cfg.public [ "-publiclobby" ]; 239 - bin = getBin (mkWrappedBox64 "${cfg.datadir}/Pal/Binaries/Linux/PalServer-Linux-Shipping"); 221 + bin = getExe (pkgs.mkSteamWrapper "${cfg.datadir}/Pal/Binaries/Linux/PalServer-Linux-Shipping"); 240 222 in "${bin} ${concatStringsSep " " args}"; 241 223 in { 242 224 wantedBy = mkIf cfg.autostart [ "multi-user.target" ]; ··· 245 227 246 228 inherit script; 247 229 preStart = '' 248 - ${serverScripts.mkDirs name dirs} 249 - ${serverScripts.mkFiles name files} 230 + ${scripts.mkDirs name dirs} 231 + ${scripts.mkFiles name files} 250 232 ''; 251 233 252 234 serviceConfig = {