I5R3NQXJRWU6TEC2JSPZ7PRJBWYUYW3D5GTNY3SVA5LK7VZHLWKAC
365UXOJVR5ILJWRUXUIRNVIKJVR2TWJYHTU5JVDZ766X3EGRMPJAC
S5GPMMOWQ7AAMERJR4CAOU3QEINCLCSG5OAI4R2HJE3NF6DJSWRQC
LZIQRWBWLIKS3X55AJB3TYBLYIPYIO5OK3XI3J47K3ZNGHFTST5AC
CM2R5CCC4BV75P2MBA4X6OS2H6GQ5BAS34LSU6Y5X3SVKBAFT24AC
H3GYCX27WTONFBIJN7UIV26LJSCENQJC4XXIOEYINXJLEDGKYJJQC
OUNCR4WJNSBEHNLLJCD224ARD3UB7LR4VN7NZHHRJSAJOAZDPU5AC
BYZGRIFZY253OFK442SR6X743U4LAX4NLFBQ4XPKXEDPPXNNUM4AC
EVVP46IQ4U6JEDWVJ4D6KT77ABOMY7XKIO2ITX4DHJDRTGTYCUTQC
HXGZ6XUYMSCPRWR3DFD5BTNXTYPQDN4ST2WOVFX5GKD72RX5XLDAC
TXA66OLAOYNGEDRBC4SKWDZPLBZXUU7WHDIAYN4TXGEJR6WIJOIQC
ZED_DEBUG_LOG = "/tmp/zed.debug.log";
ZED_EMAIL_ADDR = [ user ];
ZED_EMAIL_PROG = "${pkgs.msmtp}/bin/msmtp";
ZED_EMAIL_OPTS = "@ADDRESS@";
ZED_DEBUG_LOG = "/tmp/zed.debug.log";
ZED_EMAIL_ADDR = [user];
ZED_EMAIL_PROG = "${pkgs.msmtp}/bin/msmtp";
ZED_EMAIL_OPTS = "@ADDRESS@";
(sources."npm-package-arg-6.1.1" // {
dependencies = [
sources."semver-5.7.1"
];
})
(sources."npm-registry-client-8.6.0" // {
dependencies = [
sources."semver-5.7.1"
];
})
(sources."npmconf-2.1.3" // {
dependencies = [
sources."mkdirp-0.5.6"
sources."once-1.3.3"
sources."semver-4.3.6"
];
})
(sources."npm-package-arg-6.1.1"
// {
dependencies = [
sources."semver-5.7.1"
];
})
(sources."npm-registry-client-8.6.0"
// {
dependencies = [
sources."semver-5.7.1"
];
})
(sources."npmconf-2.1.3"
// {
dependencies = [
sources."mkdirp-0.5.6"
sources."once-1.3.3"
sources."semver-4.3.6"
];
})
(sources."tar-6.1.13" // {
dependencies = [
sources."mkdirp-1.0.4"
];
})
(sources."temp-0.9.4" // {
dependencies = [
sources."mkdirp-0.5.6"
sources."rimraf-2.6.3"
];
})
(sources."tar-6.1.13"
// {
dependencies = [
sources."mkdirp-1.0.4"
];
})
(sources."temp-0.9.4"
// {
dependencies = [
sources."mkdirp-0.5.6"
sources."rimraf-2.6.3"
];
})
(sources."verror-1.10.0" // {
dependencies = [
sources."core-util-is-1.0.2"
];
})
(sources."vscode-css-languageservice-6.2.5" // {
dependencies = [
sources."vscode-languageserver-types-3.17.3"
];
})
(sources."vscode-html-languageservice-5.0.5" // {
dependencies = [
sources."vscode-languageserver-types-3.17.3"
];
})
(sources."vscode-json-languageservice-5.3.4" // {
dependencies = [
sources."jsonc-parser-3.2.0"
sources."vscode-languageserver-types-3.17.3"
];
})
(sources."verror-1.10.0"
// {
dependencies = [
sources."core-util-is-1.0.2"
];
})
(sources."vscode-css-languageservice-6.2.5"
// {
dependencies = [
sources."vscode-languageserver-types-3.17.3"
];
})
(sources."vscode-html-languageservice-5.0.5"
// {
dependencies = [
sources."vscode-languageserver-types-3.17.3"
];
})
(sources."vscode-json-languageservice-5.3.4"
// {
dependencies = [
sources."jsonc-parser-3.2.0"
sources."vscode-languageserver-types-3.17.3"
];
})
(sources."vscode-langservers-extracted-4.7.0" // {
dependencies = [
sources."jsonc-parser-3.2.0"
sources."typescript-4.9.5"
sources."vscode-jsonrpc-8.1.0"
sources."vscode-languageserver-8.1.0"
sources."vscode-languageserver-protocol-3.17.3"
sources."vscode-languageserver-types-3.17.3"
];
})
(sources."vscode-langservers-extracted-4.7.0"
// {
dependencies = [
sources."jsonc-parser-3.2.0"
sources."typescript-4.9.5"
sources."vscode-jsonrpc-8.1.0"
sources."vscode-languageserver-8.1.0"
sources."vscode-languageserver-protocol-3.17.3"
sources."vscode-languageserver-types-3.17.3"
];
})
+ (lib.concatMapStrings (dependency:
''
if [ ! -e "${dependency.packageName}" ]; then
${composePackage dependency}
fi
''
) dependencies)
+ (lib.concatMapStrings (
dependency: ''
if [ ! -e "${dependency.packageName}" ]; then
${composePackage dependency}
fi
''
)
dependencies)
pinpointDependencies = {dependencies, production}:
let
pinpointDependenciesFromPackageJSON = writeTextFile {
name = "pinpointDependencies.js";
text = ''
var fs = require('fs');
var path = require('path');
pinpointDependencies = {
dependencies,
production,
}: let
pinpointDependenciesFromPackageJSON = writeTextFile {
name = "pinpointDependencies.js";
text = ''
var fs = require('fs');
var path = require('path');
function resolveDependencyVersion(location, name) {
if(location == process.env['NIX_STORE']) {
return null;
} else {
var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json");
function resolveDependencyVersion(location, name) {
if(location == process.env['NIX_STORE']) {
return null;
} else {
var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json");
if(dependencyPackageObj.name == name) {
return dependencyPackageObj.version;
}
} else {
return resolveDependencyVersion(path.resolve(location, ".."), name);
}
}
}
if(dependencyPackageObj.name == name) {
return dependencyPackageObj.version;
}
} else {
return resolveDependencyVersion(path.resolve(location, ".."), name);
}
}
}
function replaceDependencies(dependencies) {
if(typeof dependencies == "object" && dependencies !== null) {
for(var dependency in dependencies) {
var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency);
function replaceDependencies(dependencies) {
if(typeof dependencies == "object" && dependencies !== null) {
for(var dependency in dependencies) {
var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency);
if(resolvedVersion === null) {
process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n");
} else {
dependencies[dependency] = resolvedVersion;
}
}
}
}
if(resolvedVersion === null) {
process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n");
} else {
dependencies[dependency] = resolvedVersion;
}
}
}
}
/* Pinpoint all dependencies */
replaceDependencies(packageObj.dependencies);
if(process.argv[2] == "development") {
replaceDependencies(packageObj.devDependencies);
}
replaceDependencies(packageObj.optionalDependencies);
/* Pinpoint all dependencies */
replaceDependencies(packageObj.dependencies);
if(process.argv[2] == "development") {
replaceDependencies(packageObj.devDependencies);
}
replaceDependencies(packageObj.optionalDependencies);
/* Write the fixed package.json file */
fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
'';
};
in
''
node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
/* Write the fixed package.json file */
fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
'';
};
in ''
node ${pinpointDependenciesFromPackageJSON} ${
if production
then "production"
else "development"
}
${lib.optionalString (dependencies != [])
''
if [ -d node_modules ]
then
cd node_modules
${lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
cd ..
fi
''}
'';
${lib.optionalString (dependencies != [])
''
if [ -d node_modules ]
then
cd node_modules
${lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
cd ..
fi
''}
'';
pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args:
''
if [ -d "${packageName}" ]
then
cd "${packageName}"
${pinpointDependencies { inherit dependencies production; }}
cd ..
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
fi
'';
pinpointDependenciesOfPackage = {
packageName,
dependencies ? [],
production ? true,
...
} @ args: ''
if [ -d "${packageName}" ]
then
cd "${packageName}"
${pinpointDependencies {inherit dependencies production;}}
cd ..
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
fi
'';
prepareAndInvokeNPM = {packageName, bypassCache, reconstructLock, npmFlags, production}:
let
forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
in
''
# Pinpoint the versions of all dependencies to the ones that are actually being used
echo "pinpointing versions of dependencies..."
source $pinpointDependenciesScriptPath
prepareAndInvokeNPM = {
packageName,
bypassCache,
reconstructLock,
npmFlags,
production,
}: let
forceOfflineFlag =
if bypassCache
then "--offline"
else "--registry http://www.example.com";
in ''
# Pinpoint the versions of all dependencies to the ones that are actually being used
echo "pinpointing versions of dependencies..."
source $pinpointDependenciesScriptPath
# Patch the shebangs of the bundled modules to prevent them from
# calling executables outside the Nix store as much as possible
patchShebangs .
# Patch the shebangs of the bundled modules to prevent them from
# calling executables outside the Nix store as much as possible
patchShebangs .
# Deploy the Node.js package by running npm install. Since the
# dependencies have been provided already by ourselves, it should not
# attempt to install them again, which is good, because we want to make
# it Nix's responsibility. If it needs to install any dependencies
# anyway (e.g. because the dependency parameters are
# incomplete/incorrect), it fails.
#
# The other responsibilities of NPM are kept -- version checks, build
# steps, postprocessing etc.
# Deploy the Node.js package by running npm install. Since the
# dependencies have been provided already by ourselves, it should not
# attempt to install them again, which is good, because we want to make
# it Nix's responsibility. If it needs to install any dependencies
# anyway (e.g. because the dependency parameters are
# incomplete/incorrect), it fails.
#
# The other responsibilities of NPM are kept -- version checks, build
# steps, postprocessing etc.
${lib.optionalString bypassCache ''
${lib.optionalString reconstructLock ''
if [ -f package-lock.json ]
then
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
echo "This will most likely result in version mismatches! We will remove the lock file and regenerate it!"
rm package-lock.json
else
echo "No package-lock.json file found, reconstructing..."
fi
${lib.optionalString bypassCache ''
${lib.optionalString reconstructLock ''
if [ -f package-lock.json ]
then
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
echo "This will most likely result in version mismatches! We will remove the lock file and regenerate it!"
rm package-lock.json
else
echo "No package-lock.json file found, reconstructing..."
fi
if [ "''${dontNpmInstall-}" != "1" ]
then
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
rm -f npm-shrinkwrap.json
if [ "''${dontNpmInstall-}" != "1" ]
then
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
rm -f npm-shrinkwrap.json
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} install
fi
'';
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} install
fi
'';
buildNodePackage =
{ name
, packageName
, version ? null
, dependencies ? []
, buildInputs ? []
, production ? true
, npmFlags ? ""
, dontNpmInstall ? false
, bypassCache ? false
, reconstructLock ? false
, preRebuild ? ""
, dontStrip ? true
, unpackPhase ? "true"
, buildPhase ? "true"
, meta ? {}
, ... }@args:
let
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ];
in
buildNodePackage = {
name,
packageName,
version ? null,
dependencies ? [],
buildInputs ? [],
production ? true,
npmFlags ? "",
dontNpmInstall ? false,
bypassCache ? false,
reconstructLock ? false,
preRebuild ? "",
dontStrip ? true,
unpackPhase ? "true",
buildPhase ? "true",
meta ? {},
...
} @ args: let
extraArgs = removeAttrs args ["name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta"];
in
name = "${name}${if version == null then "" else "-${version}"}";
buildInputs = [ tarWrapper python nodejs ]
++ lib.optional (stdenv.isLinux) utillinux
++ lib.optional (stdenv.isDarwin) libtool
++ buildInputs;
name = "${name}${
if version == null
then ""
else "-${version}"
}";
buildInputs =
[tarWrapper python nodejs]
++ lib.optional (stdenv.isLinux) utillinux
++ lib.optional (stdenv.isDarwin) libtool
++ buildInputs;
inherit dontStrip; # Stripping may fail a build for some package deployments
inherit dontNpmInstall preRebuild unpackPhase buildPhase;
inherit dontStrip; # Stripping may fail a build for some package deployments
inherit dontNpmInstall preRebuild unpackPhase buildPhase;
# Create symlink to the deployed executable folder, if applicable
if [ -d "$out/lib/node_modules/.bin" ]
then
ln -s $out/lib/node_modules/.bin $out/bin
# Create symlink to the deployed executable folder, if applicable
if [ -d "$out/lib/node_modules/.bin" ]
then
ln -s $out/lib/node_modules/.bin $out/bin
# Patch the shebang lines of all the executables
ls $out/bin/* | while read i
do
file="$(readlink -f "$i")"
chmod u+rwx "$file"
patchShebangs "$file"
done
fi
# Patch the shebang lines of all the executables
ls $out/bin/* | while read i
do
file="$(readlink -f "$i")"
chmod u+rwx "$file"
patchShebangs "$file"
done
fi
# Create symlinks to the deployed manual page folders, if applicable
if [ -d "$out/lib/node_modules/${packageName}/man" ]
then
mkdir -p $out/share
for dir in "$out/lib/node_modules/${packageName}/man/"*
do
mkdir -p $out/share/man/$(basename "$dir")
for page in "$dir"/*
do
ln -s $page $out/share/man/$(basename "$dir")
done
done
fi
# Create symlinks to the deployed manual page folders, if applicable
if [ -d "$out/lib/node_modules/${packageName}/man" ]
then
mkdir -p $out/share
for dir in "$out/lib/node_modules/${packageName}/man/"*
do
mkdir -p $out/share/man/$(basename "$dir")
for page in "$dir"/*
do
ln -s $page $out/share/man/$(basename "$dir")
done
done
fi
buildNodeDependencies =
{ name
, packageName
, version ? null
, src
, dependencies ? []
, buildInputs ? []
, production ? true
, npmFlags ? ""
, dontNpmInstall ? false
, bypassCache ? false
, reconstructLock ? false
, dontStrip ? true
, unpackPhase ? "true"
, buildPhase ? "true"
, ... }@args:
buildNodeDependencies = {
name,
packageName,
version ? null,
src,
dependencies ? [],
buildInputs ? [],
production ? true,
npmFlags ? "",
dontNpmInstall ? false,
bypassCache ? false,
reconstructLock ? false,
dontStrip ? true,
unpackPhase ? "true",
buildPhase ? "true",
...
} @ args: let
extraArgs = removeAttrs args ["name" "dependencies" "buildInputs"];
in
stdenv.mkDerivation ({
name = "node-dependencies-${name}${
if version == null
then ""
else "-${version}"
}";
let
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
in
stdenv.mkDerivation ({
name = "node-dependencies-${name}${if version == null then "" else "-${version}"}";
buildInputs = [ tarWrapper python nodejs ]
buildInputs =
[tarWrapper python nodejs]
buildNodeShell =
{ name
, packageName
, version ? null
, src
, dependencies ? []
, buildInputs ? []
, production ? true
, npmFlags ? ""
, dontNpmInstall ? false
, bypassCache ? false
, reconstructLock ? false
, dontStrip ? true
, unpackPhase ? "true"
, buildPhase ? "true"
, ... }@args:
let
nodeDependencies = buildNodeDependencies args;
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "unpackPhase" "buildPhase" ];
in
buildNodeShell = {
name,
packageName,
version ? null,
src,
dependencies ? [],
buildInputs ? [],
production ? true,
npmFlags ? "",
dontNpmInstall ? false,
bypassCache ? false,
reconstructLock ? false,
dontStrip ? true,
unpackPhase ? "true",
buildPhase ? "true",
...
} @ args: let
nodeDependencies = buildNodeDependencies args;
extraArgs = removeAttrs args ["name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "unpackPhase" "buildPhase"];
in
buildInputs = [ python nodejs ] ++ lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
buildCommand = ''
mkdir -p $out/bin
cat > $out/bin/shell <<EOF
#! ${stdenv.shell} -e
$shellHook
exec ${stdenv.shell}
EOF
chmod +x $out/bin/shell
'';
buildInputs = [python nodejs] ++ lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
buildCommand = ''
mkdir -p $out/bin
cat > $out/bin/shell <<EOF
#! ${stdenv.shell} -e
$shellHook
exec ${stdenv.shell}
EOF
chmod +x $out/bin/shell
'';
# Provide the dependencies in a development shell through the NODE_PATH environment variable
inherit nodeDependencies;
shellHook = lib.optionalString (dependencies != []) ''
export NODE_PATH=${nodeDependencies}/lib/node_modules
export PATH="${nodeDependencies}/bin:$PATH"
'';
} // extraArgs);
in
{
# Provide the dependencies in a development shell through the NODE_PATH environment variable
inherit nodeDependencies;
shellHook = lib.optionalString (dependencies != []) ''
export NODE_PATH=${nodeDependencies}/lib/node_modules
export PATH="${nodeDependencies}/bin:$PATH"
'';
}
// extraArgs);
in {
in pkgs.mkShellNoCC {
packages = with pkgs; [deploy-rs age decryptSecrets encryptSecrets];
};
in
pkgs.mkShellNoCC {
packages = with pkgs; [deploy-rs age decryptSecrets encryptSecrets];
};