如何解决在 nix-env --install 之后 .nix-probfile/bin 中未生成符号链接
我对 Nix 很陌生。
我编辑了 original default.nix for Brave browser 以支持 Apple Silicon (aarch64-darwin
)。
现在,在我装有 Apple Silicon 的笔记本电脑上,我确认 nix-env -iA brave -f .
可以正常工作,并且 Brave browser.app
是在 /nix/store/<hash>/Applications
下创建的。但是,在 brave
中找不到 ~/.nix-profile/bin
命令。
我错过了什么吗?
这是我的default.nix
:
{ stdenv,lib,fetchurl,dpkg,unzip,alsa-lib,at-spi2-atk,at-spi2-core,atk,cairo,cups,dbus,expat,fontconfig,freetype,gdk-pixbuf,glib,gnome2,gnome,gsettings-desktop-schemas,gtk3,libpulseaudio,libuuid,libdrm,libX11,libXcomposite,libXcursor,libXdamage,libXext,libXfixes,libXi,libxkbcommon,libXrandr,libXrender,libXScrnSaver,libxshmfence,libXtst,mesa,nspr,nss,pango,udev,xorg,zlib,xdg-utils,wrapGAppsHook
}:
let
inherit (stdenv.hostPlatform) system;
throwSystem = throw "Unsupported system: ${system}";
pname = "brave";
version = "1.26.77";
Meta = with lib; {
homepage = "https://brave.com/";
description = "Privacy-oriented browser for Desktop and Laptop computers";
changelog = "https://github.com/brave/brave-browser/blob/master/CHANGELOG_DESKTOP.md";
longDescription = ''
Brave browser blocks the ads and trackers that slow you down,chew up your bandwidth,and invade your privacy. Brave lets you
contribute to your favorite creators automatically.
'';
license = licenses.mpl20;
maintainers = with maintainers; [ uskudnik rht jefflabonte nasirhm ];
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
};
src = let
base = "https://github.com/brave/brave-browser/releases/download";
in {
x86_64-linux = fetchurl {
url = "${base}/v${version}/brave-browser_${version}_amd64.deb";
sha256 = "tV/VseU+IncvM3gdrmqkYLPClbsf2kSvIAZj0Ylz2Rw=";
};
x86_64-darwin = fetchurl {
url = "${base}/v${version}/Brave-browser-x64.dmg";
sha256 = "1c5240fb6debc1855a885fb46639fb4297aae2d9bdec2d8552069bce7c99d03c";
};
aarch64-darwin = fetchurl {
url = "${base}/v${version}/brave-v${version}-darwin-arm64.zip";
sha256 = "f1113aff80938807946e0aae6f75a78fc099aaa515d4c6218a62089792ed8046";
};
}.${system} or throwSystem;
linux = stdenv.mkDerivation rec {
inherit pname version src Meta;
dontConfigure = true;
dontBuild = true;
dontPatchELF = true;
doInstallCheck = true;
rpath = lib.makeLibraryPath [
alsa-lib
at-spi2-atk
at-spi2-core
atk
cairo
cups
dbus
expat
fontconfig
freetype
gdk-pixbuf
glib
gnome2.GConf
gtk3
libdrm
libpulseaudio
libX11
libxkbcommon
libXScrnSaver
libXcomposite
libXcursor
libXdamage
libXext
libXfixes
libXi
libXrandr
libXrender
libxshmfence
libXtst
libuuid
mesa
nspr
nss
pango
udev
xdg-utils
xorg.libxcb
zlib
];
nativeBuildInputs = [ dpkg wrapGAppsHook ];
buildInputs = [ glib gsettings-desktop-schemas gnome.adwaita-icon-theme ];
unpackPhase = "dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner";
installPhase = ''
runHook preInstall
mkdir -p $out $out/bin
cp -R usr/share $out
cp -R opt/ $out/opt
export BINARYWRAPPER=$out/opt/brave.com/brave/brave-browser
# Fix path to bash in $BINARYWRAPPER
substituteInPlace $BINARYWRAPPER \
--replace /bin/bash ${stdenv.shell}
ln -sf $BINARYWRAPPER $out/bin/brave
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${rpath}" $out/opt/brave.com/brave/brave
# Fix paths
substituteInPlace $out/share/applications/brave-browser.desktop \
--replace /usr/bin/brave-browser-stable $out/bin/brave
substituteInPlace $out/share/gnome-control-center/default-apps/brave-browser.xml \
--replace /opt/brave.com $out/opt/brave.com
substituteInPlace $out/share/menu/brave-browser.menu \
--replace /opt/brave.com $out/opt/brave.com
substituteInPlace $out/opt/brave.com/brave/default-app-block \
--replace /opt/brave.com $out/opt/brave.com
# Correct icons location
icon_sizes=("16" "22" "24" "32" "48" "64" "128" "256")
for icon in ''${icon_sizes[*]}
do
mkdir -p $out/share/icons/hicolor/$icon\x$icon/apps
ln -s $out/opt/brave.com/brave/product_logo_$icon.png $out/share/icons/hicolor/$icon\x$icon/apps/brave-browser.png
done
# Replace xdg-settings and xdg-mime
ln -sf ${xdg-utils}/bin/xdg-settings $out/opt/brave.com/brave/xdg-settings
ln -sf ${xdg-utils}/bin/xdg-mime $out/opt/brave.com/brave/xdg-mime
runHook postInstall
'';
installCheckPhase = ''
# Bypass upstream wrapper which suppresses errors
$out/opt/brave.com/brave/brave --version
'';
passthru.updateScript = ./update.sh;
};
darwin = stdenv.mkDerivation rec {
inherit pname version src Meta;
passthru.updateScript = ./update.sh;
nativeBuildInputs = [ unzip ];
sourceRoot = ".";
installPhase = ''
mkdir -p $out/Applications
cp -r *.app $out/Applications
'';
};
in if stdenv.isDarwin
then darwin
else linux
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。