From 97e9950ca88c204c028f67c96675a810c82eb19b Mon Sep 17 00:00:00 2001 From: Emmet Date: Fri, 4 Aug 2023 13:47:41 -0500 Subject: [PATCH] More up-to-date blockbench --- profiles/work/home.nix | 4 ++- user/pkgs/blockbench.nix | 53 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 user/pkgs/blockbench.nix diff --git a/profiles/work/home.nix b/profiles/work/home.nix index 2b9e2e5..658feef 100644 --- a/profiles/work/home.nix +++ b/profiles/work/home.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, python3Packages, nix-doom-emacs, stylix, username, email, dotfilesDir, theme, wm, browser, editor, spawnEditor, term, ... }: +{ config, lib, pkgs, stdenv, fetchurl, python3Packages, nix-doom-emacs, stylix, username, email, dotfilesDir, theme, wm, browser, editor, spawnEditor, term, ... }: { # Home Manager needs a bit of information about you and the paths it should @@ -25,10 +25,12 @@ ../../user/style/stylix.nix # Styling and themes for my apps ../../user/lang/cc/cc.nix # C and C++ tools ../../user/lang/godot/godot.nix # Game development + ../../user/pkgs/blockbench.nix # Blockbench ]; home.stateVersion = "22.11"; # Please read the comment before changing. + home.packages = with pkgs; [ # Core zsh diff --git a/user/pkgs/blockbench.nix b/user/pkgs/blockbench.nix new file mode 100644 index 0000000..bdfa149 --- /dev/null +++ b/user/pkgs/blockbench.nix @@ -0,0 +1,53 @@ +{ config, stdenv, fetchurl, appimageTools, makeWrapper, electron_22, lib, pkgs, ... }: + +{ + nixpkgs.overlays = [ + (self: super: + { + blockbench-electron = + let + inherit (pkgs) fetchurl stdenv appimageTools makeWrapper electron_22; + in + super.blockbench-electron.overrideAttrs (oldAttrs: rec { + pname = "blockbench-electron"; + version = "4.8.1"; + src = fetchurl { + inherit pname version; + url = "https://github.com/JannisX11/blockbench/releases/download/v${version}/Blockbench_${version}.AppImage"; + sha256 = "sha256-CE2wDOt1WBcYmPs4sEyZ3LYvKLequFZH0B3huMYHlwA="; + name = "${pname}-${version}.AppImage"; + }; + + appimageContents = appimageTools.extractType2 { + inherit pname version; + name = "${pname}-${version}"; + inherit src; + }; + + dontUnpack = true; + dontConfigure = true; + dontBuild = true; + + nativeBuildInputs = [ makeWrapper ]; + + installPhase = '' + runHook preInstall + mkdir -p $out/bin $out/share/${pname} $out/share/applications + cp -a ${appimageContents}/{locales,resources} $out/share/${pname} + cp -a ${appimageContents}/blockbench.desktop $out/share/applications/${pname}.desktop + cp -a ${appimageContents}/usr/share/icons $out/share + substituteInPlace $out/share/applications/${pname}.desktop \ + --replace 'Exec=AppRun' 'Exec=${pname}' + runHook postInstall + ''; + + postFixup = '' + makeWrapper ${electron_22}/bin/electron $out/bin/${pname} \ + --add-flags $out/share/${pname}/resources/app.asar \ + --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ stdenv.cc.cc ]}" + ''; + }); + } + ) + ]; +}