Hack in a package.yaml instead of package.json
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...
This commit is contained in:
parent
f9bd128a02
commit
594e9bcbfd
10 changed files with 446 additions and 108 deletions
|
|
@ -5,7 +5,21 @@
|
|||
}: 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
|
||||
|
|
@ -21,7 +35,7 @@
|
|||
];
|
||||
in {
|
||||
package = pkgs.npmlock2nix.build {
|
||||
inherit buildInputs node_modules_attrs;
|
||||
inherit buildInputs prePatch node_modules_attrs;
|
||||
|
||||
src = cleanSource self;
|
||||
|
||||
|
|
@ -33,14 +47,22 @@ in {
|
|||
};
|
||||
|
||||
shell = pkgs.npmlock2nix.shell {
|
||||
inherit buildInputs node_modules_attrs;
|
||||
inherit buildInputs prePatch node_modules_attrs;
|
||||
|
||||
src = nix-filter {
|
||||
root = self;
|
||||
include = [
|
||||
"package.json"
|
||||
"package.yaml"
|
||||
"package-lock.json"
|
||||
];
|
||||
};
|
||||
|
||||
shellHook = ''
|
||||
if [ -e package.json ]; then
|
||||
unlink package.json
|
||||
fi
|
||||
|
||||
ln -s ${packageJson} package.json
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue