From d1b18f39ddcda4d63016efd622ef959952aae072 Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Thu, 9 Mar 2023 19:37:42 -0800 Subject: [PATCH] Add flake.nix --- flake.lock | 26 ++++++++++++++++++++ flake.nix | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..2930702 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1678137616, + "narHash": "sha256-T+lWTRdcYaOnZQW+Ehdlg+YldC2l9cq2GXJFPq22Nxc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7edcdf7b169c33cd3eef9aba50521ce93ee666b8", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-22.11", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0c65716 --- /dev/null +++ b/flake.nix @@ -0,0 +1,71 @@ +{ + description = "Open source implementation of AliceSoft's System 4 game engine for unix-like operating systems"; + + # Nixpkgs / NixOS version to use. + inputs.nixpkgs.url = "nixpkgs/nixos-22.11"; + + outputs = { self, nixpkgs }: + let + + # System types to support. + supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + + # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + + # Nixpkgs instantiated for supported system types. + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + + in { + + # Set up xsystem4 development environment: + # nix develop # create shell environment with dependencies available + devShell = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; in with pkgs; pkgs.mkShell { + nativeBuildInputs = [ meson ninja pkg-config ]; + buildInputs = [ + cglm + SDL2 + freetype + libffi + libjpeg + libwebp + libsndfile + glew + readline + flex + bison + ]; + } + ); + + # Build xsystem4: + # nix build .?submodules=1 # build xsystem4 (outputs to ./result/) + # nix shell .?submodules=1 # create shell environment with xsystem4 available + # Install xsystem4 to user profile: + # nix profile install .?submodules=1 + packages = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; in { + default = with pkgs; stdenv.mkDerivation rec { + name = "xsystem4"; + src = ./.; + mesonAutoFeatures = "auto"; + nativeBuildInputs = [ meson ninja pkg-config ]; + buildInputs = [ + cglm + SDL2 + freetype + libffi + libjpeg + libwebp + libsndfile + glew + readline + flex + bison + ]; + }; + } + ); + }; +}