feat: attempted to install prettierd
This commit is contained in:
parent
85cc99140c
commit
79455a6e29
41
.pnpm-debug.log
Normal file
41
.pnpm-debug.log
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"0 debug pnpm:scope": {
|
||||||
|
"selected": 1
|
||||||
|
},
|
||||||
|
"1 debug pnpm:package-manifest": {
|
||||||
|
"initial": {},
|
||||||
|
"prefix": "/home/adrielus/Projects/nixos-config"
|
||||||
|
},
|
||||||
|
"2 debug pnpm:context": {
|
||||||
|
"currentLockfileExists": false,
|
||||||
|
"storeDir": "/home/adrielus/.pnpm-store/v3",
|
||||||
|
"virtualStoreDir": "/home/adrielus/Projects/nixos-config/node_modules/.pnpm"
|
||||||
|
},
|
||||||
|
"3 debug pnpm:stage": {
|
||||||
|
"prefix": "/home/adrielus/Projects/nixos-config",
|
||||||
|
"stage": "resolution_started"
|
||||||
|
},
|
||||||
|
"4 debug pnpm:update-check": {
|
||||||
|
"currentVersion": "6.22.2",
|
||||||
|
"latestVersion": "6.29.1"
|
||||||
|
},
|
||||||
|
"5 error pnpm": {
|
||||||
|
"code": "ERR_PNPM_FETCH_404",
|
||||||
|
"hint": "prettierd is not in the npm registry, or you have no permission to fetch it.\n\nAn authorization header was used: Bearer 265b[hidden]",
|
||||||
|
"request": {
|
||||||
|
"authHeaderValue": "Bearer 265ba49b-cc14-402e-8c57-e070a7bc1997",
|
||||||
|
"url": "https://registry.npmjs.org/prettierd"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"size": 0
|
||||||
|
},
|
||||||
|
"pkgName": "prettierd",
|
||||||
|
"pkgsStack": [],
|
||||||
|
"err": {
|
||||||
|
"name": "pnpm",
|
||||||
|
"message": "GET https://registry.npmjs.org/prettierd: Not Found - 404",
|
||||||
|
"code": "ERR_PNPM_FETCH_404",
|
||||||
|
"stack": "pnpm: GET https://registry.npmjs.org/prettierd: Not Found - 404\n at RetryOperation._fn (/nix/store/kh5rqvj2l82gznih1b5isc43mk2dnh6j-pnpm-6.22.2/lib/node_modules/pnpm/dist/pnpm.cjs:84952:18)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,9 +2,19 @@ local mapSilent = require("my.keymaps").mapSilent
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.setup()
|
local bindings = {
|
||||||
-- Open files with control + P
|
-- Open files with control + P
|
||||||
mapSilent('n', '<c-P>', "<cmd>lua require('fzf-lua').files()<CR>")
|
files = "<c-P>",
|
||||||
|
-- See diagnostics with space + d
|
||||||
|
lsp_document_diagnostics = "<space>d",
|
||||||
|
lsp_workspace_diagnostics = "<space>D"
|
||||||
|
}
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
|
for action, keybind in pairs(bindings) do
|
||||||
|
-- Maps the keybind to the action
|
||||||
|
mapSilent('n', keybind, "<cmd>lua require('fzf-lua')." .. action .. "()<CR>")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -84,16 +84,29 @@ function M.setup()
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local efmLanguages = {
|
||||||
|
typescript = {
|
||||||
|
formatCommand = 'prettierd "${INPUT}"',
|
||||||
|
formatStdin = true,
|
||||||
|
env = {string.format('PRETTIERD_DEFAULT_CONFIG=%s', vim.fn.expand('~/.config/nvim/utils/linter-config/.prettierrc.json'))}
|
||||||
|
},
|
||||||
|
lua = {{formatCommand = formatLua, formatStdin = true}}
|
||||||
|
}
|
||||||
|
|
||||||
-- Setup auto-formatting
|
-- Setup auto-formatting
|
||||||
require"lspconfig".efm.setup {
|
require"lspconfig".efm.setup {
|
||||||
init_options = {documentFormatting = true},
|
init_options = {documentFormatting = true},
|
||||||
filetypes = {"lua"},
|
filetypes = {"lua", "ts", "js", "tsx", "jsx"},
|
||||||
settings = {rootMarkers = {".git/"}, languages = {lua = {{formatCommand = formatLua, formatStdin = true}}}}
|
settings = {rootMarkers = {".git/"}, languages = efmLanguages}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Auto format lua stuff
|
local autoFormatOn = {lua = 100, purs = 1000, nix = 100, js = 100, ts = 100, tsx = 100, jsx = 100}
|
||||||
cmd("autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100)")
|
|
||||||
-- cmd("autocmd BufWritePre nix vim.lsp.buf.formatting_sync(nil, 100)")
|
-- Auto format
|
||||||
|
for extension, timeout in pairs(autoFormatOn) do
|
||||||
|
-- I wonder if this could be done in a single glob pattern
|
||||||
|
cmd("autocmd BufWritePre *." .. extension .. " lua vim.lsp.buf.formatting_sync(nil, " .. timeout .. ")")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -1,26 +1,23 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
let
|
let
|
||||||
|
# config-nvim = "/etc/nixos/configuration/dotfiles/neovim";
|
||||||
config-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
config-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
||||||
name = "config-nvim";
|
name = "config-nvim";
|
||||||
src = ../../dotfiles/neovim;
|
src = ../../dotfiles/neovim;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
home-manager.users.adrielus.programs.neovim = {
|
home-manager.users.adrielus.programs.neovim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.neovim-nightly;
|
package = pkgs.neovim-nightly;
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
let g:disable_paq = v:true
|
|
||||||
luafile ${config-nvim}/init.lua
|
luafile ${config-nvim}/init.lua
|
||||||
'';
|
'';
|
||||||
|
|
||||||
extraPackages = with pkgs; [
|
extraPackages = with pkgs; [
|
||||||
fzf # Required by lua-fzf
|
|
||||||
|
|
||||||
# Language servers
|
# Language servers
|
||||||
nodePackages.typescript # typescript
|
nodePackages.typescript-language-server # typescript
|
||||||
easy-purescript-nix.purescript-language-server # purescript
|
easy-purescript-nix.purescript-language-server # purescript
|
||||||
sumneko-lua-language-server # lua
|
sumneko-lua-language-server # lua
|
||||||
efm-langserver # auto-formatting
|
efm-langserver # auto-formatting
|
||||||
|
@ -28,6 +25,11 @@ in
|
||||||
|
|
||||||
# Formatters
|
# Formatters
|
||||||
luaformatter # lua
|
luaformatter # lua
|
||||||
|
nodePackages.prettierd # prettier but faster
|
||||||
|
|
||||||
|
# Others
|
||||||
|
fzf # Required by lua-fzf
|
||||||
|
nodePackages.typescript # typescript language
|
||||||
];
|
];
|
||||||
|
|
||||||
plugins = with pkgs.vimPlugins;
|
plugins = with pkgs.vimPlugins;
|
||||||
|
@ -39,7 +41,7 @@ in
|
||||||
fzf-lua # fuzzy search for say opening files
|
fzf-lua # fuzzy search for say opening files
|
||||||
purescript-vim # purescript syntax highlighting
|
purescript-vim # purescript syntax highlighting
|
||||||
nvim-comment # allows toggling line-comments
|
nvim-comment # allows toggling line-comments
|
||||||
nvim-treesitter # use treesitter for syntax highlighting
|
nvim-treesitter # use treesitter for syntax highlighting
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
[
|
|
||||||
"pnpm",
|
|
||||||
"tsdx",
|
|
||||||
"mklicense",
|
|
||||||
"preact-cli",
|
|
||||||
"create-next-app",
|
|
||||||
"create-snowpack-app",
|
|
||||||
"bower"
|
|
||||||
]
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,9 @@
|
||||||
{ pkgs, ... }: {
|
{ pkgs, ... }: {
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
(import ./tweakSources.nix)
|
(import ./tweakSources.nix)
|
||||||
|
(import ./npm.nix)
|
||||||
|
|
||||||
# I hope this works
|
# I hope this works (spoiler: it did not)
|
||||||
(import ./edopro)
|
(import ./edopro)
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
6
modules/overlays/npm.nix
Normal file
6
modules/overlays/npm.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
self: super:
|
||||||
|
let customPackages = pkgs.callPackage ./npm { };
|
||||||
|
in with self; {
|
||||||
|
# Faster prettier for editors
|
||||||
|
nodePackages.prettierd = customPackages."@fsouza/prettierd";
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
# This file has been generated by node2nix 1.8.0. Do not edit!
|
# This file has been generated by node2nix 1.9.0. Do not edit!
|
||||||
|
|
||||||
{pkgs ? import <nixpkgs> {
|
{pkgs ? import <nixpkgs> {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
nodeEnv = import ./node-env.nix {
|
nodeEnv = import ./node-env.nix {
|
||||||
inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile;
|
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
|
||||||
inherit nodejs;
|
inherit pkgs nodejs;
|
||||||
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
|
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
import ./node-packages.nix {
|
import ./node-packages.nix {
|
||||||
inherit (pkgs) fetchurl fetchgit;
|
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
|
||||||
inherit nodeEnv;
|
inherit nodeEnv;
|
||||||
}
|
}
|
|
@ -1,8 +1,11 @@
|
||||||
# This file originates from node2nix
|
# This file originates from node2nix
|
||||||
|
|
||||||
{stdenv, nodejs, python2, utillinux, libtool, runCommand, writeTextFile}:
|
{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
# Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master
|
||||||
|
utillinux = if pkgs ? utillinux then pkgs.utillinux else pkgs.util-linux;
|
||||||
|
|
||||||
python = if nodejs ? python then nodejs.python else python2;
|
python = if nodejs ? python then nodejs.python else python2;
|
||||||
|
|
||||||
# Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise
|
# Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise
|
||||||
|
@ -37,36 +40,22 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
includeDependencies = {dependencies}:
|
# Common shell logic
|
||||||
stdenv.lib.optionalString (dependencies != [])
|
installPackage = writeShellScript "install-package" ''
|
||||||
(stdenv.lib.concatMapStrings (dependency:
|
installPackage() {
|
||||||
''
|
local packageName=$1 src=$2
|
||||||
# Bundle the dependencies of the package
|
|
||||||
mkdir -p node_modules
|
|
||||||
cd node_modules
|
|
||||||
|
|
||||||
# Only include dependencies if they don't exist. They may also be bundled in the package.
|
local strippedName
|
||||||
if [ ! -e "${dependency.name}" ]
|
|
||||||
then
|
|
||||||
${composePackage dependency}
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd ..
|
local DIR=$PWD
|
||||||
''
|
|
||||||
) dependencies);
|
|
||||||
|
|
||||||
# Recursively composes the dependencies of a package
|
|
||||||
composePackage = { name, packageName, src, dependencies ? [], ... }@args:
|
|
||||||
builtins.addErrorContext "while evaluating node package '${packageName}'" ''
|
|
||||||
DIR=$(pwd)
|
|
||||||
cd $TMPDIR
|
cd $TMPDIR
|
||||||
|
|
||||||
unpackFile ${src}
|
unpackFile $src
|
||||||
|
|
||||||
# Make the base dir in which the target dependency resides first
|
# Make the base dir in which the target dependency resides first
|
||||||
mkdir -p "$(dirname "$DIR/${packageName}")"
|
mkdir -p "$(dirname "$DIR/$packageName")"
|
||||||
|
|
||||||
if [ -f "${src}" ]
|
if [ -f "$src" ]
|
||||||
then
|
then
|
||||||
# Figure out what directory has been unpacked
|
# Figure out what directory has been unpacked
|
||||||
packageDir="$(find . -maxdepth 1 -type d | tail -1)"
|
packageDir="$(find . -maxdepth 1 -type d | tail -1)"
|
||||||
|
@ -76,31 +65,56 @@ let
|
||||||
chmod -R u+w "$packageDir"
|
chmod -R u+w "$packageDir"
|
||||||
|
|
||||||
# Move the extracted tarball into the output folder
|
# Move the extracted tarball into the output folder
|
||||||
mv "$packageDir" "$DIR/${packageName}"
|
mv "$packageDir" "$DIR/$packageName"
|
||||||
elif [ -d "${src}" ]
|
elif [ -d "$src" ]
|
||||||
then
|
then
|
||||||
# Get a stripped name (without hash) of the source directory.
|
# Get a stripped name (without hash) of the source directory.
|
||||||
# On old nixpkgs it's already set internally.
|
# On old nixpkgs it's already set internally.
|
||||||
if [ -z "$strippedName" ]
|
if [ -z "$strippedName" ]
|
||||||
then
|
then
|
||||||
strippedName="$(stripHash ${src})"
|
strippedName="$(stripHash $src)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore write permissions to make building work
|
# Restore write permissions to make building work
|
||||||
chmod -R u+w "$strippedName"
|
chmod -R u+w "$strippedName"
|
||||||
|
|
||||||
# Move the extracted directory into the output folder
|
# Move the extracted directory into the output folder
|
||||||
mv "$strippedName" "$DIR/${packageName}"
|
mv "$strippedName" "$DIR/$packageName"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unset the stripped name to not confuse the next unpack step
|
# Change to the package directory to install dependencies
|
||||||
unset strippedName
|
cd "$DIR/$packageName"
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
# Include the dependencies of the package
|
# Bundle the dependencies of the package
|
||||||
cd "$DIR/${packageName}"
|
#
|
||||||
|
# Only include dependencies if they don't exist. They may also be bundled in the package.
|
||||||
|
includeDependencies = {dependencies}:
|
||||||
|
lib.optionalString (dependencies != []) (
|
||||||
|
''
|
||||||
|
mkdir -p node_modules
|
||||||
|
cd node_modules
|
||||||
|
''
|
||||||
|
+ (lib.concatMapStrings (dependency:
|
||||||
|
''
|
||||||
|
if [ ! -e "${dependency.name}" ]; then
|
||||||
|
${composePackage dependency}
|
||||||
|
fi
|
||||||
|
''
|
||||||
|
) dependencies)
|
||||||
|
+ ''
|
||||||
|
cd ..
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
|
# Recursively composes the dependencies of a package
|
||||||
|
composePackage = { name, packageName, src, dependencies ? [], ... }@args:
|
||||||
|
builtins.addErrorContext "while evaluating node package '${packageName}'" ''
|
||||||
|
installPackage "${packageName}" "${src}"
|
||||||
${includeDependencies { inherit dependencies; }}
|
${includeDependencies { inherit dependencies; }}
|
||||||
cd ..
|
cd ..
|
||||||
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
pinpointDependencies = {dependencies, production}:
|
pinpointDependencies = {dependencies, production}:
|
||||||
|
@ -161,12 +175,12 @@ let
|
||||||
''
|
''
|
||||||
node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
|
node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
|
||||||
|
|
||||||
${stdenv.lib.optionalString (dependencies != [])
|
${lib.optionalString (dependencies != [])
|
||||||
''
|
''
|
||||||
if [ -d node_modules ]
|
if [ -d node_modules ]
|
||||||
then
|
then
|
||||||
cd node_modules
|
cd node_modules
|
||||||
${stdenv.lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
|
${lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
''}
|
''}
|
||||||
|
@ -183,7 +197,7 @@ let
|
||||||
cd "${packageName}"
|
cd "${packageName}"
|
||||||
${pinpointDependencies { inherit dependencies production; }}
|
${pinpointDependencies { inherit dependencies production; }}
|
||||||
cd ..
|
cd ..
|
||||||
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -242,8 +256,8 @@ let
|
||||||
if(fs.existsSync("./package-lock.json")) {
|
if(fs.existsSync("./package-lock.json")) {
|
||||||
var packageLock = JSON.parse(fs.readFileSync("./package-lock.json"));
|
var packageLock = JSON.parse(fs.readFileSync("./package-lock.json"));
|
||||||
|
|
||||||
if(packageLock.lockfileVersion !== 1) {
|
if(![1, 2].includes(packageLock.lockfileVersion)) {
|
||||||
process.stderr.write("Sorry, I only understand lock file version 1!\n");
|
process.stderr.write("Sorry, I only understand lock file versions 1 and 2!\n");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,8 +358,8 @@ let
|
||||||
cd "${packageName}"
|
cd "${packageName}"
|
||||||
runHook preRebuild
|
runHook preRebuild
|
||||||
|
|
||||||
${stdenv.lib.optionalString bypassCache ''
|
${lib.optionalString bypassCache ''
|
||||||
${stdenv.lib.optionalString reconstructLock ''
|
${lib.optionalString reconstructLock ''
|
||||||
if [ -f package-lock.json ]
|
if [ -f package-lock.json ]
|
||||||
then
|
then
|
||||||
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
|
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
|
||||||
|
@ -361,14 +375,14 @@ let
|
||||||
node ${addIntegrityFieldsScript}
|
node ${addIntegrityFieldsScript}
|
||||||
''}
|
''}
|
||||||
|
|
||||||
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} rebuild
|
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} rebuild
|
||||||
|
|
||||||
if [ "''${dontNpmInstall-}" != "1" ]
|
if [ "''${dontNpmInstall-}" != "1" ]
|
||||||
then
|
then
|
||||||
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
|
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
|
||||||
rm -f npm-shrinkwrap.json
|
rm -f npm-shrinkwrap.json
|
||||||
|
|
||||||
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
|
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} install
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -388,16 +402,17 @@ let
|
||||||
, dontStrip ? true
|
, dontStrip ? true
|
||||||
, unpackPhase ? "true"
|
, unpackPhase ? "true"
|
||||||
, buildPhase ? "true"
|
, buildPhase ? "true"
|
||||||
|
, meta ? {}
|
||||||
, ... }@args:
|
, ... }@args:
|
||||||
|
|
||||||
let
|
let
|
||||||
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" ];
|
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ];
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation ({
|
stdenv.mkDerivation ({
|
||||||
name = "node_${name}-${version}";
|
name = "${name}-${version}";
|
||||||
buildInputs = [ tarWrapper python nodejs ]
|
buildInputs = [ tarWrapper python nodejs ]
|
||||||
++ stdenv.lib.optional (stdenv.isLinux) utillinux
|
++ lib.optional (stdenv.isLinux) utillinux
|
||||||
++ stdenv.lib.optional (stdenv.isDarwin) libtool
|
++ lib.optional (stdenv.isDarwin) libtool
|
||||||
++ buildInputs;
|
++ buildInputs;
|
||||||
|
|
||||||
inherit nodejs;
|
inherit nodejs;
|
||||||
|
@ -411,6 +426,8 @@ let
|
||||||
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
|
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
source ${installPackage}
|
||||||
|
|
||||||
# Create and enter a root node_modules/ folder
|
# Create and enter a root node_modules/ folder
|
||||||
mkdir -p $out/lib/node_modules
|
mkdir -p $out/lib/node_modules
|
||||||
cd $out/lib/node_modules
|
cd $out/lib/node_modules
|
||||||
|
@ -443,8 +460,83 @@ let
|
||||||
# Run post install hook, if provided
|
# Run post install hook, if provided
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
# default to Node.js' platforms
|
||||||
|
platforms = nodejs.meta.platforms;
|
||||||
|
} // meta;
|
||||||
} // extraArgs);
|
} // extraArgs);
|
||||||
|
|
||||||
|
# Builds a node environment (a node_modules folder and a set of binaries)
|
||||||
|
buildNodeDependencies =
|
||||||
|
{ name
|
||||||
|
, packageName
|
||||||
|
, version
|
||||||
|
, 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}-${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 unpackPhase buildPhase;
|
||||||
|
|
||||||
|
includeScript = includeDependencies { inherit dependencies; };
|
||||||
|
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
|
||||||
|
|
||||||
|
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
source ${installPackage}
|
||||||
|
|
||||||
|
mkdir -p $out/${packageName}
|
||||||
|
cd $out/${packageName}
|
||||||
|
|
||||||
|
source $includeScriptPath
|
||||||
|
|
||||||
|
# Create fake package.json to make the npm commands work properly
|
||||||
|
cp ${src}/package.json .
|
||||||
|
chmod 644 package.json
|
||||||
|
${lib.optionalString bypassCache ''
|
||||||
|
if [ -f ${src}/package-lock.json ]
|
||||||
|
then
|
||||||
|
cp ${src}/package-lock.json .
|
||||||
|
fi
|
||||||
|
''}
|
||||||
|
|
||||||
|
# Go to the parent folder to make sure that all packages are pinpointed
|
||||||
|
cd ..
|
||||||
|
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
||||||
|
|
||||||
|
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
|
||||||
|
|
||||||
|
# Expose the executables that were installed
|
||||||
|
cd ..
|
||||||
|
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
||||||
|
|
||||||
|
mv ${packageName} lib
|
||||||
|
ln -s $out/lib/node_modules/.bin $out/bin
|
||||||
|
'';
|
||||||
|
} // extraArgs);
|
||||||
|
|
||||||
# Builds a development shell
|
# Builds a development shell
|
||||||
buildNodeShell =
|
buildNodeShell =
|
||||||
{ name
|
{ name
|
||||||
|
@ -464,59 +556,12 @@ let
|
||||||
, ... }@args:
|
, ... }@args:
|
||||||
|
|
||||||
let
|
let
|
||||||
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
|
nodeDependencies = buildNodeDependencies args;
|
||||||
|
|
||||||
nodeDependencies = stdenv.mkDerivation ({
|
|
||||||
name = "node-dependencies-${name}-${version}";
|
|
||||||
|
|
||||||
buildInputs = [ tarWrapper python nodejs ]
|
|
||||||
++ stdenv.lib.optional (stdenv.isLinux) utillinux
|
|
||||||
++ stdenv.lib.optional (stdenv.isDarwin) libtool
|
|
||||||
++ buildInputs;
|
|
||||||
|
|
||||||
inherit dontStrip; # Stripping may fail a build for some package deployments
|
|
||||||
inherit dontNpmInstall unpackPhase buildPhase;
|
|
||||||
|
|
||||||
includeScript = includeDependencies { inherit dependencies; };
|
|
||||||
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
|
|
||||||
|
|
||||||
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/${packageName}
|
|
||||||
cd $out/${packageName}
|
|
||||||
|
|
||||||
source $includeScriptPath
|
|
||||||
|
|
||||||
# Create fake package.json to make the npm commands work properly
|
|
||||||
cp ${src}/package.json .
|
|
||||||
chmod 644 package.json
|
|
||||||
${stdenv.lib.optionalString bypassCache ''
|
|
||||||
if [ -f ${src}/package-lock.json ]
|
|
||||||
then
|
|
||||||
cp ${src}/package-lock.json .
|
|
||||||
fi
|
|
||||||
''}
|
|
||||||
|
|
||||||
# Go to the parent folder to make sure that all packages are pinpointed
|
|
||||||
cd ..
|
|
||||||
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
|
||||||
|
|
||||||
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
|
|
||||||
|
|
||||||
# Expose the executables that were installed
|
|
||||||
cd ..
|
|
||||||
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
|
||||||
|
|
||||||
mv ${packageName} lib
|
|
||||||
ln -s $out/lib/node_modules/.bin $out/bin
|
|
||||||
'';
|
|
||||||
} // extraArgs);
|
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "node-shell-${name}-${version}";
|
name = "node-shell-${name}-${version}";
|
||||||
|
|
||||||
buildInputs = [ python nodejs ] ++ stdenv.lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
|
buildInputs = [ python nodejs ] ++ lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cat > $out/bin/shell <<EOF
|
cat > $out/bin/shell <<EOF
|
||||||
|
@ -529,14 +574,15 @@ let
|
||||||
|
|
||||||
# Provide the dependencies in a development shell through the NODE_PATH environment variable
|
# Provide the dependencies in a development shell through the NODE_PATH environment variable
|
||||||
inherit nodeDependencies;
|
inherit nodeDependencies;
|
||||||
shellHook = stdenv.lib.optionalString (dependencies != []) ''
|
shellHook = lib.optionalString (dependencies != []) ''
|
||||||
export NODE_PATH=${nodeDependencies}/lib/node_modules
|
export NODE_PATH=${nodeDependencies}/lib/node_modules
|
||||||
export PATH="${nodeDependencies}/bin:$PATH"
|
export PATH="${nodeDependencies}/bin:$PATH"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
buildNodeSourceDist = stdenv.lib.makeOverridable buildNodeSourceDist;
|
buildNodeSourceDist = lib.makeOverridable buildNodeSourceDist;
|
||||||
buildNodePackage = stdenv.lib.makeOverridable buildNodePackage;
|
buildNodePackage = lib.makeOverridable buildNodePackage;
|
||||||
buildNodeShell = stdenv.lib.makeOverridable buildNodeShell;
|
buildNodeDependencies = lib.makeOverridable buildNodeDependencies;
|
||||||
|
buildNodeShell = lib.makeOverridable buildNodeShell;
|
||||||
}
|
}
|
1
modules/overlays/npm/node-packages.json
Normal file
1
modules/overlays/npm/node-packages.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
["@fsouza/prettierd"]
|
80
modules/overlays/npm/node-packages.nix
Normal file
80
modules/overlays/npm/node-packages.nix
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
# This file has been generated by node2nix 1.9.0. Do not edit!
|
||||||
|
|
||||||
|
{nodeEnv, fetchurl, fetchgit, nix-gitignore, stdenv, lib, globalBuildInputs ? []}:
|
||||||
|
|
||||||
|
let
|
||||||
|
sources = {
|
||||||
|
"core_d-3.2.0" = {
|
||||||
|
name = "core_d";
|
||||||
|
packageName = "core_d";
|
||||||
|
version = "3.2.0";
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://registry.npmjs.org/core_d/-/core_d-3.2.0.tgz";
|
||||||
|
sha512 = "waKkgHU2P19huhuMjCqCDWTYjxCIHoB+nnYjI7pVMUOC1giWxMNDrXkPw9QjWY+PWCFm49bD3wA/J+c7BGZ+og==";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
"has-flag-4.0.0" = {
|
||||||
|
name = "has-flag";
|
||||||
|
packageName = "has-flag";
|
||||||
|
version = "4.0.0";
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz";
|
||||||
|
sha512 = "EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
"nanolru-1.0.0" = {
|
||||||
|
name = "nanolru";
|
||||||
|
packageName = "nanolru";
|
||||||
|
version = "1.0.0";
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://registry.npmjs.org/nanolru/-/nanolru-1.0.0.tgz";
|
||||||
|
sha512 = "GyQkE8M32pULhQk7Sko5raoIbPalAk90ICG+An4fq6fCsFHsP6fB2K46WGXVdoJpy4SGMnZ/EKbo123fZJomWg==";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
"prettier-2.5.1" = {
|
||||||
|
name = "prettier";
|
||||||
|
packageName = "prettier";
|
||||||
|
version = "2.5.1";
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz";
|
||||||
|
sha512 = "vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
"supports-color-8.1.1" = {
|
||||||
|
name = "supports-color";
|
||||||
|
packageName = "supports-color";
|
||||||
|
version = "8.1.1";
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz";
|
||||||
|
sha512 = "MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
"@fsouza/prettierd" = nodeEnv.buildNodePackage {
|
||||||
|
name = "_at_fsouza_slash_prettierd";
|
||||||
|
packageName = "@fsouza/prettierd";
|
||||||
|
version = "0.18.1";
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://registry.npmjs.org/@fsouza/prettierd/-/prettierd-0.18.1.tgz";
|
||||||
|
sha512 = "W2H1E09e1B31MuyOlpXOtemxZ+9qZk7TTOzebVDh5WqHB7+jo1WOJtGwwTyp1k9irlvqqF/FpRzIUrKBR4KGqA==";
|
||||||
|
};
|
||||||
|
dependencies = [
|
||||||
|
sources."core_d-3.2.0"
|
||||||
|
sources."has-flag-4.0.0"
|
||||||
|
sources."nanolru-1.0.0"
|
||||||
|
sources."prettier-2.5.1"
|
||||||
|
sources."supports-color-8.1.1"
|
||||||
|
];
|
||||||
|
buildInputs = globalBuildInputs;
|
||||||
|
meta = {
|
||||||
|
description = "prettier, as a daemon";
|
||||||
|
homepage = "https://github.com/fsouza/prettierd#readme";
|
||||||
|
license = "ISC";
|
||||||
|
};
|
||||||
|
production = true;
|
||||||
|
bypassCache = true;
|
||||||
|
reconstructLock = true;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue