-
Notifications
You must be signed in to change notification settings - Fork 1
What the generated script does
The script generated by Nixie is the end product and main focus of the Nixie project. It is a simple bash script, which can be found here, with the -----BEGIN ARCHIVE SECTION-----
suffix and a gzipped tar archive appended to it.
The first task accomplished by the script is to read the features
file at the root of its appended archive, into its corresponding environment variables. The file is generated by builder/nixie/output/script.py
and follows this simple format:
EXTRA_FEATURES="(string to pass to the --extra-experimental-features nix option)"
EXTRA_SUBSTITUTERS="(string to pass to the --extra-substituters nix option)"
EXTRA_TRUSTED_PUBLIC_KEYS="(string to pass to the --extra-trusted-public-keys nix option)"
SOURCE_CACHE="nix-wrap.cachix.org"
SOURCE_DERIVATION="(nix hash of sources derivation)"
BINARIES_DERIVATION="(nix hash of binaries derivation)"
NIXIE_VERSION="(optional, version of the nixie builder which created the script)"
If one of the EXTRA_*
variables is empty, the corresponding option won't be passed to Nix.
In order to remain functionally compatible with the official nix
command, the script performs a few checks around here:
- Are we being run as
nix-shell
or another Nix subcommand? If so, unpack our channels into.nixie/channels
before running - Are we being run as a shebang (
#!
)? If so, transform thenix-shell
command to emulate official behavior. - Are we being run as an arbitrary command? If so, run that command in the default develop shell.
Next up on the list is figuring out if the user has Nix installed (nix
exists in $PATH
and the /nix
directory exists at the system root)
In order to balance script size, launch speed and portability, the Nixie script relies on key derivations built by automated tasks in this repository:
-
github:nixie-dev/nixie#static-bins
, the set of prebuilt static Nix binaries and the prebuiltlibfakedir.dylib
-
github:nixie-dev/nixie#sources
, the minimal set of configured source code required to build Nix on a target machine
All resource files are at the root of the produced path, and are listed in a filelist
file, which is used by the Nixie builder to retrieve and embed these resources offline if applicable.
If those resources aren't included, the script will attempt to retrieve them using the /serve/(hash)/(file)
HTTPS endpoint provided by Cachix. If a custom server and/or custom derivations are specified, the script expects these derivations to be available at that endpoint.
Example:
https://nix-wrap.cachix.org/serve/bh38pf33bgyywhpakhn1b1rc4zagmsy4/nix.Linux.x86_64