--- title: Build illumos-gate with nightly and an env file, then bldenv and dmake for one directory area: gate impact: HIGH tags: [illumos-gate, nightly, bldenv, dmake, proto, NIGHTLY_OPTIONS, env-file, closed-binaries, gate.nix] verified: 2026-11-05 --- # Build illumos-gate with nightly and an env file, then bldenv and dmake for one directory illumos-gate builds on an illumos host with `nightly` and an env file; after one full nightly, `bldenv` gives a shell in which `dmake install` rebuilds one directory into the proto area. Solnix runs the same `nightly` inside a Nix derivation and keeps the proto area and the nightly logs. A change you mean to send upstream needs the upstream build, not Solnix's. **Antipattern** ```sh pfexec pkg install build-essential # the illumos docs' OpenIndiana setup; Solnix has no pkg (product.md) nightly illumos.sh # from a Linux host: the gate needs an illumos host; no cross-compiling nightly -i illumos.sh # then sending its mail_msg upstream: the RTI wants a full build NIGHTLY_OPTIONS='-FCDAmprt' # no n in a tree you edit: bringover uses git switch --force-create mkdir /tmp/gate && cd /tmp/gate # gate.nix: illumos /tmp is tmpfs (RAM) and the tree grows to tens of GB ``` **The Solnix way** ```sh # pkgs/illumos/gate.nix (solnix 5a8e5ce) pins illumos-gate ac45d71fc2. With no srcDir or srcHash it fetches the # already-built proto by hash (protoUrl, protoHash) and runs no build. With one of them it builds, on an illumos # host that has /opt/onbld (nightly, dmake, ctfconvert, ctfmerge), /usr/gcc/10 and javac; it installs nothing: cp usr/src/tools/env/illumos.sh solnix.sh # then, in solnix.sh: # SHADOW_CCS= SHADOW_CCCS= (no gcc 14 shadow) unset ON_CLOSED_BINS ("fully-open gate") # PERL_VERSION=5.42 PERL_VARIANT=-thread-multi MAKE= # CODEMGR_WS= STAFFER=$LOGNAME MAILTO=$LOGNAME VERSION=solnix- nightly solnix.sh || true # the exit code is not the verdict: unix, genunix and libc.so.1 must be 64-bit # amd64 ELF and usr/include must exist in proto/root_i386, or the build fails # $out = proto/root_i386; the nightly logs (without mail_msg) go to $out/.nightly-log # NIGHTLY_OPTIONS stays the template's '-FnCDAmprt', so the proto kernel is DEBUG. The boot kernel is # pkgs/illumos/kernel-nd.nix: the same rev with Solnix's patches, uts built non-DEBUG in `bldenv +d`. ``` The build copies the source to a fixed path under `/var/tmp` and starts from an empty tree each time, so nothing in it is incremental. One patch README builds a single module by hand on the build host, outside Nix: `bldenv`, then `dmake` in `$SRC/uts/intel/ena` ([ena-default-mtu-1500.README.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/pkgs/illumos/patches/ena-default-mtu-1500.README.md), Applying). **The illumos way** (OpenIndiana, OmniOS) ```sh pfexec pkg install build-essential # OpenIndiana; OmniOS: pkg:/developer/illumos-tools git clone https://github.com/illumos/illumos-gate.git && cd illumos-gate cp usr/src/tools/env/illumos.sh . && vi illumos.sh # add the distro's variables (PKGVERS_BRANCH, Perl, ...) # template: NIGHTLY_OPTIONS='-FnCDAmprt': DEBUG only (-F, -D), no bringover (-n), make check (-C), new library # interfaces (-A), mail (-m), packages (-p), ELF runpaths (-r), this workspace's tools (-t); -w adds wsdiff time ./usr/src/tools/scripts/nightly illumos.sh # full build; log/latest/nightly.log and log/latest/mail_msg ./usr/src/tools/scripts/nightly -i illumos.sh # incremental (also skips cstyle/hdrchk): not for a patch you send /opt/onbld/bin/bldenv -d ./illumos.sh # a shell with the env file's settings; -d for a DEBUG nightly cd $SRC/cmd/dtrace && dmake install # rebuild a command into the proto area ($ROOT) cd $SRC/uts && dmake install_h # kernel headers first, when you changed one cd $SRC/uts/intel/igb && dmake install # a kernel module builds in its architecture directory dmake -m serial install # one job at a time, to find the first error ``` The proto area is `$CODEMGR_WS/proto/root_${MACH}`; packages go to `packages/${MACH}/nightly` for a DEBUG build, `packages/${MACH}/nightly-nd` for a non-DEBUG one. On OpenIndiana and OmniOS the closed binaries are in `/opt/onbld/closed`, and `ON_CLOSED_BINS` points at them. `/etc/nightly.conf`, if present, runs before the env file. **The difference.** Solnix runs illumos's own nightly, but in a derivation that keeps the proto area and the nightly logs. A failing IPS packaging step is out of scope for Solnix and is not fixed (illumos-domain.md, Packaging); there is no `onu` step. Solnix unsets `ON_CLOSED_BINS`, drops the gcc 14 shadow compiler and builds serially. Its build tools come from the build host (impure by design in Phase 1), an OpenIndiana host whose `pkg` installs them (product.md, Bootstrap exception). A gate change you send upstream needs the illumos way: a full, non-incremental nightly with GCC 10 primary and GCC 14 and smatch as shadows, and a clean `mail_msg` straight after a clean build of the previous commit (rule `gate-upstream-rti.md`). Solnix's gate log is not that. **Check.** In your own illumos-gate workspace, after a full nightly (not `-i`): `grep -n '\*\*\*' log/latest/nightly.log | head -1` prints nothing (dmake marks errors with `***`), and `log/latest/mail_msg` lists no errors or warnings. **Unverified** - Which components a build without closed binaries leaves out: the illumos docs still describe closed binaries; illumos-domain.md says the gate is fully buildable from source. - The attribute that builds gate.nix from source on a Solnix flake: not traced here. **Sources** - [pkgs/illumos/gate.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/pkgs/illumos/gate.nix) (solnix 5a8e5ce), header (WHAT THIS RUNS, `|| true`); protoUrl/protoHash; hostPrereqs; buildRoot (not /tmp); the env-file edits; the proto assertions; keepLog - [pkgs/illumos/kernel-nd.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/pkgs/illumos/kernel-nd.nix) (solnix 5a8e5ce), WHY IT EXISTS (-F, DEBUG proto kernel); WHAT IT BUILDS (`bldenv +d`); patches - [pkgs/illumos/patches/ena-default-mtu-1500.README.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/pkgs/illumos/patches/ena-default-mtu-1500.README.md) (solnix 5a8e5ce), Applying - [.kiro/steering/illumos-domain.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/.kiro/steering/illumos-domain.md) (solnix 5a8e5ce), Build system; The hard blocker; Packaging - [.kiro/steering/product.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/.kiro/steering/product.md) (solnix 5a8e5ce), No IPS/`pkg` in the end product; Bootstrap exception (the OpenIndiana host's `pkg` installs gcc, onbld, headers) - [docs/design-gate-derivation.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/docs/design-gate-derivation.md) (solnix 5a8e5ce), ยง1.3 build inputs from the host - [pkgs/illumos/default.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/pkgs/illumos/default.nix) (solnix 5a8e5ce), kernelNd = kernel-nd.nix; slices with kernelTree = kernelNd; `inherit (slices) ... kernel` - [modules/system/activation/default.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/modules/system/activation/default.nix) (solnix 5a8e5ce), system.build.kernelTree (default pkgs.solnix.kernel, the base non-DEBUG kernel) - [illumos docs: Contributing](https://illumos.org/docs/contributing/) (MPL-2.0), Submitting A Patch (full clean build, GCC 10 primary, GCC 14 and smatch shadows, clean `mail_msg`) - [illumos docs: Building illumos](https://illumos.org/docs/developers/build/) (MPL-2.0), Introduction; Installing required packages; Getting the closed binaries; Configuring the build; Starting the build; Performing an incremental build; Installing your build (nightly, nightly-nd) - [Developer's Guide: Workflow](https://illumos.org/books/dev/workflow.html) (PDL), Diagnosing Build Failures; Your Best Friend while Building: bldenv; The Proto Area and You; Building Individual Components - [Developer's Guide: Debugging](https://illumos.org/books/dev/debugging.html) (PDL), Build Failures (`dmake -m serial`, `***`) - [nightly(1onbld)](https://github.com/illumos/illumos-gate/blob/b56614870515295c253babb2b10fffdd3c60fdbe/usr/src/tools/scripts/nightly.1onbld) (illumos-gate b566148, CDDL), NIGHTLY_OPTIONS (-i, -n, -w); ENVIRONMENT VARIABLES (ROOT, ON_CLOSED_BINS); FILES /etc/nightly.conf; WARNINGS (git switch --force-create) - [usr/src/tools/env/illumos.sh](https://github.com/illumos/illumos-gate/blob/b56614870515295c253babb2b10fffdd3c60fdbe/usr/src/tools/env/illumos.sh) (illumos-gate b566148), NIGHTLY_OPTIONS and its comment; ON_CLOSED_BINS; ROOT; SRC; PKGARCHIVE; ENABLE_SMATCH - [usr/src/tools/scripts/bldenv](https://github.com/illumos/illumos-gate/blob/b56614870515295c253babb2b10fffdd3c60fdbe/usr/src/tools/scripts/bldenv) (illumos-gate b566148, CDDL), USAGE (-d, +t, ` [command]`); Example 1 (`cd $SRC/cmd/true`)