diff --git a/confgen.lua b/confgen.lua index 317d38b..4e958f5 100644 --- a/confgen.lua +++ b/confgen.lua @@ -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 diff --git a/flake.nix b/flake.nix index a63df6e..be4a505 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }); } diff --git a/cgnix/.gitignore b/nix/cgnix/.gitignore similarity index 100% rename from cgnix/.gitignore rename to nix/cgnix/.gitignore diff --git a/cgnix/README.md b/nix/cgnix/README.md similarity index 100% rename from cgnix/README.md rename to nix/cgnix/README.md diff --git a/cgnix/default.nix b/nix/cgnix/default.nix similarity index 100% rename from cgnix/default.nix rename to nix/cgnix/default.nix diff --git a/cgnix/jvm.nix b/nix/cgnix/jvm.nix similarity index 100% rename from cgnix/jvm.nix rename to nix/cgnix/jvm.nix diff --git a/cgnix/nvim-tools.nix b/nix/cgnix/nvim-tools.nix similarity index 100% rename from cgnix/nvim-tools.nix rename to nix/cgnix/nvim-tools.nix diff --git a/cgnix/tree-sitter-parsers.nix b/nix/cgnix/tree-sitter-parsers.nix similarity index 100% rename from cgnix/tree-sitter-parsers.nix rename to nix/cgnix/tree-sitter-parsers.nix diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..6c83bbe --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + imports = [ ./cgnix ./mcdev.nix ]; +} diff --git a/nix/mcdev.nix b/nix/mcdev.nix new file mode 100644 index 0000000..1ef0c50 --- /dev/null +++ b/nix/mcdev.nix @@ -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 ]; + }; +} diff --git a/scripts/withjava/src/main.zig b/scripts/withjava/src/main.zig index 087c4fa..23d0520 100644 --- a/scripts/withjava/src/main.zig +++ b/scripts/withjava/src/main.zig @@ -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); } diff --git a/setup/commands/setup-nix.rkt b/setup/commands/setup-nix.rkt index 821b926..9336cf7 100644 --- a/setup/commands/setup-nix.rkt +++ b/setup/commands/setup-nix.rkt @@ -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"))