A Nix flake for the Node.js Package Registry Verdaccio.
This provides Verdaccio “as is” as if it had been installed globally by a common Node.js package manager.
This flake also exposes a configured wrapper for Verdaccio, which may be customized using the module
defined in ./verdaccio-cfg.nix
.
The flake exposes a module eval funtion evalVerdaccioConfig
, and a “convenience” wrapper which outputs
the wrapper package directly mkVerdaccioWrapper
.
You can use your configuration settings to produce a standalone wrapped verdaccio
executable,
which points to a generated config.yaml
file; and (TODO) in the future this same config can also be
used to generate a service - using systemd
, plist
, etc depending on your system.
I recommend using the basic
template to set up a configured Verdaccio server.
The custom-cfg
template is a simpler more disposable expression which may be useful for CI.
mkdir -p ~/my-verdaccio;
cd ~/my-verdaccio;
git init;
nix flake init -t github:aameen-tulip/verdaccio-nix;
vim flake.nix; # hack away
nix flake lock;
git add flake.nix flake.lock; # Probably commit too
nix build --impure;
./result/bin/verdaccio;
This flake also exposes a few extra outputs associated with node2nix
generated expressions.
For example nodeShell
provides the dev shell for building Verdaccio, nodeSources
exposes the
fetchers and dependency metadata for Verdaccio’s inputs, and nodeDependencies
exposes the builders
for those dependencies.
Additionally you will find several configDocs-*
outputs which produce the Nix Verdaccio Module’s
configuration documentation, configDocs-all
contains a large collection of file formats which
are not exposed globally.
Finally may also generate a Verdaccio YAML configuration file from a Nix config, which may be useful for debugging or running a verdaccio instance outside of Nix.
This example just builds a wrapped verdaccio server, but the same config
pattern may be used with any of the evalVerdaccioConfig
family.
/* my-verdaccio.nix */
let
verdaccio-nix = builtins.getFlake "github:aameen-tulip/verdaccio-nix";
config = {
listenPort = 420;
# Extra CLI utilities/wrappers for writing local configs to use your
# configured Verdaccio server.
# Thes are defined in `./verdaccio-cfg.nix'.
utils.enable = true;
# Fallback package registries
settings.uplinks = {
# This NPM entry is the default, but you must explicitly name it when
# defining uplinks explicitly.
npmjs.url = "https://registry.npmjs.org";
# Some private registry
my-org.url = "https://intranet.my-org.net/npm-registry";
};
};
in verdaccio-nix.mkVerdaccioWrapper { inherit config; }
This could be built with nix build --impure -f ./my-verdaccio.nix
.
If you just want to run the default wrapped configuration you can just refer to
our verdaccioWrapped
installable here.
If you want a customized configuration you could follow a from scratch approach
like my-verdaccio.nix
seen above ( this is the custom-cfg
template ).
But the recommended usage is to use the basic
template which is flake based and
has some bells and whistles like documentation.
Just run nix flake init -t github:aameen-tulip/verdaccio-nix
, edit your config,
and nix build
( or however else you prefer to realise the derivation ).
In either case, running nix {build,shell,run,profile install} --impure .#verdaccioWrapped
for a flake or nix {build,profile install} --impure -f ./my-verdaccio.nix
for
a non-flake will produce a configured wrapper for you to use.
I imagine that nix profile install .#verdaccioWrapped
or nix run .#verdaccioWrapped
are most
likely the commands you’ll want in general.
You can read the full list of configuration options in ./verdaccio-cfg.nix
, or
generate documentation using the configDocs-*
outputs.
$ nix build --impure .#configDocs-all
$ ls ./result/
options-docbook.xml options.adoc options.json options.md options.xml
...
The basic
template has a more complete example.