Tristan Daniël Maat
594e9bcbfd
json is just incredibly tedious to use for this, especially because of lack of comments. Upstream has been informed of this many times apparently, npm won't change it. Just hack it downstream. npm will never get better, will it...
69 lines
1.2 KiB
Nix
69 lines
1.2 KiB
Nix
{
|
|
self,
|
|
nix-filter,
|
|
pkgs,
|
|
}: let
|
|
inherit (pkgs.lib) cleanSource;
|
|
|
|
packageJson =
|
|
pkgs.runCommand "package.json" {
|
|
nativeBuildInputs = with pkgs; [yj];
|
|
src = "";
|
|
} ''
|
|
cat ${self}/package.yaml | yj > $out
|
|
'';
|
|
|
|
prePatch = ''
|
|
ln -s ${packageJson} package.json;
|
|
'';
|
|
|
|
node_modules_attrs = {
|
|
packageJson = "${packageJson}";
|
|
|
|
# Dependencies that should be available in the node build
|
|
buildInputs = with pkgs; [
|
|
pkg-config
|
|
python3
|
|
vips
|
|
glib
|
|
];
|
|
};
|
|
|
|
# Dependencies that should be available outside of the node build
|
|
buildInputs = with pkgs; [
|
|
util-linux
|
|
];
|
|
in {
|
|
package = pkgs.npmlock2nix.build {
|
|
inherit buildInputs prePatch node_modules_attrs;
|
|
|
|
src = cleanSource self;
|
|
|
|
buildCommands = ["npm run build-dist"];
|
|
|
|
installPhase = ''
|
|
cp -r dist $out/
|
|
'';
|
|
};
|
|
|
|
shell = pkgs.npmlock2nix.shell {
|
|
inherit buildInputs prePatch node_modules_attrs;
|
|
|
|
src = nix-filter {
|
|
root = self;
|
|
include = [
|
|
"package.yaml"
|
|
"package-lock.json"
|
|
];
|
|
};
|
|
|
|
shellHook = ''
|
|
if [ -e package.json ]; then
|
|
unlink package.json
|
|
fi
|
|
|
|
ln -s ${packageJson} package.json
|
|
'';
|
|
};
|
|
}
|