This repository has been archived on 2022-09-16. You can view files and clone it, but cannot push or open issues or pull requests.
tlaternet-templates/nix/package.nix

75 lines
1.3 KiB
Nix
Raw Normal View History

2022-08-01 21:14:18 +01:00
{
self,
nix-filter,
pkgs,
}: let
2022-08-03 01:47:50 +01:00
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;
'';
2022-08-01 21:14:18 +01:00
node_modules_attrs = {
packageJson = "${packageJson}";
2022-08-01 21:14:18 +01:00
# 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;
2022-08-01 21:14:18 +01:00
2022-08-03 01:47:50 +01:00
src = cleanSource self;
2022-08-01 21:14:18 +01:00
buildCommands = ["npm run build-dist"];
installPhase = ''
cp -r dist $out/
'';
};
shell = pkgs.npmlock2nix.shell {
2022-08-06 18:04:38 +01:00
inherit prePatch node_modules_attrs;
buildInputs =
buildInputs
++ (with pkgs; [
clang-tools
]);
2022-08-01 21:14:18 +01:00
2022-08-03 01:47:50 +01:00
src = nix-filter {
2022-08-01 21:14:18 +01:00
root = self;
include = [
"package.yaml"
2022-08-01 21:14:18 +01:00
"package-lock.json"
];
};
shellHook = ''
if [ -e package.json ]; then
unlink package.json
fi
ln -s ${packageJson} package.json
'';
2022-08-01 21:14:18 +01:00
};
}