various nix fixes + minecraft dev shell

This commit is contained in:
LordMZTE 2024-04-13 21:32:27 +02:00
parent 869b7fe7f6
commit bbabdab552
Signed by: LordMZTE
GPG Key ID: B64802DC33A64FF6
12 changed files with 84 additions and 35 deletions

View File

@ -24,7 +24,10 @@ cg.onDone(function(errors)
end
end)
local nix = (loadfile "cgnix/nix.lua" or function() return {} end)()
local nix = (loadfile "nix/cgnix/nix.lua" or function()
print "no cgnix file!"
return {}
end)()
cg.opt.nix = nix

View File

@ -17,6 +17,7 @@
root-mod = {
options.packages = nixpkgs.lib.mkOption { };
options.dev-shells = nixpkgs.lib.mkOption { };
config._module.args = {
inherit pkgs system;
@ -32,44 +33,46 @@
(flakePkg "github:nix-community/zon2nix")
];
};
# devshell for the dotfiles
config.dev-shells.default = nixpkgs.legacyPackages.${system}.mkShell {
buildInputs = with pkgs;
[
# packages required to build scripts
libGL
libgit2
luajit
pkg-config
racket
roswell
wayland
wayland-protocols
haxe
mpv-unwrapped
] ++
# shorthands for setup.rkt
builtins.map
(cmd: pkgs.writeShellScriptBin cmd ''
./setup.rkt ${cmd}
'') [
"install-scripts"
"install-plugins"
"install-lsps-paru"
"setup-nvim-config"
"setup-nix"
"run-confgen"
];
};
};
modopt = nixpkgs.lib.evalModules {
modules = [ root-mod ./cgnix ] ++ common.localconf;
modules = [ root-mod ./nix ] ++ common.localconf;
specialArgs = { inherit common; };
};
in
{
mzteinit = pkgs.callPackage ./scripts/mzteinit/package.nix { };
packages = modopt.config.packages;
devShells.default = nixpkgs.legacyPackages.${system}.mkShell {
buildInputs = with pkgs;
[
# packages required to build scripts
libGL
libgit2
luajit
pkg-config
racket
roswell
wayland
wayland-protocols
haxe
mpv-unwrapped
] ++
# shorthands for setup.rkt
builtins.map
(cmd: pkgs.writeShellScriptBin cmd ''
./setup.rkt ${cmd}
'') [
"install-scripts"
"install-plugins"
"install-lsps-paru"
"setup-nvim-config"
"setup-nix"
"run-confgen"
];
};
devShells = modopt.config.dev-shells;
});
}

4
nix/default.nix Normal file
View File

@ -0,0 +1,4 @@
{ ... }:
{
imports = [ ./cgnix ./mcdev.nix ];
}

37
nix/mcdev.nix Normal file
View File

@ -0,0 +1,37 @@
# A dev shell for Minecraft development, including necessary dependencies for the game to run.
{ pkgs, ... }:
let
libs = with pkgs; [
libpulseaudio
libGL
glfw
openal
stdenv.cc.cc.lib
udev # OSHI
];
xorg-libs = with pkgs.xorg; [
libX11
libXext
libXcursor
libXrandr
libXxf86vm
];
in
{
dev-shells = builtins.mapAttrs
(_: extra-pkgs:
let
shpgks = libs ++ xorg-libs ++ extra-pkgs;
in
pkgs.mkShell {
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.addOpenGLRunpath.driverLink}/lib:${pkgs.lib.makeLibraryPath shpgks}:$LD_LIBRARY_PATH"
'';
buildInputs = shpgks;
})
{
mcdev = [ pkgs.jdk8 ];
mcdev-new = [ pkgs.jdk17 ];
};
}

View File

@ -19,22 +19,24 @@ pub fn main() !u8 {
var env = try std.process.getEnvMap(alloc);
defer env.deinit();
const jvm_basepath = opts.jvm orelse "/usr/lib/jvm";
if (env.getPtr("PATH")) |path_p| {
const newpath = try std.fmt.allocPrint(
alloc,
(opts.jvm orelse "/usr/lib/jvm") ++ "/{s}/bin:{s}",
jvm_basepath ++ "/{s}/bin:{s}",
.{ std.os.argv[1], path_p.* },
);
alloc.free(path_p.*);
path_p.* = newpath;
} else {
const newpath = try std.fmt.allocPrint(alloc, "/usr/lib/jvm/{s}/bin", .{std.os.argv[1]});
const newpath = try std.fmt.allocPrint(alloc, jvm_basepath ++ "/{s}/bin", .{std.os.argv[1]});
errdefer alloc.free(newpath);
try env.putMove(try alloc.dupe(u8, "PATH"), newpath);
}
{
const java_home = try std.fmt.allocPrint(alloc, "/usr/lib/jvm/{s}", .{std.os.argv[1]});
const java_home = try std.fmt.allocPrint(alloc, jvm_basepath ++ "/{s}", .{std.os.argv[1]});
errdefer alloc.free(java_home);
try env.putMove(try alloc.dupe(u8, "JAVA_HOME"), java_home);
}

View File

@ -5,4 +5,4 @@
(define (run)
(define out (build-path (find-system-path 'home-dir) ".local" "mzte-nix"))
(cmd "nix" "build" ".#mzte-nix" "--impure" "--out-link" out)
(cmd "nix" "build" ".#cgnix" "--impure" "--out-link" "cgnix/nix.lua"))
(cmd "nix" "build" ".#cgnix" "--impure" "--out-link" "nix/cgnix/nix.lua"))