From 1282bf0ce4baad2f75879e8a66c91338c304b1cb Mon Sep 17 00:00:00 2001 From: aleksana Date: Sun, 17 Nov 2024 11:28:13 +0800 Subject: [PATCH] anvil-editor: init at 0.4 --- pkgs/by-name/an/anvil-editor/extras.nix | 14 +++ pkgs/by-name/an/anvil-editor/package.nix | 105 +++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 pkgs/by-name/an/anvil-editor/extras.nix create mode 100644 pkgs/by-name/an/anvil-editor/package.nix diff --git a/pkgs/by-name/an/anvil-editor/extras.nix b/pkgs/by-name/an/anvil-editor/extras.nix new file mode 100644 index 000000000000..4e130565fe4c --- /dev/null +++ b/pkgs/by-name/an/anvil-editor/extras.nix @@ -0,0 +1,14 @@ +{ + buildGoModule, + anvil-editor, +}: + +buildGoModule { + inherit (anvil-editor) version src meta; + + pname = "anvil-editor-extras"; + + modRoot = "anvil-extras"; + + vendorHash = "sha256-PH7HSMlCAHn4L1inJDbDcj6n+i6LXakIOqwdUkRjf9E="; +} diff --git a/pkgs/by-name/an/anvil-editor/package.nix b/pkgs/by-name/an/anvil-editor/package.nix new file mode 100644 index 000000000000..97a547f25bb0 --- /dev/null +++ b/pkgs/by-name/an/anvil-editor/package.nix @@ -0,0 +1,105 @@ +{ + lib, + stdenv, + buildGoModule, + fetchzip, + pkg-config, + libicns, + copyDesktopItems, + makeDesktopItem, + desktopToDarwinBundle, + apple-sdk_11, + darwinMinVersionHook, + wayland, + libxkbcommon, + vulkan-headers, + libGL, + xorg, + callPackage, + buildPackages, + anvilExtras ? callPackage ./extras.nix { }, +}: + +buildGoModule rec { + pname = "anvil-editor"; + version = "0.4"; + + # has to update vendorHash of extra package manually + # nixpkgs-update: no auto update + src = fetchzip { + url = "https://anvil-editor.net/releases/anvil-src-v${version}.tar.gz"; + hash = "sha256-0fi6UeppWC9KbWibjQYlPlRqsl9xsvij8YpJUS0S/wY="; + }; + + modRoot = "anvil/src/anvil"; + + vendorHash = "sha256-1oFBV7D7JgOt5yYAxVvC4vL4ccFv3JrNngZbo+5pzrk="; + + nativeBuildInputs = + [ + pkg-config + copyDesktopItems + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + desktopToDarwinBundle + ]; + + buildInputs = + if stdenv.hostPlatform.isDarwin then + [ + apple-sdk_11 + # metal dependencies require 10.13 or newer + (darwinMinVersionHook "10.13") + ] + else + [ + wayland + libxkbcommon + vulkan-headers + libGL + xorg.libX11 + xorg.libXcursor + xorg.libXfixes + ]; + + # Got different result in utf8 char length? + checkFlags = [ "-skip=^TestClearAfter$" ]; + + desktopItems = [ + (makeDesktopItem { + name = "anvil"; + exec = "anvil"; + icon = "anvil"; + desktopName = "Anvil"; + comment = meta.description; + categories = [ "TextEditor" ]; + startupWMClass = "anvil"; + }) + ]; + + postInstall = '' + pushd ../../img + # cannot add to nativeBuildInputs + # will be conflict with icnsutils in desktopToDarwinBundle + ${lib.getExe' buildPackages.libicns "icns2png"} -x anvil.icns + for width in 32 48 128 256; do + square=''${width}x''${width} + install -Dm644 anvil_''${square}x32.png $out/share/icons/hicolor/''${square}/apps/anvil.png + done + popd + cp ${anvilExtras}/bin/* $out/bin + ''; + + passthru = { + inherit anvilExtras; + }; + + meta = { + description = "Graphical, multi-pane tiling editor inspired by Acme"; + homepage = "https://anvil-editor.net"; + license = lib.licenses.mit; + mainProgram = "anvil"; + maintainers = with lib.maintainers; [ aleksana ]; + platforms = with lib.platforms; unix ++ windows; + }; +}