mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 00:12:56 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
124 lines
3.2 KiB
Nix
124 lines
3.2 KiB
Nix
{ lib
|
|
, rustPlatform
|
|
, clangStdenv
|
|
, fetchFromGitHub
|
|
, linkFarm
|
|
, fetchgit
|
|
, runCommand
|
|
, gn
|
|
, neovim
|
|
, ninja
|
|
, makeWrapper
|
|
, pkg-config
|
|
, python3
|
|
, removeReferencesTo
|
|
, xcbuild
|
|
, SDL2
|
|
, fontconfig
|
|
, xorg
|
|
, stdenv
|
|
, darwin
|
|
, libglvnd
|
|
, libxkbcommon
|
|
, enableWayland ? stdenv.hostPlatform.isLinux
|
|
, wayland
|
|
}:
|
|
|
|
rustPlatform.buildRustPackage.override { stdenv = clangStdenv; } rec {
|
|
pname = "neovide";
|
|
version = "0.13.3";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "neovide";
|
|
repo = "neovide";
|
|
rev = version;
|
|
hash = "sha256-u10JxMvXC/FIobeolWJElBZuCiJ3xIUg4F0vLom7/S0=";
|
|
};
|
|
|
|
cargoHash = "sha256-j8++watC7RBc1zn8m7Jg0Zl/iKXSrld+q62GiaLxGCo=";
|
|
|
|
SKIA_SOURCE_DIR =
|
|
let
|
|
repo = fetchFromGitHub {
|
|
owner = "rust-skia";
|
|
repo = "skia";
|
|
# see rust-skia:skia-bindings/Cargo.toml#package.metadata skia
|
|
rev = "m126-0.74.2";
|
|
hash = "sha256-4l6ekAJy+pG27hBGT6A6LLRwbsyKinJf6PP6mMHwaAs=";
|
|
};
|
|
# The externals for skia are taken from skia/DEPS
|
|
externals = linkFarm "skia-externals" (lib.mapAttrsToList
|
|
(name: value: { inherit name; path = fetchgit value; })
|
|
(lib.importJSON ./skia-externals.json));
|
|
in
|
|
runCommand "source" { } ''
|
|
cp -R ${repo} $out
|
|
chmod -R +w $out
|
|
ln -s ${externals} $out/third_party/externals
|
|
''
|
|
;
|
|
|
|
SKIA_GN_COMMAND = "${gn}/bin/gn";
|
|
SKIA_NINJA_COMMAND = "${ninja}/bin/ninja";
|
|
|
|
nativeBuildInputs = [
|
|
makeWrapper
|
|
pkg-config
|
|
python3 # skia
|
|
removeReferencesTo
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ];
|
|
|
|
nativeCheckInputs = [ neovim ];
|
|
|
|
buildInputs = [
|
|
SDL2
|
|
fontconfig
|
|
rustPlatform.bindgenHook
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
darwin.apple_sdk.frameworks.AppKit
|
|
];
|
|
|
|
postFixup = let
|
|
libPath = lib.makeLibraryPath ([
|
|
libglvnd
|
|
libxkbcommon
|
|
xorg.libXcursor
|
|
xorg.libXext
|
|
xorg.libXrandr
|
|
xorg.libXi
|
|
] ++ lib.optionals enableWayland [ wayland ]);
|
|
in ''
|
|
# library skia embeds the path to its sources
|
|
remove-references-to -t "$SKIA_SOURCE_DIR" \
|
|
$out/bin/neovide
|
|
|
|
wrapProgram $out/bin/neovide \
|
|
--prefix LD_LIBRARY_PATH : ${libPath}
|
|
'';
|
|
|
|
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
mkdir -p $out/Applications
|
|
cp -r extra/osx/Neovide.app $out/Applications
|
|
ln -s $out/bin $out/Applications/Neovide.app/Contents/MacOS
|
|
'' + lib.optionalString stdenv.hostPlatform.isLinux ''
|
|
for n in 16x16 32x32 48x48 256x256; do
|
|
install -m444 -D "assets/neovide-$n.png" \
|
|
"$out/share/icons/hicolor/$n/apps/neovide.png"
|
|
done
|
|
install -m444 -Dt $out/share/icons/hicolor/scalable/apps assets/neovide.svg
|
|
install -m444 -Dt $out/share/applications assets/neovide.desktop
|
|
'';
|
|
|
|
disallowedReferences = [ SKIA_SOURCE_DIR ];
|
|
|
|
meta = with lib; {
|
|
description = "This is a simple graphical user interface for Neovim";
|
|
mainProgram = "neovide";
|
|
homepage = "https://github.com/neovide/neovide";
|
|
changelog = "https://github.com/neovide/neovide/releases/tag/${version}";
|
|
license = with licenses; [ mit ];
|
|
maintainers = with maintainers; [ ck3d ];
|
|
platforms = platforms.linux ++ [ "aarch64-darwin" ];
|
|
};
|
|
}
|