mirror of
https://codeberg.org/spire/nix.git
synced 2026-06-03 18:04:10 +02:00
proper per-system sdks
This commit is contained in:
parent
f3a8debf10
commit
8919632524
6 changed files with 69 additions and 20 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
|
@ -23,7 +23,7 @@ jobs:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: cachix/install-nix-action@v20
|
- uses: cachix/install-nix-action@v20
|
||||||
- id: set-matrix
|
- id: set-matrix
|
||||||
run: echo "matrix={\"sdk\":$(nix eval --json ".#sdks.x86_64-linux")}" | tee $GITHUB_OUTPUT
|
run: echo "matrix=$(nix eval --json ".#matrix")" | tee $GITHUB_OUTPUT
|
||||||
|
|
||||||
sourcemod:
|
sourcemod:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
@ -39,7 +39,7 @@ jobs:
|
||||||
name: ci
|
name: ci
|
||||||
instance: https://cache.icewind.me
|
instance: https://cache.icewind.me
|
||||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||||
- run: nix build .#sourcemods.${{ matrix.sdk }}
|
- run: nix build .#packages.${{ matrix.system }}.sourcemods.${{ matrix.sdk }}
|
||||||
|
|
||||||
sourcepawn:
|
sourcepawn:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
||||||
12
README.md
12
README.md
|
|
@ -12,7 +12,7 @@ The following is currently packaged:
|
||||||
- `sourcemod`
|
- `sourcemod`
|
||||||
|
|
||||||
|
|
||||||
### Sourcemod SDKs
|
## Sourcemod SDKs
|
||||||
|
|
||||||
For the `sourcemod` package, you need to enable one or more SDKs at build time.
|
For the `sourcemod` package, you need to enable one or more SDKs at build time.
|
||||||
The SDKs are packaged under the `hl2sdk` package and can be enabled like in the following example.
|
The SDKs are packaged under the `hl2sdk` package and can be enabled like in the following example.
|
||||||
|
|
@ -21,6 +21,16 @@ The SDKs are packaged under the `hl2sdk` package and can be enabled like in the
|
||||||
pkgs.sourcemod.override {sdks = {inherit (pkgs.hl2sdk) tf2;};};
|
pkgs.sourcemod.override {sdks = {inherit (pkgs.hl2sdk) tf2;};};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Supported SDKs
|
||||||
|
|
||||||
|
#### i686-linux
|
||||||
|
|
||||||
|
`episode1`, `css`, `hl2dm`, `dods`, `sdk2013`, `tf2`, `l4d`, `l4d2`, `nucleardawn`, `csgo`, `doi` and `bms`
|
||||||
|
|
||||||
|
#### x86_64-linux
|
||||||
|
|
||||||
|
`dota`
|
||||||
|
|
||||||
## Building sourcepawn script
|
## Building sourcepawn script
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
|
|
|
||||||
23
flake.nix
23
flake.nix
|
|
@ -8,17 +8,22 @@
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
utils,
|
utils,
|
||||||
}:
|
}: let
|
||||||
utils.lib.eachDefaultSystem (system: let
|
systems = with utils.lib.system; [x86_64-linux i686-linux];
|
||||||
inherit (builtins) mapAttrs attrNames;
|
in utils.lib.eachSystem systems (system: let
|
||||||
|
inherit (builtins) mapAttrs attrNames elem;
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
inherit (lib.attrsets) filterAttrs;
|
||||||
overlays = [(import ./pkgs)];
|
overlays = [(import ./pkgs)];
|
||||||
pkgs = (import nixpkgs) {
|
pkgs = (import nixpkgs) {
|
||||||
inherit system overlays;
|
inherit system overlays;
|
||||||
|
# crossSystem = { config = "i686-unknown-linux-gnu"; };
|
||||||
};
|
};
|
||||||
testScript = pkgs.fetchurl {
|
testScript = pkgs.fetchurl {
|
||||||
url = "https://raw.githubusercontent.com/spiretf/nocheats/master/plugin/nocheats.sp";
|
url = "https://raw.githubusercontent.com/spiretf/nocheats/master/plugin/nocheats.sp";
|
||||||
sha256 = "sha256-Z3RJhuc9c8YQTo9gnLTBrqL4JpADZgDttrJVyE/MWdM=";
|
sha256 = "sha256-Z3RJhuc9c8YQTo9gnLTBrqL4JpADZgDttrJVyE/MWdM=";
|
||||||
};
|
};
|
||||||
|
platformSdks = filterAttrs (name: sdk: elem system sdk.meta.platforms) pkgs.hl2sdk;
|
||||||
in rec {
|
in rec {
|
||||||
packages = rec {
|
packages = rec {
|
||||||
inherit (pkgs) ambuild sourcemod sourcepawn sourcemod-includes buildSourcePawnScript hl2sdk;
|
inherit (pkgs) ambuild sourcemod sourcepawn sourcemod-includes buildSourcePawnScript hl2sdk;
|
||||||
|
|
@ -27,11 +32,17 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [];
|
nativeBuildInputs = with pkgs; [clangStdenv];
|
||||||
};
|
};
|
||||||
|
|
||||||
sdks = attrNames packages.hl2sdk;
|
sdks = attrNames platformSdks;
|
||||||
|
|
||||||
overlays.default = import ./pkgs;
|
overlays.default = import ./pkgs;
|
||||||
});
|
}) // {
|
||||||
|
matrix = let
|
||||||
|
inherit (nixpkgs.lib.lists) concatMap;
|
||||||
|
inherit (builtins) map;
|
||||||
|
systemSdks = concatMap (system: map (sdk: {inherit system sdk;}) self.sdks.${system}) systems;
|
||||||
|
in {include = systemSdks;};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
final: prev: {
|
final: prev: {
|
||||||
hl2sdk = (import ./hl2sdk.nix) {
|
hl2sdk = (import ./hl2sdk.nix) {
|
||||||
inherit (final) fetchFromGitHub;
|
inherit (final) fetchFromGitHub lib;
|
||||||
inherit (final.stdenvNoCC) mkDerivation;
|
inherit (final.stdenvNoCC) mkDerivation;
|
||||||
};
|
};
|
||||||
ambuild = final.python3Packages.callPackage ./ambuild.nix {};
|
ambuild = final.python3Packages.callPackage ./ambuild.nix {};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{fetchFromGitHub, mkDerivation}: let
|
{fetchFromGitHub, mkDerivation, lib}: let
|
||||||
inherit (builtins) mapAttrs;
|
inherit (builtins) mapAttrs elem;
|
||||||
|
inherit (lib) optionals;
|
||||||
revisions = {
|
revisions = {
|
||||||
csgo = {rev = "4e0975afe5b2994c76ec9b40951b6347b8788463"; sha256 = "sha256-Z5LD3I4uPKGIXTeSC3yQcJl6455XFwQVuiitND8ULEQ=";};
|
csgo = {rev = "4e0975afe5b2994c76ec9b40951b6347b8788463"; sha256 = "sha256-Z5LD3I4uPKGIXTeSC3yQcJl6455XFwQVuiitND8ULEQ=";};
|
||||||
tf2 = {rev = "2d3560994fbc31aebbe3a250048bbbc7f76d2803"; sha256 = "sha256-hKwF1cqg08NRPoZk77+lpC2cPMZeKVhsYFpGNi5IH30=";};
|
tf2 = {rev = "2d3560994fbc31aebbe3a250048bbbc7f76d2803"; sha256 = "sha256-hKwF1cqg08NRPoZk77+lpC2cPMZeKVhsYFpGNi5IH30=";};
|
||||||
|
|
@ -27,6 +28,11 @@
|
||||||
css = {rev = "ef291082a9efa01225001626e2b14bee8c2c63be"; sha256 = "sha256-x4tZ+fUTb+i2HoKIXgkpXjOUQIWurmHTLyJVuOm/lD0=";};
|
css = {rev = "ef291082a9efa01225001626e2b14bee8c2c63be"; sha256 = "sha256-x4tZ+fUTb+i2HoKIXgkpXjOUQIWurmHTLyJVuOm/lD0=";};
|
||||||
doi = {rev = "a4a0aa9de0a648d7f91fbb9ad8aecb119bd44314"; sha256 = "sha256-qMVHEeJqHyg9Kq1Y2+MNTjChiIUyO6PkbWmKPoGZa/Q=";};
|
doi = {rev = "a4a0aa9de0a648d7f91fbb9ad8aecb119bd44314"; sha256 = "sha256-qMVHEeJqHyg9Kq1Y2+MNTjChiIUyO6PkbWmKPoGZa/Q=";};
|
||||||
};
|
};
|
||||||
|
# from https://github.com/alliedmodders/metamod-source/blob/master/sample_mm/AMBuildScript
|
||||||
|
linuxX86Sdks = ["episode1" "css" "hl2dm" "dods" "sdk2013" "tf2" "l4d" "l4d2" "nucleardawn" "csgo" "doi" "bms"];
|
||||||
|
linuxX64Sdks = ["dota"];
|
||||||
|
isX86 = name: elem name linuxX86Sdks;
|
||||||
|
isX64 = name: elem name linuxX64Sdks;
|
||||||
fetchRev = {rev, sha256}: fetchFromGitHub {
|
fetchRev = {rev, sha256}: fetchFromGitHub {
|
||||||
inherit rev sha256;
|
inherit rev sha256;
|
||||||
owner = "alliedmodders";
|
owner = "alliedmodders";
|
||||||
|
|
@ -39,6 +45,15 @@
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cp -r $src $out/${name}
|
cp -r $src $out/${name}
|
||||||
'';
|
'';
|
||||||
|
passthru.platforms = {
|
||||||
|
x86 = isX86 sdkName;
|
||||||
|
x64 = isX64 sdkName;
|
||||||
|
};
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
platforms = optionals passthru.platforms.x86 ["i686-linux"] ++
|
||||||
|
optionals passthru.platforms.x64 ["x86_64-linux"];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
sdks = mapAttrs buildSdk revisions;
|
sdks = mapAttrs buildSdk revisions;
|
||||||
in sdks
|
in sdks
|
||||||
|
|
@ -1,34 +1,47 @@
|
||||||
{ clangMultiStdenv, fetchFromGitHub, ambuild, metamod-source, symlinkJoin, sdks ? {} }: let
|
{ clangStdenv, fetchFromGitHub, ambuild, metamod-source, symlinkJoin, lib, writeShellScriptBin, zlib, sdks ? {} }: let
|
||||||
inherit (builtins) concatStringsSep attrNames attrValues;
|
inherit (builtins) concatStringsSep attrNames attrValues;
|
||||||
sdkNames = attrNames sdks;
|
inherit (lib) optionals;
|
||||||
combinedSdks = symlinkJoin {
|
combinedSdks = symlinkJoin {
|
||||||
name = "hl2sdk-${concatStringsSep "-" (attrNames sdks)}";
|
name = "hl2sdk-${concatStringsSep "-" (attrNames sdks)}";
|
||||||
paths = attrValues sdks;
|
paths = attrValues sdks;
|
||||||
};
|
};
|
||||||
in clangMultiStdenv.mkDerivation rec {
|
ambuildArchs = {
|
||||||
|
"x86_64-linux" = "x86_64";
|
||||||
|
"i686-linux" = "x86";
|
||||||
|
};
|
||||||
|
ambuildArch = ambuildArchs.${clangStdenv.system};
|
||||||
|
sdkNames = concatStringsSep "," (attrNames sdks);
|
||||||
|
# ambuild doesn't allow configuring a target prefix for "ar"
|
||||||
|
arWrapper = writeShellScriptBin "ar" "exec -a $0 ${clangStdenv.cc.targetPrefix}ar $@";
|
||||||
|
in clangStdenv.mkDerivation rec {
|
||||||
pname = "sourcemod";
|
pname = "sourcemod";
|
||||||
version = "1.10";
|
version = "1.11";
|
||||||
|
|
||||||
NIX_CFLAGS_COMPILE = "-Wno-error=implicit-const-int-float-conversion -Wno-error=tautological-overlap-compare";
|
NIX_CFLAGS_COMPILE = "-Wno-error=implicit-const-int-float-conversion -Wno-error=tautological-overlap-compare";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "alliedmodders";
|
owner = "alliedmodders";
|
||||||
repo = pname;
|
repo = pname;
|
||||||
rev = "39c2dc60e0c0d963cfbe39bee3a7cf953cc8055c";
|
rev = "b09a675eb01c65dd95d7ac1a522fb62";
|
||||||
sha256 = "sha256-SwrBuOAebmLq5bgjw5i8CFuEDTtvDqLYY/dk4holrzw=";
|
sha256 = "sha256-FQBYxBt2AoM7OQYhz+qZuLddT9tIfW7ZlRg1Zkd5qE0=";
|
||||||
fetchSubmodules = true;
|
fetchSubmodules = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
ambuild
|
ambuild
|
||||||
|
] ++ optionals (clangStdenv.cc.targetPrefix != "") [arWrapper];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
zlib
|
||||||
];
|
];
|
||||||
|
|
||||||
hardeningDisable = [ "all" ];
|
# hardeningDisable = [ "all" ];
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
python ../configure.py --sdks present --no-mysql --disable-auto-versioning --mms-path=${metamod-source.src} --hl2sdk-root=${combinedSdks}
|
python ../configure.py --targets ${ambuildArch} --enable-optimize --sdks=${sdkNames} \
|
||||||
|
--no-mysql --disable-auto-versioning --mms-path=${metamod-source.src} --hl2sdk-root=${combinedSdks}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue