forked from nikkuss/pkgs
helium-browser: init
This commit is contained in:
@@ -0,0 +1,174 @@
|
||||
{
|
||||
stdenv,
|
||||
upstream-info,
|
||||
chromium,
|
||||
fetchurl,
|
||||
go-crx3,
|
||||
overrideCC,
|
||||
pkgsBuildBuild,
|
||||
lib,
|
||||
helium-patcher-unwrapped,
|
||||
fetchzip,
|
||||
}:
|
||||
(
|
||||
(chromium.passthru.mkDerivation.override (old: {
|
||||
inherit stdenv;
|
||||
ungoogled = true;
|
||||
ungoogled-chromium = helium-patcher-unwrapped;
|
||||
inherit upstream-info;
|
||||
}))
|
||||
(
|
||||
base:
|
||||
let
|
||||
helium = helium-patcher-unwrapped {
|
||||
inherit (upstream-info.deps.ungoogled-patches) rev hash;
|
||||
};
|
||||
buildPlatformLlvmStdenv =
|
||||
let
|
||||
llvmPackages = pkgsBuildBuild.rustc.llvmPackages;
|
||||
in
|
||||
overrideCC llvmPackages.stdenv (
|
||||
llvmPackages.stdenv.cc.override {
|
||||
inherit (llvmPackages) bintools;
|
||||
}
|
||||
);
|
||||
|
||||
ublock_src =
|
||||
let
|
||||
version = "1.66.4";
|
||||
in
|
||||
fetchurl {
|
||||
url = "https://github.com/imputnet/ublock-origin-crx/releases/download/${version}/uBlock0_${version}.crx";
|
||||
hash = "sha256-CMPHVEpSeKA1ZJX3Ia5gccIr+4KDFs6OF+IgO0Zhq74=";
|
||||
|
||||
recursiveHash = true;
|
||||
downloadToTemp = true;
|
||||
nativeBuildInputs = [
|
||||
go-crx3
|
||||
];
|
||||
postFetch = ''
|
||||
mv "$downloadedFile" "$TMPDIR/uBlock0_${version}.crx"
|
||||
crx3 unpack "$TMPDIR/uBlock0_${version}.crx"
|
||||
mv "uBlock0_${version}" "$out"
|
||||
'';
|
||||
};
|
||||
helium-onboarding =
|
||||
let
|
||||
version = "202509241653";
|
||||
in
|
||||
fetchzip {
|
||||
url = "https://github.com/imputnet/helium-onboarding/releases/download/${version}/helium-onboarding-${version}.tar.gz";
|
||||
hash = "sha256-AeGc6psN4nzbjSG/UF1GNiZ7ZhcgA5GwBrGTg2Rt3Ns=";
|
||||
stripRoot = false;
|
||||
};
|
||||
search-engine-data = fetchzip {
|
||||
url = "https://gist.githubusercontent.com/wukko/2a591364dda346e10219e4adabd568b1/raw/e75ae3c4a1ce940ef7627916a48bc40882d24d40/nonfree-search-engines-data.tar.gz";
|
||||
hash = "sha256-G83WwfoNmzI0ib9SRfjoDEoULnwgOTMQurlr1fKIpoo=";
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
in
|
||||
rec {
|
||||
inherit stdenv;
|
||||
pname = "helium-browser-unwrapped";
|
||||
depsBuildBuild = lib.filter (
|
||||
d: d != buildPlatformLlvmStdenv && d != buildPlatformLlvmStdenv.cc
|
||||
) base.depsBuildBuild;
|
||||
|
||||
postUnpack = ''
|
||||
cp -r ${helium-onboarding}/ src/components/helium_onboarding
|
||||
chmod +rw -R src/components/helium_onboarding
|
||||
cp -r ${ublock_src}/ src/third_party/ublock
|
||||
chmod +rw -R src/third_party/ublock
|
||||
cp -r ${search-engine-data}/. src/third_party/search_engines_data/resources_internal
|
||||
chmod +rw -R src/third_party/search_engines_data/resources_internal
|
||||
# chmod +x src/components/helium_onboarding/node_modules/@esbuild/linux-x64/bin/esbuild
|
||||
'';
|
||||
postPatch = base.postPatch + ''
|
||||
"${helium}/utils/name_substitution.py" --sub -t .
|
||||
"${helium}/utils/helium_version.py" --tree "${helium}" --chromium-tree .
|
||||
cp --no-preserve=mode,ownership -r "${helium}/resources" "$TMPDIR/helium-resources"
|
||||
"${helium}/utils/generate_resources.py" "${helium}/resources/generate_resources.txt" "$TMPDIR/helium-resources"
|
||||
"${helium}/utils/replace_resources.py" "${helium}/resources/helium_resources.txt" "$TMPDIR/helium-resources" .
|
||||
'';
|
||||
# stdenv = ccacheStdenv;
|
||||
name = "helium-browser";
|
||||
packageName = "helium";
|
||||
buildTargets = [
|
||||
"run_mksnapshot_default"
|
||||
"chrome_sandbox"
|
||||
"chrome"
|
||||
];
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"sandbox"
|
||||
];
|
||||
|
||||
sandboxExecutableName = "__chromium-suid-sandbox";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$libExecPath"
|
||||
cp -v "$buildPath/"*.so "$buildPath/"*.pak "$buildPath/"*.bin "$libExecPath/"
|
||||
cp -v "$buildPath/libvulkan.so.1" "$libExecPath/"
|
||||
cp -v "$buildPath/vk_swiftshader_icd.json" "$libExecPath/"
|
||||
cp -v "$buildPath/icudtl.dat" "$libExecPath/"
|
||||
cp -vLR "$buildPath/locales" "$buildPath/resources" "$libExecPath/"
|
||||
cp -v "$buildPath/chrome_crashpad_handler" "$libExecPath/"
|
||||
cp -v "$buildPath/chrome" "$libExecPath/$packageName"
|
||||
|
||||
# Swiftshader
|
||||
# See https://stackoverflow.com/a/4264351/263061 for the find invocation.
|
||||
if [ -n "$(find "$buildPath/swiftshader/" -maxdepth 1 -name '*.so' -print -quit)" ]; then
|
||||
echo "Swiftshader files found; installing"
|
||||
mkdir -p "$libExecPath/swiftshader"
|
||||
cp -v "$buildPath/swiftshader/"*.so "$libExecPath/swiftshader/"
|
||||
else
|
||||
echo "Swiftshader files not found"
|
||||
fi
|
||||
|
||||
mkdir -p "$sandbox/bin"
|
||||
cp -v "$buildPath/chrome_sandbox" "$sandbox/bin/${sandboxExecutableName}"
|
||||
|
||||
mkdir -vp "$out/share/man/man1"
|
||||
cp -v "$buildPath/chrome.1" "$out/share/man/man1/$packageName.1"
|
||||
|
||||
for icon_file in chrome/app/theme/chromium/product_logo_*[0-9].png; do
|
||||
num_and_suffix="''${icon_file##*logo_}"
|
||||
icon_size="''${num_and_suffix%.*}"
|
||||
expr "$icon_size" : "^[0-9][0-9]*$" || continue
|
||||
logo_output_prefix="$out/share/icons/hicolor"
|
||||
logo_output_path="$logo_output_prefix/''${icon_size}x''${icon_size}/apps"
|
||||
mkdir -vp "$logo_output_path"
|
||||
cp -v "$icon_file" "$logo_output_path/$packageName.png"
|
||||
done
|
||||
|
||||
# Install Desktop Entry
|
||||
install -D chrome/installer/linux/common/desktop.template \
|
||||
$out/share/applications/chromium-browser.desktop
|
||||
|
||||
substituteInPlace $out/share/applications/chromium-browser.desktop \
|
||||
--replace "@@MENUNAME@@" "Chromium" \
|
||||
--replace "@@PACKAGE@@" "chromium" \
|
||||
--replace "Exec=/usr/bin/@@USR_BIN_SYMLINK_NAME@@" "Exec=chromium"
|
||||
|
||||
# Append more mime types to the end
|
||||
sed -i '/^MimeType=/ s,$,x-scheme-handler/webcal;x-scheme-handler/mailto;x-scheme-handler/about;x-scheme-handler/unknown,' \
|
||||
$out/share/applications/chromium-browser.desktop
|
||||
|
||||
# See https://github.com/NixOS/nixpkgs/issues/12433
|
||||
sed -i \
|
||||
-e '/\[Desktop Entry\]/a\' \
|
||||
-e 'StartupWMClass=chromium-browser' \
|
||||
$out/share/applications/chromium-browser.desktop
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit sandboxExecutableName;
|
||||
};
|
||||
|
||||
requiredSystemFeatures = [ "big-parallel" ];
|
||||
|
||||
}
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user