diff --git a/.envrc b/.envrc index 1d953f4..3550a30 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use nix +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c19674c --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1701952659, + "narHash": "sha256-TJv2srXt6fYPUjxgLAL0cy4nuf1OZD4KuA1TrCiQqg0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b4372c4924d9182034066c823df76d6eaf1f4ec4", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..85229a5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + description = "BASE Demo Game"; + + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixos-23.11; + }; + + outputs = { self, nixpkgs }: + let + pkgs = import nixpkgs { inherit system; }; + system = "x86_64-linux"; + opengl = "/run/opengl-driver"; + in { + devShells.${system}.default = with pkgs; mkShell { + name = "base-demo"; + + buildInputs = [ + xorg.libXtst + alsa-lib + jdk17 + ]; + + shellHook = '' + echo + echo + echo "======================================================================================================" + echo "Welcome to BASE Demo Game NixOS flake shell environment" + echo "Remember to provide following LD environment variable in order to run the game outside this shell" + echo + echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" + echo "======================================================================================================" + echo + echo + ''; + + LD_LIBRARY_PATH = "${opengl}/lib:${xorg.libXtst}/lib:${alsa-lib}/lib"; + }; + }; +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 4959948..0000000 --- a/shell.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ pkgs ? import {} }: - -# Because of high dependency on native libraries like OpenGL and OpenAL -# on the NixOS the BASE engine requires few modifications. -# Basically this shell.nix could be enough, however the OpenGL is highly tied with the hardware, -# so the following change needs to be applied in the configuration.nix (or your flake configuration, whatever): -# hardware.opengl = { -# enable = true; -# extraPackages = with pkgs; [ -# libGL -# ]; -# setLdLibraryPath = true; -# }; -# -# Also for GNOME environments, the Editor requires the libglassgtk3.so library, -# so it is available via xorg.libXtst package mentioned already in the shell definition below. - -let - opengl = "/run/opengl-driver"; -in pkgs.mkShell { - name = "BASE NixOS runtime"; - - buildInputs = [ - pkgs.xorg.libXtst # Required by editor on GNOME environments (due to libglassgtk3.so dependency) - pkgs.alsa-lib # Either alsa or jack or pulseaudio library is required by game engine via OpenAL native library - ]; - - # OpenGL needs to be configured via /etc/nixos/configuration.nix - LD_LIBRARY_PATH = "${opengl}/lib:${pkgs.xorg.libXtst}/lib:${pkgs.alsa-lib}/lib"; - - shellHook = '' - echo - echo - echo "======================================================================================================" - echo "Welcome to BASE NixOS shell environment" - echo "Remember to provide following LD environment variable in order to run application outside this shell:" - echo - echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" - echo "======================================================================================================" - echo - echo - ''; -}