From b229a37e59b9720b7017e72a6d159b869ff36458 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 26 Aug 2024 23:51:17 -0400 Subject: [skip ci] initial commit --- default.nix | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 default.nix (limited to 'default.nix') diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..fb95f92 --- /dev/null +++ b/default.nix @@ -0,0 +1,63 @@ +# nix-build +# or to build a cross compiled package: nix-build -A .lwjgl +# i.e., nix-build -A aarch64-unknown-linux-gnu.lwjgl +{ + pkgs ? import { + inherit system; + config = { }; + overlays = [ ]; + }, + nixpkgs ? , + system ? builtins.currentSystem, +}: + +let + inherit (pkgs) lib; + inherit (pkgs.stdenv.hostPlatform) system; + nativeTarget = pkgs.stdenv.hostPlatform.config; + + # Targets we want to build for + targets = [ + "x86_64-unknown-linux-gnu" + "i686-unknown-linux-gnu" + "aarch64-unknown-linux-gnu" + "armv7l-unknown-linux-gnueabihf" + "riscv64-unknown-linux-gnu" + ]; + + # Loop over each target + forAllTargets = lib.genAttrs targets; + + # Nixpkgs re-instantiated to cross compile from our current system to each target + crossPkgsFor = forAllTargets ( + target: + + import nixpkgs { + inherit system; + inherit (pkgs) config overlays; + crossSystem = { + config = target; + }; + } + ); + + # Our package set for each target + ourPackagesFor = forAllTargets ( + target: + + let + callPackage = lib.callPackageWith (ourPackagesFor.${target} // crossPkgsFor.${target}); + in + + { + fetchAntDeps = callPackage ./pkgs/fetch-ant-deps.nix { }; + lwjgl = callPackage ./pkgs/lwjgl.nix { }; + } + ); + + nativeLwjgl = + ourPackagesFor.${nativeTarget}.lwjgl + or (lib.trace "${nativeTarget} is not a supported target" pkgs.emptyFile); +in + +ourPackagesFor // { lwjgl = nativeLwjgl; } -- cgit v1.2.3