examples(nodejs): add example nodejs-no-lock

This commit is contained in:
DavHau 2023-07-08 13:03:12 +02:00
parent 6159824a2a
commit b38c4d9a2f
4 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,2 @@
let message: string = 'Hello, World!';
console.log(message);

View File

@ -0,0 +1,46 @@
{
lib,
config,
...
}: let
l = lib // builtins;
system = config.deps.stdenv.system;
in {
imports = [
../../drv-parts/nodejs-package-json
../../drv-parts/nodejs-granular
];
mkDerivation = {
src = lib.cleanSource ./.;
checkPhase = ''
./app.js | ${config.deps.gnugrep}/bin/grep -q "Hello, World!"
'';
doCheck = true;
};
nodejs-granular = {
buildScript = ''
tsc ./app.ts
mv app.js app.js.tmp
echo "#!${config.deps.nodejs}/bin/node" > app.js
cat app.js.tmp >> app.js
chmod +x ./app.js
patchShebangs .
'';
};
deps = {nixpkgs, ...}: {
inherit
(nixpkgs)
gnugrep
stdenv
;
};
name = l.mkForce "app";
version = l.mkForce "0.0.0";
lock.lockFileRel =
l.mkForce "/v1/nix/modules/drvs/nodejs-no-lock/lock-${system}.json";
}

View File

@ -0,0 +1,33 @@
{
"package-lock": {
"name": "tmp.BeJiEGlOfL",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"dependencies": {
"typescript": "^5.1.6"
}
},
"node_modules/typescript": {
"version": "5.1.6",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz",
"integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
}
},
"dependencies": {
"typescript": {
"version": "5.1.6",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz",
"integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA=="
}
}
}
}

View File

@ -0,0 +1,7 @@
{
"name": "app",
"dependencies": {
"typescript": "^5.1.6"
},
"bin": "app.js"
}