cross: support browserpass-extension w/o emulation

This commit is contained in:
Colin 2023-08-06 01:51:14 +00:00
parent 3423f103fc
commit 4b072ecbe5
2 changed files with 52 additions and 12 deletions

View File

@ -336,14 +336,42 @@ in {
# # <https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Runtime.html>
# };
firefox-extensions = prev.firefox-extensions.overrideScope' (self: super: {
unwrapped = super.unwrapped // {
browserpass-extension = super.unwrapped.browserpass-extension.override {
# bash: line 1: node_modules/.bin/prettier: cannot execute: required file not found
inherit (emulated) mkYarnModules;
};
};
});
# firefox-extensions = prev.firefox-extensions.overrideScope' (self: super: {
# unwrapped = super.unwrapped // {
# # browserpass-extension = super.unwrapped.browserpass-extension.override {
# # # bash: line 1: node_modules/.bin/prettier: cannot execute: required file not found
# # # same with less and browserify.
# # inherit (emulated) mkYarnModules;
# # };
# # browserpass-extension = emulateBuildMachine super.unwrapped.browserpass-extension;
# browserpass-extension = super.unwrapped.browserpass-extension.override {
# mkYarnModules = args: emulateBuildMachine {
# override = { stdenv }: (
# (final.yarn2nix-moretea.override {
# pkgs = final.pkgs.__splicedPackages // { inherit stdenv; };
# }).mkYarnModules args
# ).overrideAttrs (upstream: {
# # i guess the VM creates the output directory for the derivation? not sure.
# # and `mv` across the VM boundary breaks, too?
# # original errors:
# # - "mv: cannot create directory <$out>: File exists"
# # - "mv: failed to preserve ownership for"
# buildPhase = lib.replaceStrings
# [
# "mkdir $out"
# "mv "
# ]
# [
# "mkdir $out || true ; chmod +w deps/browserpass-extension-modules/package.json"
# "cp -Rv "
# ]
# upstream.buildPhase
# ;
# });
# };
# });
# };
# });
# 2023/07/31: upstreaming is blocked on ostree dep
# flatpak = prev.flatpak.overrideAttrs (upstream: {

View File

@ -1,8 +1,8 @@
{ stdenv
, fetchFromGitHub
, fetchFromGitea
, gnused
, mkYarnModules
, nodejs
, zip
}:
@ -25,7 +25,8 @@ let
# sha256 = "sha256-dSRZ2ToEOPhzHNvlG8qdewa7689gT8cNB7nXkN3/Avo=";
# };
browserpass-extension-yarn-modules = mkYarnModules {
inherit pname version;
inherit version;
pname = "${pname}-modules";
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
# yarnNix is auto-generated. to update: leave unset, then query the package deps and copy it out of the store.
@ -37,9 +38,20 @@ let
in stdenv.mkDerivation {
inherit pname version src;
nativeBuildInputs = [ nodejs zip ];
postPatch = ''
# dependencies are built separately: skip the yarn install
${gnused}/bin/sed -i /yarn\ install/d src/Makefile
# prettier, lessc, browserify are made available here via the modules,
# which are for the host (even the devDependencies are compiled for the host).
# but we can just run those via the build node.
#
# alternative would be to patchShebangs in the node_modules dir.
substituteInPlace src/Makefile \
--replace "yarn install" "true" \
--replace ' $(PRETTIER)' ' node $(PRETTIER)' \
--replace ' $(LESSC)' ' node $(LESSC)' \
--replace ' $(BROWSERIFY)' ' node $(BROWSERIFY)'
'';
preBuild = ''
@ -48,7 +60,7 @@ in stdenv.mkDerivation {
installPhase = ''
pushd firefox
${zip}/bin/zip -r $out ./*
zip -r $out ./*
popd
'';