Migrate Nix shell config to Flake

This commit is contained in:
2023-12-09 18:33:39 +01:00
parent c12960caea
commit 0cb61384e9
6 changed files with 80 additions and 48 deletions

2
.envrc
View File

@@ -1 +1 @@
use nix
use flake

27
flake.lock generated Normal file
View File

@@ -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
}

42
flake.nix Normal file
View File

@@ -0,0 +1,42 @@
{
description = "BASE engine";
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-editor";
buildInputs = [
xorg.libXtst
alsa-lib
gradle_7
jdk17
protobuf
];
shellHook = ''
echo
echo
echo "======================================================================================================"
echo "Welcome to BASE NixOS flake 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
'';
LD_LIBRARY_PATH = "${opengl}/lib:${xorg.libXtst}/lib:${alsa-lib}/lib";
PROTOBUF_EXECUTABLE = "${protobuf}/bin/protoc";
};
};
}

View File

@@ -11,10 +11,10 @@ javaFxPluginVersion=0.0.10
tornadoFxVersion=2.0.0-SNAPSHOT
ikonliVersion=12.2.0
protobufPluginVersion=0.8.18
protobufVersion=3.19.1
protobufVersion=3.24.4
richtextfxVersion=0.10.7
janinoVersion=3.1.6
apacheCommonsVersion=3.6.1
h2Version=1.4.200
hikariVersion=5.0.0
javaPoetVersion=1.13.0
javaPoetVersion=1.13.0

View File

@@ -29,7 +29,13 @@ sourceSets {
protobuf {
// Fetch protoc compiler
protoc {
artifact = "com.google.protobuf:protoc:$protobufVersion"
def protobufExecutable = System.getenv("PROTOBUF_EXECUTABLE")
if (protobufExecutable == null) {
artifact = "com.google.protobuf:protoc:$protobufVersion"
} else {
path = protobufExecutable
}
}
generatedFilesBaseDir = "$projectDir/build/proto/"
@@ -42,4 +48,4 @@ protobuf {
}
}
}
}
}

View File

@@ -1,43 +0,0 @@
{ pkgs ? import <nixpkgs> {} }:
# 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
'';
}