diff --git a/flake.nix b/flake.nix index f7b3f84..0404b7a 100644 --- a/flake.nix +++ b/flake.nix @@ -49,6 +49,7 @@ }: let system = "x86_64-linux"; + mylib = import ./lib; overlay-stable = final: prev: { stable = import nixpkgs-stable { inherit system; @@ -75,7 +76,7 @@ in nixpkgs.lib.nixosSystem { inherit system; - specialArgs = { inherit data; }; + specialArgs = { inherit data; inherit mylib; }; modules = [ { nixpkgs.overlays = my-overlays; } ./hosts/${host}/configuration.nix @@ -94,6 +95,7 @@ ./hosts/${host}/home ] ++ extra-home-modules; }; + home-manager.extraSpecialArgs = { inherit mylib; }; } ]) ; diff --git a/hosts/laptop/home/default.nix b/hosts/laptop/home/default.nix index 0ffdf94..1469b9b 100644 --- a/hosts/laptop/home/default.nix +++ b/hosts/laptop/home/default.nix @@ -1,4 +1,4 @@ -{ config, osConfig, pkgs, ... }: +{ config, osConfig, pkgs, mylib, ... }: { home.username = "lgm"; @@ -93,14 +93,20 @@ minetest # dev # Wrap idea-community to add libraries required for Minecraft Moddev - (symlinkJoin { - name = "idea-community"; - paths = [ jetbrains.idea-community ]; - buildInputs = [ makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/idea-community \ - --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [libpulseaudio libGL glfw openal stdenv.cc.cc.lib]}" - ''; + stable.jetbrains.idea-community + (mylib.appwrapper { + inherit pkgs; + inputpkg = stable.jetbrains.idea-community; + pkgsuffix = "mcdev-jbr17"; + libraries = with pkgs; [libpulseaudio libGL glfw openal stdenv.cc.cc.lib]; + extrapathpkgs = with pkgs; [jetbrains.jdk-no-jcef-17]; + }) + (mylib.appwrapper { + inherit pkgs; + inputpkg = stable.jetbrains.idea-community; + pkgsuffix = "mcdev-jbr21"; + libraries = with pkgs; [libpulseaudio libGL glfw openal stdenv.cc.cc.lib]; + extrapathpkgs = with pkgs; [jetbrains.jdk-no-jcef]; }) packwiz # vscodium # see programs.vscode diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..bacfbf0 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,29 @@ +{ + appwrapper = + { + pkgs, + inputpkg, + pkgsuffix, + libraries, + extrapathpkgs + }: with pkgs; let + name = "${inputpkg.pname}-${pkgsuffix}"; + in stdenv.mkDerivation { + inherit name; + inherit (inputpkg) version; + nativeBuildInputs = [ makeWrapper gnused ]; + buildCommand = '' + mkdir -p $out/bin + mkdir -p $out/share/applications + cp ${inputpkg}/share/applications/${inputpkg.pname}.desktop $out/share/applications/${name}.desktop + makeWrapper ${inputpkg}/bin/${inputpkg.pname} $out/bin/${name} \ + --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath libraries}" \ + --prefix PATH : "${lib.makeBinPath extrapathpkgs}" + substituteInPlace $out/share/applications/${name}.desktop \ + --replace-fail "=${inputpkg.pname}" "=${name}" + sed -i -E "s/^Name=(.*)/Name=\1 (${pkgsuffix})/g" "$out/share/applications/${name}.desktop" + echo $out/bin/${name} + ''; + dontBuild = true; + }; +} \ No newline at end of file