Skip to content

Commit

Permalink
Fixup mkYarnPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
vkleen committed Jan 7, 2025
1 parent a9dcbb6 commit ca7fbbb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 27 deletions.
39 changes: 31 additions & 8 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 21 additions & 19 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs;
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;
};
outputs = inputs@{ self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let
Expand All @@ -13,27 +13,29 @@
name = "${pname}-${version}";
nativeBuildInputs = [ pkgs.makeWrapper ];
src = self;
packageJSON = src + "/package.json";
yarnNix = src + "/yarn.nix";
packageJSON = ./package.json;

offlineCache = pkgs.fetchYarnDeps {
yarnLock = ./yarn.lock;
sha256 = "sha256-8dO70wELOd1Lec/jL7CRQzuxkWzvkkC3sD4cqCKGg4Q=";
};
packageResolutions = {
"@matrix-org/matrix-sdk-crypto-nodejs" =
"${pkgs.matrix-sdk-crypto-nodejs}/lib/node_modules/@matrix-org/matrix-sdk-crypto-nodejs";
};

buildPhase = ''
yarn --offline build
runHook preBuild
yarn build
runHook postBuild
'';
preInstall = ''
mkdir -p $out/bin $out/node_modules $out/config
cp -r node_modules/node-purple $out/node_modules/node-purple
cp -r deps/matrix-bifrost/lib $out/lib
cp deps/matrix-bifrost/package.json deps/matrix-bifrost/yarn.lock $out
cp deps/matrix-bifrost/config/config.schema.yaml $out/config/
cat > $out/bin/matrix-bifrost <<EOF
#!${pkgs.stdenv.shell}
exec ${pkgs.nodejs}/bin/node $out/lib/Program.js "\$@"
EOF
chmod +x $out/bin/matrix-bifrost
wrapProgram $out/bin/matrix-bifrost \
--set NODE_PATH "$out/libexec/matrix-bifrost/node_modules"

postInstall = ''
makeWrapper '${pkgs.nodejs}/bin/node' "$out/bin/matrix-bifrost" --add-flags \
"$out/libexec/matrix-bifrost/deps/matrix-bifrost/lib/Program.js"
'';
distPhase = ":";
publishBinsFor = [ "matrix-bifrost" ];

doDist = false;
};
};
defaultPackage = packages.matrix-bifrost;
Expand Down

0 comments on commit ca7fbbb

Please sign in to comment.