packages feed

nova-nix-0.11.0.0 / CHANGELOG.md

# Changelog## 0.11.0.0 - 2026-12-04`nova-nix daemon` serves a store in upstream Nix's worker protocol, over a Unix socket on Linux and macOS and a named pipe on Windows, and builds, substitutes and adds paths for its clients. A command that cannot write its store goes through a daemon when one is there, `push` and `trust` included. `nova-nix profile` keeps profiles of generations, with history, rollback and wipe-history, and on Linux and macOS `nova-nix develop` starts a shell in a derivation's build environment, which `print-dev-env` prints. Builds run in a sandbox by default on Linux and under a macOS sandbox profile with `sandbox = true`, and as root on Linux and macOS they run as members of `build-users-group`. On Windows, the package set's stdenv takes its shell, tools and toolchain from the seed ladder, which builds them from stage0-pe32's seed through GNU Mes, TinyCC and GCC 4.6.4, 10 and 16 to a native x86_64 GCC, and `pkgs/windows` no longer downloads a prebuilt compiler or shell. `builtins.fetchTarball` unpacks in process, so a tarball's tree and its store path are the archive's own. Evaluation spends less of its time collecting garbage: a pending thunk holds its environment's C pointer where it held a GHC stable pointer, and in that change's measurement the drvPaths of firefox, git, python3 and gimp from nixpkgs evaluated in 6.7 seconds where they took 24.5. The Library API section lists the breaking changes.### Library APIBreaking changes for code that uses nova-nix as a library:- **`Nix.Realise.realise` takes a `RealiseSettings`, holding `rsFallback` and `rsSubstitutes`, where it took a `Fallback`.** `RealiseFailure` gains `InvalidDerivation`, `BuildConfig` gains `bcSubstitutes` and `NixConfig` gains `ncAlwaysAllowSubstitutes`, so a record built without a default needs the new field. `Nix.Realise` exports `derivationAttrs` and `substitutesAllowed` with their types, and `storePathBasename` is defined in `Nix.Store.Path`, which exports it as `Nix.Push` still does. (#421)- **`Nix.Realise.realise` also takes a `BuildMode`, `BuildNormal` or `BuildCheck`, after its `RealiseSettings`; `RealiseEffects` gains `reCheck`, which answers a `CheckVerdict`; `Realised` gains `Checked`; and `RealiseFailure` gains `OutputsNotValid`, `NotDeterministic` and `MissingDerivation`, the last for a check whose root the graph does not hold, which is a failure where a build of such a root realises nothing and succeeds.** A record built without a default needs the new field, a call to `realise` the mode, and a total match the new constructors. `realiseFailureMessage` takes the directory the store's files are in before the failure, to name the output that differs where it is, and `realiseFailureStatus` gives the status a failure exits with. `BuildConfig` gains `bcMode`, and `buildWithDeps` answers a `BuildFailure` with that status, 104 for a check that found a difference, where it answered 1 for every failure. `Nix.Builder` exports `checkDerivation`, the rebuild and comparison alone for a derivation whose outputs are valid and whose inputs are realised. (#425)- **`Nix.Eval.Types` drops `mkSyntheticThunk`, whose callers use `mkThunkBc`, and `allocCSlots` and `fillCSlots`, which `tieFrame :: (MonadCData m) => EnvSite -> Maybe Env -> Int -> (Env -> m [Thunk]) -> m (Env, [Thunk])` replaces: it allocates a frame of that many empty slots at a site under a parent or none, makes its thunks against it, and fills the slots last.** A pending thunk's cell holds its env's C pointer, so `mkThunkBc`, and `cheapThunkBc` and `cheapThunk` where they make a pending thunk, take the env when they run; a frame whose slots hold thunks that point back at it is built with `tieFrame`. `cthunkNewBc` in `Nix.Eval.CThunk` takes the pending payload as an `nn_env_t *`, which both evaluators' force paths read back, and arena teardown no longer frees it, so a caller passing a StablePtr there leaks it and crashes when the thunk is forced. `cthunkPayload` answers that env pointer for a pending thunk of code. `Nix.Eval.CThunk` drops `cthunkSetPayload`. (#428)- **`Nix.Config.NixConfig` gains `ncCores :: Maybe Word32`, `Nothing` when no source sets it, and `Nix.Builder.BuildConfig` gains `bcCores :: Word32`, which `defaultBuildConfig` sets to 1, what setup.sh takes an unset `NIX_BUILD_CORES` to mean, and which a builder is told of as it is, `settingsBuildConfig` giving it the machine's default where `ncCores` is `Nothing` or `Just 0`; a record built with the constructor needs the new field.** The new module `Nix.Builder.Cores` gives upstream's default: `defaultCores` chooses it from a cgroup limit and a hardware count, `hardwareConcurrency` reads the hardware count, `cgroupCoreLimit` finds the limit over a file-reading effect (`ReadKernelFile`), and `cgroup2MountPoint`, `parseCgroups` and `cpuMaxCores` parse the three files it reads. (#436)- **`Nix.Store.GC` adds `deleteStorePaths :: Store -> [StoreEntryName] -> (StoreEntryName -> DeleteOutcome -> IO ()) -> IO (Either Text ())`, which deletes the named entries in order under one collector lock and one live set, runs the action after each deletion, and stops at the first refusal, which it returns; it refuses whatever `deleteStorePathRaw` refuses.** `LiveSet`, `withLiveSet` and `isLive` are removed from `Nix.Store.GC`, and `deleteStorePathChecked` from `Nix.Store`: a batch delete calls `deleteStorePaths`. `DeleteOutcome` and `deleteStorePathRaw` move from `Nix.Store` to `Nix.Store.GC`, which `Nix.Store` re-exports, so an import from `Nix.Store` is unchanged. (#446)- **`Nix.Builder.BuildConfig` has no `bcTmpDir`; a build's directory follows from `bcStoreDir`.** The new module `Nix.Builder.BuildDir` names a build's directory (`buildDirFor`), creates one (`createBuildDir`) and runs a build in one (`withBuildDir`). (#449)- **`deleteStorePathRaw` takes a `StoreEntryName` where it took `Text`, as `deleteStorePaths` does.** `Nix.Store.GC`, which `Nix.Store` re-exports, adds `StoreEntryName` without its constructor, `storeEntryName :: Text -> Either Text StoreEntryName`, the only way to make one, and `storeEntryNameText`. `resolveDeleteTarget` returns a `StoreEntryName`. (#457)- **`Nix.Expr.Types.Expr` gains `EPos`, the position `__curPos` is written at, which the parser gives where it gave `EVar "__curPos"`; a match on `Expr` needs the case.** `Nix.Eval.CBytecode` adds the opcode `OpPos`. (#468)- **`Nix.Store.setReadOnly` is replaced by `canonicalizeMetadata`, from the new module `Nix.Store.Metadata`; `Nix.Store` re-exports it.** The module also exports the canonical form: `metadataChanges` gives the `MetadataChange`s a node's `NodeMetadata` needs, and `canonicalPermissions`, `readOnlyPermissions`, `executablePermissions` and `storeModificationTime` are its constants. `writeDrvAterm` keeps a `.drv` that already holds its bytes rather than writing it again. On Windows the `Win32` floor rises to 2.12, the first whose `setFileTime` leaves a time it is not given as it is. (#477)- **`Nix.Eval.Types.MonadEval`'s `listDirectory` returns `[(Text, Maybe Text)]`, `Nothing` for an entry whose `lstat` is refused, where it returned `[(Text, Text)]`; an instance gives `Nothing` for such an entry, and a caller that needs every entry's type reads it with `getFileType`.** (#491)- **`Nix.Eval.Compile.decodeBcFormals` answers a `Maybe EvalFormals` and `decodeBcCaptureInfo` an `Either` whose `Left` holds the unknown tag, where each answered the decoded value alone.** `Nix.Eval.Compile` exports each operator's tag pair, `encodeUnaryOp` with `decodeUnaryOp :: Word8 -> Maybe UnaryOp` and `encodeBinaryOp` with `decodeBinaryOp :: Word8 -> Maybe BinaryOp`, and `Nix.Expr.Types.UnaryOp` and `BinaryOp` derive `Bounded` and `Enum`. (#502)- **`Nix.DependencyGraph.DepNode`'s `dnDeps` maps each dependency's `.drv` path to the outputs wanted of it, a `Map StorePath (Set Text)`, where it was a `[StorePath]`; `directDeps` still answers the paths.** `Nix.Realise.RealiseEffects` drops `reAllValid`: whether the outputs wanted of a derivation are valid is asked of `reSubst`'s `seValid`. Its `reBuild` also takes the names of the outputs the request that led to the build asks for, a `Set Text`, which a build that makes every output may leave unread. `Nix.Realise.RealiseFailure` gains `MissingOutputs`, naming the derivation and the outputs it lacks, a `NonEmpty Text`. (#503)- **`Nix.Eval.Types.MonadEval`'s `copyPathToStore` takes its pin as the digest the copy must have and the refusal of a copy with another, given the digest it has (`Maybe (ByteString, ByteString -> Text)`), where it took the refusal's subject and the digest (`Maybe (Text, ByteString)`).** (#500)- **`Nix.Eval.Types.MonadEval`'s `addErrorTrace` method is replaced by `addEvaluatedTrace :: (Text -> Text) -> m Text -> m a -> m a`, which makes its line, an action, only when the action it wraps fails, and when making the line fails keeps the action's failure with the line its first argument makes of the line's own failure.** `addErrorTrace :: (MonadEval m) => Text -> m a -> m a` is a function of `Nix.Eval.Types` taking a line that is already made, which `MonadEval (..)` no longer brings in and `Nix.Eval` does not export, so a caller imports it from `Nix.Eval.Types` by name, and an instance defines `addEvaluatedTrace`. (#517, #706)- **`Nix.Realise.SubstEffects` and `RealiseEffects` take the type of a substitute, which `Offered` carries beside the references; `SubstEffects` gains `seNextOffer`, and `seFetch` takes a `Registration`, `RegisterAll` or `RegisterNone`, and each path with its substitute, as a `NonEmpty`.** `FetchOutcome` is `Fetched` or `NotFetched`, which names each path that did not arrive with an `Undelivered`, `Gone` or `DeliveryFailed`, in place of `FetchMissed` and `FetchFailed`. `Nix.Substituter.queryReferencesWith` runs in `StateT CacheMemo IO` and answers an `Offer Substitute`, which names the path it was checked for (`substitutePath`) and the cache it comes from (`substituteCache`); `queryNextOfferWith` asks the caches after a substitute's, `fetchSubstituteWith` fetches a substitute's path, and a run starts from `emptyCacheMemo`. `trySubstitute`, `trySubstituteWith` and `tryCachesWith` are removed: a path is fetched from the substitute a reference query offered, `queryReferencesWith` and then `fetchSubstituteWith`, whose `SubstResult` is about that one cache. `Nix.Builder.substitutePaths` takes a `Registration` and the substitutes. (#518)- **`Nix.Hash.makeFixedOutputPath` takes the method as a `FileIngestionMethod` (`FlatIngestion` or `NarIngestion`, exported from `Nix.Hash` with `fileIngestionPrefix`), where it took `"flat"` or `"recursive"` as `Text` and read every other text as flat.** (#528)- **`Nix.Parser.parseNix` and `parseNixWithScope` return a `ParsedSource`, whose expression `parsedExpr` reads and whose names, in upstream's interning order, `parsedNames` reads.** `Nix.Eval.evalParsed` evaluates one in the environment an action builds, interning its names first and running the action once the source has compiled, and `Nix.Eval.Compile.compileParsed` compiles one; `eval` on its expression interns the names in the order the compiler meets them. `Nix.Parser.Internal.ParseState` gains `psNames`, the names noted so far, latest first, which a state built outside the parser starts as `[]`, and `recordName` notes one. (#525)- **Every constructor of an environment or attribute set takes, first, the `EnvSite` or `SetSite` (`Nix.Eval.AllocSite`, new) it allocates for: `attrSetFromMap`, `attrSetFromEntries`, `attrSetMapWithKey` and `attrSetRemoveKeys`, and in `Nix.Eval.CAttrSet` and `Nix.Eval.CEnv` `cattrsetNew`, `cattrsetUnion`, `cattrsetRemoveKeys` and `cenvPushWith`.** `Nix.Eval.AllocSite` gives each site's name in the census (`envSiteName`, `setSiteName`) and its index in the C counts (`envSiteIndex`, `setSiteIndex`). `Nix.Eval.CStats` also has `countSites`, which turns counting by site on, `siteCounts`, which reads the `SiteCounts` (an `EnvSiteFigures` for each environment site, a `SetSiteFigures` for each set site, and the environments by `EnvSize`), `envSitesCounted` and `setSitesCounted`, and the census's `censusSites`. `attrSetUnionWith` and `pushWithScope`, which nothing called, are removed. (#539)- **`Nix.Eval.EvalFormals.EFSet` and `EFNamedSet` take the function's `LambdaName` (`AnonymousLambda`, or `NamedLambda` holding the name's `Symbol`) as their first field, which `lambdaNameText`, `lambdaNameSymbol` and `lambdaNameFromSymbol` read.** `Nix.Eval.StartupSymbols.startupSymbols` lists the names an evaluation session interns first, and `Nix.Eval.Symbol.invalidSymbolId` is exported. `Nix.Eval.CLambda.clambdaNew` takes the function's name symbol after the binding's and refuses a formals type or count its closure cannot hold, `clambdaLambdaNameSym` reads the name, and `clambdaShape`, `clambdaShapeFormalsType`, `clambdaShapeAllowExtra` and `clambdaShapeFormalCount` pack and unpack the one word a closure keeps its formals type, ellipsis flag and formal count in. `Nix.Eval.Print.printSymbol` prints a name as upstream writes a symbol into a message. `Nix.Eval.runPureEval` reports an abort with its message alone, as `Nix.Eval.IO.runEvalIO` does, where it prefixed `evaluation aborted: `. (#540)- **`MonadEval` has `MonadCData` (in the new `Nix.Eval.CData`) as a superclass, so an instance needs `liftCData`, which runs a `CData` action; `IO` is an instance.** The C accessors and allocators are `MonadCData` actions where they were pure: in `Nix.Eval.Types` the attribute set, list, environment and thunk functions (`attrSetLookup`, `attrSetFromMap`, `evaluated`, `readThunkValue`, `mkThunkBc` and the rest), `Nix.Eval.CList`'s `clistFromThunks`, `clistThunks`, `clistLen`, `clistIndex` and `clistDrop`, `Nix.Eval.SourcePos.lookupPos`, `Nix.Eval.Print.printValue` and `printAmbiguous`, `Nix.Eval.deferApply`, and `Nix.Builtins`'s `builtinEnv`, `builtinEnvWithScope`, `parseNixPath` and `searchPathRoots`; the `IO` accessors of the C binding modules (`Nix.Eval.CThunk`, `CAttrSet`, `CEnv`, `CLambda`, `CList`, `CCtxStr`, `CBytecode`), `Nix.Eval.Compile`'s `decodeBcFormals`, `decodeBcCaptureInfo` and `decodeBcBindings`, and `Nix.Eval.Symbol.symbolIntern` are too, so their `IO` callers are unchanged; each environment and set constructor keeps the site it takes first, and `buildCaptureEnv` takes one too. `attrSetMapWithKey` takes an action where it took a function, `Nix.Eval.CEnv.cenvEmpty` is a value, and `Nix.Eval` exports `compileSource`; `NIX_PATH`'s entries are built and interned as a session starts rather than when an entry is first used, and `Nix.Eval.IO.nixPathValue` reads `NIX_PATH`'s bytes. `Nix.Eval.Types` no longer exports the unused `lookupWithScopes`, nor `checkedCPtr`, which `Nix.Eval.CStatus` exports; it exports `compile`, `compileSource`, `readComputed`, `pushLazyWithScope`, `buildCaptureEnv`, `withScopeAt` and `resolveWithScopeAt`. `Eq` on `Thunk` and `AttrSet` compares identity, as on `Env` and `CList`, where it compared what they held, so two `NixValue`s holding equal sets in different C objects are unequal; `Show` on the four gives the address. `Nix.Eval.Types.thunkSameRef` is gone, since `==` on `Thunk` is what it was. `Nix.Eval.CData` exports `cdataIO`, which runs a binding's `IO` action as a `CData` one, `runCData`, which runs a `CData` action in `IO`, and the two reads outside a monad, `readImmutable` and `runCDataPure`; `Nix.Eval.Operator` exports `expectedFailure`, upstream's refusal of a value of the wrong type. (#552)- **In `Nix.Eval.Types`, `newEnv`, which takes a site, a parent or none and the thunks for the slots, and `newScopeEnv`, which takes a site, a parent or none and a name table, replace `buildCSlots`, `newMinimalEnv`, `envFromSlots` and `newCEnv`.** In `Nix.Eval.CEnv`, `cenvNew` takes a site, a slot count and a parent, `cenvNewScoped` and `cenvWithOwner` are new, `cenvSlots` answers the environment's own slots, `cenvWithScopes` and `cenvWithCount` read the with-scopes an environment has of its own (`envWithScopesRaw` answers those it sees), and `cenvAllocSlots`, `cenvFromSlots` and `cenvNewMinimal` are removed. (#559)- **`Nix.Eval.CStr` (new) binds the string arena: `cstrNew`, `cstrFromText`, `cstrBytes` and `cstrText` over a `CStrPtr`.** `Nix.Eval.Symbol` no longer exports `symbolInternBytes` or `symbolBytes`. The string and path functions of `Nix.Eval.CThunk` (`cthunkNewComputedStr`, `cthunkNewComputedPath`, `cthunkSetComputedStr`, `cthunkSetComputedPath`) and the text, hash, name and output functions of `Nix.Eval.CCtxStr` take and answer a `CStrPtr` where they took a symbol's `Word32`. `Nix.Eval.CBytecode` exports `cbcEmitString`, `cbcEmitText`, `cbcString`, `cbcStringBytes` and `cbcStringText` for the compiled code's strings, and `Nix.Eval.CStats.PerKind` has a `kindStrings` field and `CRoot` the roots `RootString` and `RootCtxStr`. `NixValue`'s string and path constructors are `VStrHeld` and `VPathHeld`, which carry the `HeldBytes` their bytes already are in C; `VStr` and `VPath` are bidirectional pattern synonyms bundled with `NixValue`, which match one whatever it holds and build one held in Haskell only, so code that matches and builds strings and paths is unchanged. `Nix.Eval.Types` exports `heldString`, `stringCell`, `pathCell` and `StringCell`. (#559)- **`Nix.Push.PushConfig` gains `pcPartSize`, a `PartSize` (from `mkPartSize`, or `defaultPartSize` for 64 MiB), and `pcRetry`, a `Nix.Http.FetchRetryPolicy` (`defaultFetchRetryPolicy` for upstream's); a caller that builds a `PushConfig` sets both.** `splitParts` cuts a NAR into the parts of an upload, and `partSizeBytes` gives the bytes a part size allows. `Nix.Http.exceptionFailure` classifies a client failure as `fetchExceptionFailure` does, with the caller's message. (#560)- **`NixValue`'s `VBuiltin` holds a `Builtin` from the new `Nix.Eval.Builtin`, one constructor per builtin, where it held the builtin's name; `builtinName` and `builtinNamed` convert, and `builtinIndex` and `builtinAtIndex` give the index the C data layer holds.** `VCompiledRegex` and `CompiledRegex` are removed. `Nix.Eval` exports `listedBuiltins`, the builtins `builtins` lists, where it exported `builtinNames` and `builtinRegistry`. `Nix.Eval.CPrimop` (new) binds the partial application object. `Nix.Eval.CThunk` loses `cthunkNewComputed` and `cthunkSetComputed`, which stored a StablePtr, and gains `cthunkPrimop`, a builtin's static cell, with `cthunkNewComputedPrimop`, `cthunkNewComputedPrimopApp`, `cthunkSetComputedPrimop`, `cthunkSetComputedPrimopApp` and `cthunkGetPrimop`. `Nix.Eval.Types` exports `PrimopCell` and `primopCell`. `Nix.Eval.CStats.PerKind` has a `kindPrimopApps` field. (#565)- **`Nix.Eval.IO.EvalState` no longer exports its constructor or `esPolicy`, `esTimestamp`, `esSearchPaths` and `esImportCache`, which the session fixes as it starts, and `evalBaseEnv` gives the environment to evaluate a file in.** `Nix.Builtins.builtinEnvWithScope` takes the base environment to overlay in place of the policy, the timestamp and the search path. `Nix.Eval.CRoots` (new) registers roots, `Nix.Eval.CStats.CRoot` has `RootRegistered`, and `Nix.Eval.CThunk` exports `cthunkEmptyList`. (#567)- **`Nix.Eval.IO` exports `SessionSettings`, `withEvalSession`, `nixPathSearchPath` and `evalSearchPath`, and no longer exports `newEvalState`: `newEvalStateWith :: Logger -> EvalPolicy -> [Thunk] -> SessionStore -> StoreDir -> FilePath -> IO EvalState` makes a state, with its base environment built over the policy and the search path, in the session already open.** `Nix.Eval.Arena` is no longer exposed, so `arenaInit` and `arenaDestroy` leave the public API; `CStatusError` and `arenaLive` are in `Nix.Eval.CStatus`. `ArenaNotInitialized` names `withEvalSession` in its message. (#574)- **`Nix.Eval.Types.MonadEval`'s `forceThunk` takes the action that runs a `Pending`, a pending thunk's code in an environment (`PendingCode`) or its deferred application (`PendingApply`, `PendingApply2`), where it took one running code in an environment; `readPending` reads it from a cell, and `mkApplyThunk` and `mkApply2Thunk` make an application's cell.** `Nix.Eval.CBytecode` loses `reservedApply1`, `reservedApply2`, `appDirect` and `appDeferred`: the bytecode store no longer opens with reserved instructions. `Nix.Eval.CThunk` gains `cthunkNewApply1`, `cthunkNewApply2`, `cthunkPendingForm`, `cthunkApplyCell` and `noCode`, the index of no instruction, which `cthunkGetBcIdx` answers for an application and `cthunkNewBc` must not be given; `Nix.Eval.CStats.PerKind` has a `kindApps` field. (#575)- **The C data layer's lifecycle is internal to the library, as an evaluation session owns it (`Nix.Eval.IO.withEvalSession`): `Nix.Eval.Symbol` no longer exports `symbolInit` and `symbolDestroy`, `Nix.Eval.CThunk` `cthunkInit` and `cthunkDestroy`, `Nix.Eval.CEnv` `cenvInit` and `cenvDestroy`, `Nix.Eval.CBytecode` `cbcInit` and `cbcDestroy`, and `Nix.Eval.CCtxStr`, `Nix.Eval.CLambda` and `Nix.Eval.CList` `cctxstrFreeAll`, `clambdaFreeAll` and `clistFreeAll`, any of which, called inside a session, freed the session's memory under it.** Names nothing outside their module uses are no longer exported: from `Nix.Eval.Types`, `marshalStringContext`, `unmarshalStringContext`, `unmarshalLambdaValue`, `withScopesForCapture` and `mkThunk`; from `Nix.Eval`, `BuiltinDef` and `ArgMode`; from `Nix.Eval.IO`, `EvalErrorKind`, `NixEvalError` and `NixAbortError`, which `runEvalIO` and `runEvalIOTraced` catch before a caller can meet them; from `Nix.Eval.Policy`, `modeInformation` and `forbiddenUriMessage`; from `Nix.Eval.CallDepth`, `maxCallDepthExceeded`; and from `Nix.Eval.CList`, `clistNew`, which made a list whose cells nothing exported could fill, `clistCount`, `clistGet`, `clistSet` and `clistToThunkList`: a list is built with `clistFromThunks` or `thunkListToCList` and read with `clistLen`, `clistIndex` and `clistThunks`. `Nix.Eval.Types.thunkToCPtr`, which was `unThunk`, is gone, and so are `Nix.Eval.CThunk.cthunkCount` and `cthunkGet`, with the count of thunks the arena kept for them. (#589)- **`Nix.Eval.CThunk` no longer exports `cthunkGetStr`, `cthunkGetPath`, `cthunkGetList`, `cthunkGetAttrs`, `cthunkGetCtxStr` and `cthunkGetLambda`, each of which answered the payload `cthunkPayload` answers, which a caller casts.** `Nix.Eval.CEnv` renames `cenvLazyScope` to `cenvNameTable`, the set of names an environment binds. `cenvLookupResolved` takes `Word32` coordinates and raises `CInvariantViolated` where it answered `nullPtr`, and `Nix.Eval.Types.envLookupResolved` takes `Word32` coordinates. `Nix.Eval.CEnv`'s `cenvNew` and `cenvPushWith`, `Nix.Eval.CLambda.clambdaNew` and `Nix.Eval.CCtxStr.cctxstrNew` raise a `CStatusError` where they answered `nullPtr`. `Nix.Eval.CLambda` exports `FormalsName`, `FormalsSet` and `FormalsNamedSet`, and `Nix.Eval.CCtxStr` exports `ScePlain`, `SceDrvOutput` and `SceAllOutputs`, the tags their C structs hold. (#595)- **`Nix.Eval.CEnv` removes `cenvRootScope` and `cenvAllocWithScopes`, which built a trimmed closure's copy of its scopes.** (#595)- **`Nix.Expr.Types.Expr` loses `ESearchPath` and `Nix.Eval.CBytecode` loses `OpSearchPath`.** `Nix.Parser` no longer exports `parseNixFile`, which nothing called: a caller reads the file and passes its bytes to `parseNix`. (#597)- **`Nix.Eval.Types.envLookup` takes the name it looks up as a `Symbol` where it took `Text`.** `Nix.Eval.Types` exports `attrSetLookupSymbol`, which looks a name up in a set by its `Symbol`. (#599)- **`Nix.Eval.Types.buildCAttrSetKeys` takes a name table's names as `Symbol`s and `fillCAttrSetValues` takes a `Map Symbol Thunk`, where each took `Text` names.** `Nix.Eval.Types` exports `attrSetFromSymbolEntriesSizedFor`, which builds, from names already interned, a set upstream sizes before it knows what it holds, and `Nix.Eval.SourcePos` exports `printPos`, which writes a position as upstream's messages write one. (#604)- **`Nix.Eval.Types.attrSetMapWithKey` passes each name to its action as a `Symbol` where it passed `Text`.** `MonadEval`'s `scopedImportFile` takes the scope as an `AttrSet` where it took a list of names and values, and `Nix.Builtins.builtinEnvWithScope` takes that set, which becomes the environment's name table, in place of the list. `Nix.Eval.Types` exports `attrSetFoldM`, which folds an action over a set's attributes in the order the set holds them, and `attrSetLookupSymbolEntry`, which looks an attribute up with its position by the `Symbol` of its name. (#605)- **`Nix.Eval.Compile.decodeBcBindings` answers `BcBindings`, a binding list's `BcBindingCounts` with its count and offset, where it answered a list of `BcBinding`; `foldBcBindings` folds over the bindings, handing a binding tag the compiler never writes to the function it is given, and `foldBcInheritedNames` folds over an `inherit (from)`'s names.** `BcAttrKey` is gone: `BcNamed` holds a static name's symbol, the new `BcDynamic` holds the bytecode index a dynamic name is computed by, and `BcInheritFrom` holds `BcInheritedNames`, the names' count and offset, where it held a list. The capture info `decodeBcCaptureInfo` answers is a `BcCaptureInfo`, whose `BcCaptures` and `BcCapturesWithScopes` hold the `BcCapturedSlots` that `foldBcCapturedSlots` reads, where it was a `CaptureInfo`, and `Nix.Eval.Types.buildBcCaptureEnv` builds a closure's env from one. A binding list's bytecode starts with the two counts. (#608)- **`Nix.Eval.EvalFormals.EvalFormal`'s `efName`, the argument name `EFName` holds and the `@` name `EFNamedSet` holds are each a `Symbol` where they were `Text`, so `Nix.Eval.Compile.decodeBcFormals` answers, and `Nix.Eval.Types.marshalLambda` stores, the symbols the bytecode and a closure hold, and `Nix.Eval.Compile.compileFormalsToEval` interns each name it compiles.** (#611)- **`Nix.Eval.Types.cheapThunkBc` answers the value of a variable the resolver left to a name table, where it answered a thunk of its own, and `Nix.Eval.Types.frameThunkBc` makes a value in a frame that is being tied; `shareSlot` gives a slot of such a frame the cell another slot holds, handing a slot past the frame's, as `Nix.Eval.CEnv.cenvSlotCount` counts them, to the function it is given, `envSlotCells` reads a frame's cells, and `attrSetMemberSymbol` says whether a set binds a symbol, a name table's entry not filled yet included.** `Nix.Eval.EvalFormals.EvalFormal`'s `efDefault` is a `FormalDefault`, which tells a default that shares a slot's cell apart, where it was a `Maybe Word32`; `hasDefault` says whether there is one. `Nix.Eval.Compile.decodeBcFormals` takes the function a default kind the compiler never writes is handed to, and `formalDefaultWords` and `formalDefaultFromWords` write and read a default as the kind and code words a set pattern's entries hold. A binding list's words hold the count of its frame's shares and the shares after its two counts, which `Nix.Eval.Compile.decodeBcBindings` reads into a field of `BcBindings` and `foldBcShares` folds over, and `Nix.Eval.Compile.siblingShares` decides them. `Nix.Eval.CBytecode` exports `attrsPlain`, `attrsRec` and `attrsRecOverrides`, the flags an `OpAttrs` instruction holds, and `formalNoDefault`, `formalDefault` and `formalSharedDefault`, the kinds of a formal's default. Bytecode holding an `OpAttrs` flag or a default kind the compiler never writes, a share naming a slot past its frame or a name its frame does not bind, or shared defaults that form a cycle is corrupt bytecode, where any `OpAttrs` flag but 0 made a recursive set and any default kind but 0 made a default. (#616)- **`SessionSettings` has a field `sessionRegions`, what the session runs regions for (`Nix.Eval.CRegion`): `RegionsCollect` the collector, `RegionsCensus` the census, which frees nothing, or `RegionsOff` neither.** `withRegions` runs an arena's setup and teardown with them running, `regionsRunning` reads what they run for, and `inRegion` runs a force in a region of its own. (#622)- **`Nix.Eval.CAttrSet` has `cattrsetUpdate`, which makes the set `cattrsetUnion` makes and counts its entries as copied.** `SiteCounts` in `Nix.Eval.CStats` has a field `sitesUpdateCopied`, the count. (#637)- **`Nix.Push.Directory` is new: `pushToDirectory` writes a closure to a directory cache as `DirectoryPush` describes it, `loadSecretKeyFile` reads a signing key, and `pushTarget` tells a server's URL from a directory's.** `Nix.Push.loadApiKeyFile` is renamed `loadKeyFile`, since it reads either kind of key, and `narInfoFileName` and `narDirSegment` are exported. (#639)- **`Nix.Builder.attrsDelivery` takes the build directory and outputs where the builder sees them, and the `adFiles` of the `AttrsDelivery` it gives name each file in the build directory, where they held its path there.** `Nix.Builder` exports `BuildPlace`, a path as the builder is told of it and on disk, `BuildLayout`, a build's directory and outputs as places, and `builderInvocation`, which gives the `BuilderInvocation` a spawned builder starts with: the program and arguments, the environment and the ambient variables copied into it, the files written before it starts and the directory it starts in. (#646)- **`Nix.Eval.Types` has `attrSetFindName`, which walks a set in order and stops at the first name a test holds for, and `attrSetAllPairs`, which walks two sets in lockstep and stops at the first pair an action fails.** `Nix.Eval.CAttrSet` drops `cattrsetKeys`, `cattrsetGetKey`, `cattrsetGetPos` and `cattrsetGetValue`: a set is walked in symbol order with the new `cattrsetWalk` and `cattrsetWalkNext`, a `CAttrSetStep` at a time, and read by name with the new `cattrsetFind`, which gives an entry's position and value and finds a value not yet written, and `cattrsetMember`. `cattrsetIndex` and `cattrsetSetValue` take a `FlatCAttrSet`, the name table `cattrsetFromNames` makes, whose set `flatCAttrSet` gives; `buildCAttrSetKeys` gives one and `fillCAttrSetValues` takes one. (#650)- **`Nix.Eval.AttrPath.selectAttrPath` takes, first, the action the value each component selects from is passed through, `pure` for none.** `Nix.Eval.AutoCall` is new, with `autoCallFunction` and `AutoArgs`; `Nix.Eval` exports `findInSearchPath`, the lookup `builtins.findFile` makes; `Nix.Eval.IO` exports `resolveImportTarget` and `readImportTarget`, which find and read a file as `import` does; and `Nix.Environment` exports `argumentBytes`. (#644)- **`Nix.Eval.Types.MonadEval` has a new method with no default, `realiseContext :: StringContext -> m (Either ContextRefusal ())`; `PureEval` answers `Right ()`, and an instance with no store answers the same.** Its `copyPathToStore` and `addFixedOutputFile` take a `PendingOrigin` first, `Fetched` from a fetcher and `Computed` from `builtins.path`. The new module `Nix.Eval.RealiseContext` holds `ContextRequest`, `SessionMode`, `PendingOrigin`, `Plan`, `planRealisation`, `firstInvalidPath`, `referenceClosure`, `ContextRefusal` and its messages, and `Nix.Eval.Context` gives a context's request (`contextRequest`). `Nix.Eval.IO.SessionSettings` gains `sessionStore`, a `SessionStore` that is `ReadOnlySession` over a `StoreQueries` and a build or `ReadWriteSession` over a `StoreOps`, and `newEvalStateWith` takes one after the search path. `Nix.Store.Ops` exports `StoreQueries` (`sqValidPaths`, `sqReferences`), `StoreOps` gains `soQueries`, and `localQueries` answers for the store in a directory without making or writing it. `Nix.Builder.BuildConfig` gains `bcSubstitution`, whose `RefuseSubstitution` refuses every substitution in upstream's read-only words (`Nix.Realise.noWriteAccessMessage`), and `Nix.Builder.realiseWithoutWriting` realises requests that way where nothing may be opened or written. `Nix.Store.DB` adds `openStoreDBReadOnly` and `storeTablesExist`. The read-only open needs `direct-sqlite >= 2.3.28`, the first release whose `open2` opens a database read-only, and wraps the handle in sqlite-simple's `Connection`, whose two fields arrived in sqlite-simple 0.4.19.0 (a minor release), so the library's bound on sqlite-simple rises from `>= 0.4` to `>= 0.4.19 && < 0.4.20`. `Nix.Store.Path` adds `isInStoreText`, upstream's `isInStore`. (#657)- **`Nix.Eval.Policy.EvalPolicy` gains `epImportFromDerivation`, an `ImportFromDerivation` that is `RefuseImportFromDerivation`, `AllowImportFromDerivation` (in `unrestrictedPolicy`) or `TraceImportFromDerivation`.** `Nix.Eval.RealiseContext.planRealisation` takes one first, `Plan` gains `planWarning`, and `ContextRefusal` gains `ImportFromDerivationOff`. `Nix.Config.NixConfig` gains `ncAllowImportFromDerivation` and `ncTraceImportFromDerivation`, and `Nix.Eval.Types` exports `warnMessage`, upstream's `warn`. (#665)- **`Nix.Eval.Types.MonadEval` has a new method with no default, `pinnedFetchHeld :: StorePath -> m Bool`, which `PureEval` answers `False`, and a read-only `SessionStore`, `ReadOnlySession` over a `StoreQueries` and a `StoreOps`, writes and adds only what a fetcher fetches.** `Nix.Store.Ops`'s local `soAddEvalObjects` adds nothing, and refuses nothing, for an evaluation that made nothing. `Nix.Eval.RealiseContext` exports `readableIn`. (#668)- **`Nix.Builder.BuildConfig` gains `bcSandbox`, a `SandboxConfig` from the new `Nix.Builder.Sandbox`, which also holds the settings' types, the decision (`sandboxUse`, `buildNetwork`), the helper's plan (`sandboxPlan`, `renderPlan`), the chroot (`chrootSkeleton`) and the helper's reports (`parseStatus`, `helperOutcome`); `defaultBuildConfig` leaves the sandbox off (`defaultSandboxConfig`), since finding the helper takes IO.** The new `Nix.Builder.Sandbox.Spawn` probes the system (`sandboxAvailability`), runs the helper (`runHelper`) and makes the chroot (`withChroot`). `Nix.Config.NixConfig` gains `ncSandbox`, `ncSandboxFallback`, `ncSandboxPaths` (a `PathSetValue`), `ncSandboxBuildDir`, `ncSandboxDevShmSize`, `ncRequireDropSupplementaryGroups` and `ncSslCertFile`, so a record built without a default needs them. `Nix.Realise` exports `derivationBoolAttr`, upstream's `getBoolAttr`. `Nix.Builder.BuildLayout` also holds the `HOME` a builder is told of (`layoutHome`). The library's `directory` floor rises to 1.3.9, the first whose `removePathForcibly` works relative to each directory's descriptor and never follows a link, which removing a chroot relies on. (#673)- **`Nix.Store.Ops.EvalObjects`' `eoSources` is a `Map StorePath Text`, each copy's store path with the path-value text of the tree it is restored from, and `Nix.Store.materializeEvalSources` takes that map.** `Nix.Eval.IO.EvalState`'s `esSourcePathCache` holds a `SourceCopy` per coerced path, and `sourceCopies` gives the map from it. (#676)- **A caller that makes an attribute set, a lambda, a builtin's partial application or a string with context directly, through `Nix.Eval.CAttrSet`, `Nix.Eval.CLambda`, `Nix.Eval.CPrimop` or `Nix.Eval.CCtxStr`, does so inside `Nix.Eval.IO.withEvalSession`.** (#703)- **`Nix.Profile.Manifest` reads and writes `manifest.json` and selects its elements as `profile remove` does, and `Nix.Profile.Generation` finds where profiles are from a `ProfileEnvironment`, resolves the default profile, names and lists generations, and changes a profile through `updateProfile`.** `Nix.Store.addSourceTree`, and the `StoreOps` field `soAddSourceTree`, add a tree given as its NAR as the content-addressed path its name and references make. `Nix.Config.NixConfig` gains `ncUseXdgBaseDirectories`, and `Nix.HostPath` exports `hostPathBytes`, the inverse of `hostPathFromBytes`. (#713)- **`Nix.Develop.Shell` holds what a `develop` shell runs (`shellModeFor`, `shellArguments`, `bashProgram`) and the environment it starts with (`shellEnvironment` over `EnvironmentChanges`), refusing what upstream refuses in its words, and `developHost`, the host's temporary files, environment and exec, which is `Left` on Windows.** `Nix.Eval` exports `inputModuloHashes`, `Nix.Develop.Environment` exports `appendPath`, and `NixConfig` gains `ncBashPrompt`, `ncBashPromptPrefix` and `ncBashPromptSuffix`, which a record built without `defaultNixConfig` needs. (#715)- **`Nix.Builder.Sandbox` gains macOS's sandbox: `SandboxBackend`, `hostSandboxBackend` and `backendFallback`; the macOS defaults (`darwinSandboxPaths`, `darwinImpureHostPrefixes`); a derivation's `DarwinOptions` (`darwinOptions`); the paths a profile names (`darwinPathsInSandbox`, `darwinPathTarget`, `profileFilter`), the profile itself (`darwinProfile`), the helper's macOS plan (`DarwinPlan`, `darwinParameters`, `renderDarwinPlan`) and its macOS steps (`DarwinStage`, `darwinSetupFailureMessage`).** `sandboxUse` takes the host's backend first, `helperOutcome` takes the backend's stage names and report of a failed step in place of a Linux plan, `unavailableMessage` takes the backend, and `SandboxConfig` has two new strict fields, `scAllowedImpureHostDeps` and `scViolationLog`. `Nix.Builder.Sandbox.Spawn`'s `sandboxAvailability` answers the backend with the helper, and `profileFilters` and `resolvedPath` are added. `Nix.Config.NixConfig` has two new strict fields, `ncAllowedImpureHostDeps` and `ncDarwinLogSandboxViolations`. `Nix.Realise` exports `derivationStringAttr` and `derivationStringsAttr`, upstream's `getStringAttr` and `getStringSetAttr`. `Nix.Json` exports `expectJson`, upstream's `ensureType`, which `Nix.Daemon.Protocol` used privately. (#725)- **`Nix.Builder.BuildConfig` has a new strict field, `bcFailedBuilds :: FailedBuilds`, which `defaultBuildConfig` sets to `RemoveFailed`.** `Nix.Builder.BuildDir` exports `FailedBuilds`, `WorkDir`, `workDirIn` and `BuildEnding`, and its `withBuildDir` takes, after the first output, where in the directory the builder works, what a failed build keeps, and how the build's result says it ended. `Nix.Realise`'s `OutputDiffers` and `NotDeterministic` carry a new `DifferingRebuild`, `RebuildKept` or `RebuildDiscarded`, and `checkedOutputPath` names where a kept rebuild is. `Nix.Config.NixConfig` has a new strict field, `ncKeepFailed`. `Nix.Store` exports `moveOutput`, the move a build makes into the store. (#733)- **Library code reports through a `Nix.Logger.Logger` it is given and never writes to standard error itself: a message (a wait on a lock, a collection's progress, a substitution's or a push's progress, a warning, a trace) and each line a builder writes, as the line completes and unfiltered.** `openStore` takes the logger the store's operations report through, which the handle holds as `stLogger`, and a build, a substitution, a collection and a push report through their store's. `withLocalStore`, `newEvalStateWith`, `readProfileEnvironment`, `updateProfile`, `ioRetryEffects`, `queryReferencesWith`, `queryNextOfferWith`, `realiseWithoutWriting`, `withBuildDir`, `clearLeftover`, `runBuiltinBuildenv`, `warnFallback`, `runHelper`, `withChroot`, `streamBuildLog`, Push's `logSkipped`, `logNar` and `logPushed`, and the lock functions of `Nix.Store.Lock` take one, whose busy messages are `Text`, as `Nix.Store.Lock.waitingForLockMessage` and `Nix.Store.GC.findingRootsMessage` are, where they were `String`. `SessionSettings` holds one as `sessionLogger`, and `BuildConfig` no longer has `bcBuildLog`. `handleLogger` writes each report to a handle, a build line filtered for the terminal by `filterLogLine` under `escapeFilterFor`, which move to `Nix.Logger` from `Nix.Builder.Log` with `EscapeFilter`. The command line's output is unchanged. (#741)- **`Nix.Builder.Sandbox` gains the helper's Windows plan (`WindowsPlan`, `renderWindowsPlan`) and its Windows steps (`WindowsStage`, `windowsStageName`), and `ProbeStage` has `ProbePrivileges`, the probe of the privileges that starting a builder as another account takes.** `Nix.Store.Access` exports `sidText`, a `Sid`'s string form. (#743)- **`Nix.Profile.Generation` reads a profile's generations with their times and its current one (`findGenerations`), plans a rollback and a wipe as values (`rollbackPlan`, `wipePlan`), carries them out (`switchGeneration`, `wipeHistory`), and reads `--to` and `--older-than` as upstream does (`readGenerationNumber`, `parseOlderThan`); `ProfileFailure` gains `NoSuchGeneration` and `NoOlderGeneration`.** `Nix.Profile.Manifest.manifestChanges` gives what changed from one manifest to the next, as a profile's history prints it, and `Nix.Store.Metadata.nodeModificationTime` reads a node's own modification time, a symlink's rather than its target's. (#744)- **`Nix.CacheDirectory` holds what is shared by a push to a directory and a substitution from one: `cacheInfoFileName`, `cacheInfoText` and `readCacheInfo`, which returns a `CacheInfo` or a `CacheOpenFailure`.** `Nix.Substituter` no longer exports `sortCaches`, and `readBodyCapped` and `cappedBodySource` take an `IO ByteString` chunk source, the type http-client's `BodyReader` already was. (#745)- **`Nix.Trust.FoundCode` carries the file's SHA-256 in lowercase base-16 (`fcSha256`), `TrustReport` the builder inputs that are one file, by their SHA-256 (`trBuilderBytes`), and `trustReportJson` and `trustReportJsonVersion` render the report as JSON; `Nix.Hash` exports `sha256LazyHex`.** (#757)- **`EvalPolicy` has a field `epExperimentalFeatures` and `NixConfig` one `ncExperimentalFeatures`, each a `Nix.ExperimentalFeature.FeatureSet`; a record built with every field lists it.** `parseSriHash` and `parseNarHash` are exported by `Nix.Hash`. (#773)- **`PathRegistration` has `prUltimate`, `prSignatures` and `prContentAddress`, and `PathInfo` has `piUltimate`, `piSignatures` and `piContentAddress`, with the new `Ultimate` type.** `Nix.Store.DB` has `queryReferrers`, `queryValidDerivers` and `queryPathFromHashPart`. `checkStatedAddress` answers the content address it held the tree to. `indirectRootRecordName` takes the bytes of the link's spelling. `Nix.HostPath` exports `absolutePath`, which `Nix.Profile.Generation` re-exports. `Nix.Daemon.Protocol` exports `parseSignature`, `renderSignature` and `renderContentAddress`, and `Nix.Derivation` exports `drvExtension`. (#749)- **`Nix.Store.Import` imports a path from its NAR with what it claims of itself (`importNar`), refusing, in upstream's words, a path that must be signed and is neither signed by a key given nor content-addressed, a NAR whose hash or size is not the claim's, a tree that does not reproduce the stated content address, an address that does not make the path, and a derivation whose outputs are not the paths its inputs make (`checkDerivationOutputs`); and adds a text as a client adds a `.drv` (`addTextToStore`).** The NAR arrives from a chunk source that ends where the archive ends. `collectGarbage` takes extra roots, kept alive as upstream's temporary roots are, and `deleteSpecificPaths` deletes named paths as upstream's collector deletes them: each with the paths that reference it, all named, referrers first (`referrersFirst`), stopping at the first that stays alive with upstream's refusal. `Nix.Substituter` exports `checkContentAddress`, `Nix.Store.Upstream` exports `upstreamStateDir`, and `Nix.Derivation` exports `fixedOutputModulo` and `inputAddressedModulo`, the modulo-hash rules the evaluator and the store share. (#756)- **The new `Nix.Builder.BuildUser` decides whom builds run as (`buildUsersFor`, `defaultBuildUsersGroup`, `userPoolDir`), chooses a member over a capability record of the user database (`acquireBuildUser`, `UserDatabase`, `Member`), holds one for a build (`withBuildUser`, which alone makes a `BuildUser`, and only in a process that runs as root), kills a member's processes (`killBuildUser`, which the C shim refuses for a caller that is not root) and runs a builder as one (`runAsBuildUser`), and answers whether a daemon is to refuse a peer for its primary group (`peerInBuildUsersGroup`), which `Nix.Daemon.Auth` asks.** `BuildConfig` gains `bcBuildUsers`, so a record built without a default needs it; `defaultBuildConfig` builds as the user nova-nix runs as. `Nix.Config.NixConfig` gains `ncBuildUsersGroup`. `Nix.Store.Metadata.foreignOwnedNode` takes whom the output belongs to (`OutputOwner`), and `ownedByAnother` tests an output's root. In `Nix.Builder.Sandbox`, `PlanInputs` and `SandboxPlan` carry the ids the builder runs as (`BuilderIds`), `DarwinPlan` the build user, `darwinParameters` the build's temporary directory, and the chroot's store directory is a `SkeletonStoreDir`; the plan's format is version 5, which a helper of an earlier release refuses. `Nix.Builder.Sandbox` also exports `setupContext` and `errnoSuffix`, and `Nix.Builder.Sandbox.Spawn.withChroot` takes the build users' group. (#770)- **`Nix.Eval.Context.firstContextEncoded` is replaced by `firstContextDisplayed`, which names a context's first element as upstream 2.34.0 and later display it.** (#776)- **`Nix.Store.Access` gains `StoreAccounts`, the account that keeps the store and the build accounts' group where there is one, which `accessSddl`, `securityDistrust` and `descriptorDistrust` now take in place of a `Sid`, the last two with the `DirAccess` of the directory checked; `StateAccess`, the state directory's access, which `StoreAccess` no longer stands for; `validPathSddl`, a registered path's security descriptor for a node of a `ValidNode` kind, a directory's entries passed down and a file's or a link's with no inheritance flags, which Windows keeps on no such node; and `withValidPathAccess`, the step `Nix.Store.canonicalizeMetadata` takes for each node.** `AllowEntry` carries the entry's flags. (#758)- **`ConfigLocations` has a field `clNixConfigHome`, `NIX_CONFIG_HOME`'s bytes when it is set; a record built with every field lists it.** (#775)- **`Nix.Store.sinkNarStream` takes an `ArchiveEnd` first: `AtEndOfInput` for the archive that ends its input, as it always read one, and `AtRootClose` for one that stops at its root node's close, leaving the rest of the input unread.** Either way the digest and size are of the bytes the parser consumed. `Nix.Store.Import.importNar` reads to the root node's close, as upstream's daemon reads an imported NAR, and pulls no chunk after it, leaving the rest of its source to the caller. (#761)- **`Nix.Daemon.Listen` listens on a socket and serves each admitted client on its own thread (`openListener`, `serveListener`), `Nix.Daemon.Auth` decides admission over a user database it is given (`admitPeer`), and `Nix.Daemon.LocalStore` serves the local store to each connection (`serveLocal`).** `NixConfig` has `ncTrustedUsers`, `ncAllowedUsers` and `ncTrustedSubstituters`, and `Nix.Store.GC` exports `addIndirectRoot`. The library depends on `network`. (#772)- **`Nix.Http.FetchRetryPolicy`'s `frpAttempts` and the retry number `Nix.Http.retryDelayMs` takes are `Word32` where they were `Int`, and `Nix.Config.NixConfig` has a new strict field, `ncDownloadAttempts :: Word32`, which a record built with the constructor needs.** `Nix.Http` exports `defaultDownloadAttempts`, upstream's default number of attempts, and `fileUrlFailure`, the failure of a `file://` URL a fetch cannot read; `Nix.Eval.Policy` exports `fileUrlPath`, the path a `file://` URL names; and `Nix.Store.Path` exports `storeDirDrive`, the drive a store directory is on. (#782)- **A `Nix.Logger.Logger`'s messages have a level (`logAt`, with `LevelWarn` and `LevelInfo`), and a build, a check and a substitution are activities of it (`withActivity`, `ActivityStart`), whose builders' lines are the activity's, so a daemon can pass each on to its client as upstream's daemon passes on its logger's calls.** `logMessage` reports at the info level, and `plainLogger` makes a logger from a message sink and a build-line sink. The command line writes what it wrote before. (#780)- **`Nix.Realise.realiseEach` realises several requests and says how each ended (`RequestOutcome`), or the failure that ended the call, and `planMissing` works out what realising some paths would take (`Wanted`, `MissingPaths`) over the queries it is given (`MissingEffects`).** `Nix.Builder` exports `buildRequestsEach`, `planMissingPaths`, `substitutablePaths` and `readDrvFromStore`, `Nix.Substituter` exports `substituteSizes`, and `Nix.Daemon.Ops` exports `logVerbosity` and `storeActivity`. `Nix.Daemon.LocalStore.newServedStore` takes the machine's defaults. `Nix.Realise.RealiseEffects.reBuild` answers a `FailedBuild`, a builder that stopped or a fixed output refused, and `RealiseFailure` has `FixedOutputRejected` for the second; `Nix.Builder.BuildStop` has `FixedOutputRefused`, which exits as any other stop does, and `stopReported` gives any stop's message and exit code. (#780)- **`Nix.Store.Import` takes a NAR and a dump a chunk at a time: `admitNar`, `beginNarImport`, `feedNarImport`, `endNarImport` and `abandonNarImport` import a NAR, and `beginDumpAdd`, `feedDumpAdd`, `endDumpAdd`, `endedDumpPath`, `placeDump` and `abandonDumpAdd` add a dump as the path its content address makes.** `importNar` is built on them, so it unpacks into a staging directory and moves the tree to its path under the lock, and refuses a reference that is not valid with upstream's message; `replacePath` is exposed for testing. `Nix.Store.DB`'s `PathRegistration` states when its path is registered (`prRegistrationTime`, a `RegistrationTime`), and `statedRegistrationTime` reads a time a path's info states as upstream does. `Nix.Store` feeds a NAR to a sink a chunk at a time (`NarFeed`, `NarFed`, `startNarFeed`, `feedNar`, `endNar`), which `sinkNarStream` now drives, and closes an unpack without making its links (`closeNarUnpack`, `NarLinks`), so its tree can be moved and its links made where it stays (`moveNarUnpack`). `Nix.Key` reads a public key as upstream does (`parsePublicKey`, refused with `PublicKeyNotValid`), and `Nix.Daemon.Protocol` exports `grammarText`. (#799)- **`NixConfig` has `ncRequireSigs` and `ncSecretKeyFiles`, and `CacheConfig` carries them as `ccRequireSigs` (a `RequireSigs`) and `ccSecretKeyFiles`.** `Nix.Substituter.cacheRequirement` reads what a cache's narinfos are held to, and `judgeNarInfo` takes it and answers, beside its verdict, the lines it warns of at the error level; a narinfo no trusted key signed is `NarInfoUnsigned`, warned of with `unsignedWarning`, a trust check that cannot be made is `NarInfoTrustFailed`, and `verifySigs` takes the keys and answers a `Bool`, where it took a `CacheConfig` and answered `Either Text ()`. `Nix.Key` gathers the keys a store trusts (`trustedKeys`, `verifyingKey`) and words a key's refusal (`keyRefusalReason`). `Nix.Logger.Level` has `LevelError`. `Nix.Store` says what a path copied in must be signed by (`SignatureRequirement`) and what a content address makes of a path (`addressMakesPath`, `AddressedPath`, `fixedReferencesRefusal`), and words upstream's warning of one that makes another (`notContentAddressed`) and its refusal to register the path (`addressRegistrable`). (#800)- **`Nix.Daemon.Pipe`, built on Windows alone, makes the daemon's pipe and its instances (`listenPipe`, `nextInstance`, `awaitClient`), reads a client's account (`clientAccount`), connects a client (`connectPipe`), says whether a pipe is there without connecting to it (`pipePresent`), gives the owner a daemon's pipe has (`PipeOwner`, `processPipeOwner`, `pipeOwnerOf`) and its descriptor (`pipeSddl`, `clientPipeAccess`, `daemonPipeAccess`), and resolves accounts (`systemAccounts`); each end's connection is a `Nix.Daemon.Connection.Transport`.** `Nix.Daemon.Auth` admits a Windows account by SID (`admitAccount`, over an `AccountDatabase` that resolves names of an `AccountKind` and computes an account's groups, given an `AccountPeer`), says which pipe owners a client trusts (`trustsPipeOwner`), and `acceptedMessage` takes the peer's process. `Nix.Store.Access` exports the SIDs of SYSTEM and Administrators and derives a service's SID from its name as Windows does (`serviceSid`, `novaNixServiceSid`). The library links `authz` on Windows. (#803)- **The new `Nix.Daemon.StoreChoice` reads a store reference (`parseStoreTarget`, `storeReference`) and chooses whether a command opens the store or goes through a daemon (`chooseStore`, over a `StoreProbe`).** `Nix.Daemon.Dial.addressPresence` says whether anything is at a daemon's address, `Nix.Store.Access.probeStoreWriting` and `StoreWriting` whether a process can keep a store's state directory, `Nix.Daemon.StoreChoice.storeOverride` and `StoreFlag` what a daemon is told of the `store` setting, `NixConfig` has `ncStore`, and `AssignedSettings` and `HowAssigned` are semigroups, so the record of a command line's settings joins the record of the files'. (#810)- **`Nix.Push.Source` is new and holds `PushSource`, `PushedPath` and `localPushSource`, which `Nix.Push` does not re-export.** A `PushSource` gives `psReferences`, the only record `computeClosure` asks, and `psPathInfo`, which `preparePath` asks for a path it sends, so a damaged row of a path the cache already holds does not fail a push. `computeClosure`, `preparePath`, `pushPaths` and `Nix.Push.Directory.pushToDirectory` take a `PushSource` in place of a `Store`, and `checkRecordedNarHash` takes a `PushedPath`. `Nix.Trust.Fetch` is new (`FixedOutputStore`, `fetchAndScan`), and `Nix.Daemon.ClientStore` has `withDaemonPushSource` and `withDaemonFixedOutputs`. (#815)- **`MonadEval` has the methods `fetchUrlBytes` and `fetchArchiveToStore`, so an instance defines them.** `Nix.Http` exports `downloadUrlWith`, the request `builtin:fetchurl` and the fetchers share. The new modules `Nix.Fetch.Tar`, `Nix.Fetch.Tree`, `Nix.Fetch.Archive`, `Nix.Fetch.Download` and `Nix.Compression.Stream` hold the tar reader, fetched trees and their NARs, the tar sink, the downloads, and the decoders. (#816)- **The new module `Nix.Store.Upstream`, which `Nix.Store` re-exports, holds `upstreamDatabasePath`, the database upstream would keep for a store directory, when upstream keeps stores in a directory of that name, and `collectGarbage` and `deleteStorePathRaw` return `Left` for a store with one.** (#442)- **`Nix.Store.Upstream` also holds `upstreamManagedRefusal`, which gives the reason an operation is refused for a store directory upstream Nix's database may also manage, worded for what the operation would do to upstream's paths (`UpstreamHazard`).** For such a store, before they write anything, `Nix.Builder.buildDerivation` and `buildWithDeps` return `BuildFailure`, and `checkDerivation` returns `Left`. `Nix.Substituter.unpackAndVerify` and `fetchSubstituteWith` return `SubstError`, so `Nix.Builder.substitutePaths` returns `NotFetched`, each path `DeliveryFailed`. `Nix.Store.materializeEvalSources` throws an `IOException`, and the `Nix.Eval.IO` evaluator's store writes (`writeToStore`, `copyPathToStore`, `addSourceNar`, `addFixedOutputFile`) fail the evaluation with an error `builtins.tryEval` does not catch. (#452)- **The new module `Nix.Trust` classifies the fixed-output derivations of a `DepGraph` from the graph and from content facts it is given, and renders the report; `Nix.Trust.Scan` reads a fetched output's bytes for those facts.** `Nix.Builder` adds `substituteFromCaches :: BuildConfig -> Store -> [StorePath] -> IO ClosureOutcome`, which substitutes paths from the caches a build uses, each after the paths it references, and builds nothing. (#458)- **`Nix.Hash` exports the decoder, `base64ToBytes :: Text -> Maybe ByteString`.** (#469)- **`Nix.Push` exports `preparePath`, the NAR and the narinfo a push uploads for one store path.** (#473)- **`Nix.Eval` exports `deepForce :: MonadEval m => NixValue -> m ()`, the deep force behind `builtins.deepSeq`, which `nova-nix eval --strict` now runs too.** (#488)- **`Nix.Substituter` exports `narStreamFailure`, the retry class of a streamed NAR's failure, and `withXzAttempt`, which runs a consumer over an xz-decompressed chunk source and ends the attempt with the class of a decoder failure.** (#501)- **`Nix.Store.Metadata` exports `isPlainFile`, whether a node is a regular file its owner may not execute.** (#501)- **`Nix.Eval.CStats` takes a census and renders it: `takeCensus :: [CRoot] -> IO (Either CStatusError Census)`, with the roots a value holds from `valueRoots :: NixValue -> [CRoot]`, and `renderCensus :: Census -> ByteString`.** (#531)- **`Nix.Store.ExecBit` exports `serialiseIfReadable`, which answers `Nothing` for a tree that cannot be read into an archive.** (#561)- **`Nix.Eval.Types` exports `attrSetFromSymbols` and `attrSetFromSymbolEntries`, which build a set from names already interned.** `Nix.Json` exports `parseJsonInto`, which hands each value it reads to a `JsonBuilder`, an object's members in document order with a repeated name each time it appears, as nlohmann's SAX interface does. (#564)- **`Nix.Eval.Types` exports `emptyAttrSet`, the shared set.** `attrSetFromMap`, `attrSetFromEntries` and `attrSetRemoveKeys` give `emptyAttrSet` for an empty result, except a removal from a set with attributes, which makes a set of its own. `Nix.Eval.CAttrSet` exports `cattrsetEmpty`, and `cattrsetInsert` raises on a frozen set, the shared one among them. (#568)- **`Nix.Eval.CEnv` exports `cenvResolveWith`, which resolves the entry at an index of a with-scopes array to the set its thunk evaluated to.** It is the one write into the array after its creation, which a census of regions records. (#617)- **`Nix.Derivation` exports `fixedOutput :: Derivation -> Maybe DerivationOutput`, the one output of a fixed-output derivation.** (#642)- **`Nix.Realise` exports `realiseRequests`, which realises several derivations in one call, each for the outputs a request asks of it, with one record of what is realised, as upstream's `Store::buildPaths` runs a goal for each request with one worker (entry-points.cc at 2.24.9, `Worker::buildPaths` there at 2.36.0).** Requests that name one derivation are realised as one request for every output any of them asks, as they share one goal upstream. Every request is assessed before any is realised, so one whose outputs are valid is realised first, and one whose derivation's attributes cannot be read or that asks for an output its derivation does not have stops the call before anything is substituted or built, as in upstream's first pass over its goals. The requests are realised and never checked, as import from derivation builds under upstream's `bmNormal` (`EvalState::realiseContext` in primops.cc); a check is of one derivation, through `realise`. The first failure stops the call, as upstream's does without `keep-going`. It answers a `RequestsFailure`: `FailedWith` a failure reported as it is, or `FailedLeaving` a request's failure with the requests it left unrealised, which `requestsFailureMessage` reports as upstream's `build of '<drv>', '<drv>' failed`; `requestsFailureStatus` gives the status the call exits with, the one failure's. (#647)- **The new module `Nix.Store.Ops` gives the store a command works against as a record of its operations, `StoreOps`: adding what an evaluation wrote or named, an `EvalObjects` of its sources, written trees and derivations, references first (`soAddEvalObjects`); realising several derivations, each for the outputs a request names (`soBuild`); checking one derivation, every output of it, as `nova-nix build --check` does (`soCheck`); and rooting an out-link (`soAddOutLinkRoot`).** `withLocalStore` runs an action with the operations of the store in a `BuildConfig`'s `bcStoreDir`, which it opens at the first operation and closes once, when the action ends; an add, a build or a check in a store upstream Nix's database manages is refused before the store is opened, since opening it would make this store's database there. `withOpenedOnFirstUse` is the bracket it opens the store with. `nova-nix build` adds, builds or checks, and roots through these operations. `Nix.Builder` exports `buildRequests`, which reads the requested derivations and their inputs from the store and realises them through `Nix.Realise.realiseRequests`, `checkStored`, which reads one derivation from the store and checks it as `buildWithDeps` does under `BuildCheck`, and `BuildStop`, the message and status of a stopped build. `Nix.DependencyGraph` exports `buildDepGraphFrom`, the graph of several roots read as their inputs are. (#653)- **`Nix.Eval.Operator` exports `evalUpdateChain`, which evaluates the operands of a chain of `//` and merges them as upstream's update queue does.** (#656)- **The new module `Nix.Store.Access` creates a directory open to whom a `DirAccess` says (`StoreAccess`, `ParentAccess` or `OwnerAccess`, with `createDirectoryWith`) and a store's state directory with the store directory it is in and any missing parent (`createStateDirectory`), and gives the SDDL a directory is created with on Windows (`accessSddl`), for a `Sid` that `sidFromText` makes only from a SID's string form, `S-1-I-S...`, so no trustee can carry another entry into the DACL.** `Nix.Store.DB` exports `createStoreDirectories`, which `openStore` and `openStoreDB` create a store's directories with. (#659)- **`Nix.Builder.BuildDir` exports `clearLeftover`, which removes what an earlier build left at a path or moves it aside.** (#673)- **`Nix.Store` exports `useStoreFileMask`, which a program building through the library calls to give its builders upstream's mask, `replaceWithCopy` and `freshCopyPath`, and, for testing, `rewriteRegularFile`; `Nix.Store.Metadata` exports `writableByOthers` and `foreignOwnedNode`; and `Nix.Builder.BuildDir` exports `sandboxedBuildDir`, where a sandboxed build's own directory is.** `Nix.Store`'s `placeInStore` and `addToStore` move a path by a rename that fails, rather than copies, except across volumes. (#673)- **`Nix.Store.CaseSensitive` exports `pathCaseHack`, the case-hack mode a read of path-value text runs under given the store volume's sensitivity.** `Nix.Eval.Policy` exports the walk of a path through its symlinks, `walkPath`, pure over path-value text with the read of a link as an argument, and its rules: `PathRules` and `hostPathRules`, `SymlinkResolution`, `LinkTarget` and `linkTarget`, `WalkStop`, `storeRootPrefix` and `windowsLinkTargetJoins`. (#676)- **`Nix.Derivation` exports `inputAddressed`, which makes every output of a derivation input-addressed from the derivation's name and its inputs' modulo hashes and gives the `.drv` file it is written as, as upstream's `fillInOutputPaths` and `writeDerivation` do (derivations.cc), and `drvFile`, the `.drv` file of a derivation as it stands.** A `DrvFile` holds the derivation, its ATerm and its store path (`drvFileDerivation`, `drvFileATerm`, `drvFilePath`). `derivationStrict` fills in an input-addressed derivation through `inputAddressed`, and every drvPath and output path is the one it gave before. `Nix.Eval.Types.storePathOrThrow` unwraps the result of any construction that makes a store path, not only a store path itself. (#694)- **The new modules `Nix.Daemon.Wire` and `Nix.Daemon.Protocol` read and write the worker protocol upstream's `nix-daemon` speaks, as upstream 2.35.4 reads and writes it at every protocol version its serialisers distinguish.** `Nix.Daemon.Wire` is the framing: 64-bit little-endian numbers, each refused above the largest value of the type upstream reads it into; strings padded with zeros to a multiple of eight, refused when the padding is not zeros; lists; and framed streams, read a chunk at a time. Its `Decoder` reads incrementally (`startDecoding`, `feedInput`), so a connection can hand it each read as it arrives. `Nix.Daemon.Protocol` holds the values the protocol carries and their serialisers: versions and features, the handshake's words and what a daemon tells its client after it, store paths, a path's info with its NAR hash, signatures and content address, derived paths, realisations, build results, a collection's action and paths, and the messages and errors a daemon sends while it works. Each reader refuses what upstream refuses, and each writer refuses what upstream's does, in upstream's words, but for a malformed hash, which is worded as `Nix.Hash` words it, after 2.24.9. Realisations and a build's outputs follow 2.35's `realisation-with-path-not-hash` feature where both sides list it, and the older JSON form of a build's outputs where they do not, as 2.35.4 does. `Nix.Hash` exports `parseAnyHash`, `parseHashAlgo`, `digestByLength`, `sriDigest` and `unknownHashAlgo`, which `Nix.Eval` held privately, and the library depends on `binary`. (#695)- **`Nix.Profile.Tree` builds the tree as a value over a `TreeReader`, the capability that reads the packages, so it runs over any store, an in-memory one included: `buildProfile`, `storeTreeReader` for a store on disk, and `writeTree`.** `Nix.Builder.Buildenv` exports the builtin's name, `runBuiltinBuildenv`, and `parseDerivations`, which reads the `derivations` attribute. (#696)- **`Nix.Develop.Environment` holds the build environment upstream's `nix develop` captures and the scripts made from it, as upstream's `BuildEnvironment`, `makeRcScript` and `CmdDevelop::run` make them (develop.cc at 2.35.4).** `parseBuildEnvironment` reads the JSON `get-env.sh` writes, dropping a variable of a kind it does not know as upstream does, and `buildEnvironmentJson` writes it back. `environmentScript` gives the script `print-dev-env` prints, each output's path moved under the working directory, with the structured attributes' files to write; `renderRcfile` wraps it for an interactive shell, `--command` or `--phase`. `ignoreVars` and `escapeShellArgAlways` are upstream's. Where upstream asserts that a variable is set, or replaces a path forever because the text replacing it holds it, these return an error. (#702)- **`Nix.Develop.Capture` makes the derivation upstream's `nix develop` builds to capture a target's build environment (`getDerivationEnvironment`, develop.cc at 2.35.4).** `captureDerivation` refuses a builder whose base name is not `bash`, makes upstream's `get-env.sh` the builder's one argument and an input source, removes the checks on what the outputs refer to (under structured attributes, `outputChecks`, with `__json` written again as nlohmann's `dump()` writes it), names the capture `NAME-env`, and fills its outputs in input-addressed, so a fixed-output target's capture is input-addressed too. `getEnvScriptPath` gives the script's store path, `/nix/store/hyhh9rhzxhzmfspllmpf75xzkzns109r-get-env.sh`, since upstream stores the file after a newline its build puts in front of it; the file ships as `data/develop/get-env.sh`, upstream's 2.35.4 copy under its LGPL-2.1 license. `environmentOutput` picks the output the environment is read from, the first in name order that is a regular file of at least one byte. (#705)- **`Nix.Hash` exports `makeSourcePath`, the path of a tree added by the SHA-256 of its NAR together with the store paths it references, as upstream's `makeFixedOutputPath` makes one under `NixArchive` and SHA-256: the type it hashes is `source` followed by each reference after a colon, in path order (`makeType`, store-dir-config.cc at 2.35.4), which upstream's own fixture for such a path pins.** `makeFixedOutputPath` gives that path with no references for a NAR SHA-256 hash, as it did. (#707)- **`Nix.Hash` exports `ModuloHash`, `moduloHashInit`, `moduloHashUpdate` and `moduloHashFinalize`, a digest modulo a hash part; `Nix.Daemon.Protocol` exports `parseContentAddress`; and `Nix.Substituter` exports `checkStatedAddress`.** (#738)- **`Nix.Derivation` exports `impureOutputHash`.** (#738)- **The local store's `soAddSourceTree` (`Nix.Store.Ops.withLocalStore`) refuses a store directory that upstream Nix's database also manages before it opens the store, as its other adds, builds and checks do, so it no longer makes this store's database there on the way to the refusal.** `nova-nix profile add` and `profile remove`, which add a generation's tree through it, refuse such a store before evaluating anything and are unchanged. (#739)- **`Nix.Eval.Context` exports `inUpstreamOrder`, a context's elements in the order upstream keeps them, and `encodedElement`, an element in the encoding upstream prints.** (#736)- **On Windows `Nix.Store.Access.createStateDirectory`, and through it `Nix.Store.DB.createStoreDirectories`, `openStoreDB` and `Nix.Store.openStore`, refuse a store with a directory another account owns or can change with a `userError`, `Nix.Store.DB.openStoreDBReadOnly` does through the new `checkStateDirectory`, and the new `createStoreDirectory` makes and checks a store's directory as they do, less the state directory, for an evaluation's write.** `Nix.Store.Access` gives the rule as pure functions that work on every platform: `storeDirectories` and `stateDirectories` list the directories checked, `parseSecurityDescriptor` reads a self-relative security descriptor into a `DirSecurity` of `AclEntry` values, `securityDistrust` and `descriptorDistrust` give the `Distrust` that refuses one, and `distrustMessage` words the refusal. `Sid` equality compares the accounts two SIDs name, so the hexadecimal digits of a wide authority may differ in case. (#742)- **`Nix.DrvName` (new) holds the split, `drvNameDash`, which takes the `uncons` of the string it reads, so it counts bytes for `builtins.parseDrvName` and characters for `Nix.Profile.Manifest.drvNameName`.** (#750)- **The new modules `Nix.Flake.Ref`, `Nix.Fetch.Input` and `Nix.Fetch.Attrs` read and write flake references, fetcher inputs and their attributes as upstream 2.36.0 does.** (#773)- **The new modules `Nix.Daemon.Ops` and `Nix.Daemon.Connection` are a daemon's side of upstream's worker protocol, over a store and a transport they are given.** `Nix.Daemon.Connection.serveConnection` runs one connection: upstream's handshake, from 1.18, then each operation the client asks, until its input ends. `Nix.Daemon.Ops` holds what each operation reads before its work begins (`getRequest`), what a client the daemon does not trust may not ask (`authorize`), what a client's settings change for its connection (`applyClientSettings`), and the store the operations run over (`DaemonStore`), a record of upstream's store calls in the protocol's own terms. The operations are those upstream's clients send to build, substitute, copy, query and collect through a daemon; another code is refused as upstream refuses one it does not know, and AddToStore before protocol 1.25 and AddToStoreNar before 1.23, whose uploads are not framed, are refused as their requests begin. A failure before an operation's work closes the connection and one during it is sent and the connection goes on, where upstream's daemon does each; what the store reports as it works reaches the client as upstream's daemon forwards its logger's calls; and an upload's frames are read past after its store stops, as upstream drains them, so the next operation starts at its first byte. Upstream's messages are kept without the colours its formatter adds. `Nix.Daemon.Ops` also writes each request and a client's settings as upstream's client writes them (`putRequest`, `putClientSettings`, `putUploadPathInfo`), refusing in upstream's words a request the agreed version cannot carry, and names the versions the requests change at. `Nix.Daemon.Protocol` reads and writes the replies the operations give (`Missing`, `GCResult`, a derivation's outputs, the roots, build results with the paths they answer) and names the build and substitution activities and the two log-line results. `Nix.Daemon.Wire.DecodeFailed` carries the input after the bytes a refused read took, and `Nix.Daemon.Protocol` exports `parseContentAddressMethod`, `featureDeleteDeadSpecificReferrers` and `defaultExitStatus`. (#755)- **`Nix.Key` reads, makes and spells signing keys, and `Nix.Daemon.Protocol` reads and spells signatures through `Nix.Key`'s `parseColonBase64` and `renderColonBase64`, so a byte outside base64 that is not ASCII in a signature the daemon receives is named as the character of its value, where it was named as the UTF-8 character it began.** (#765)- **The new `Nix.Signals.interruptOnTermination` has SIGTERM and SIGHUP throw `UserInterrupt` to the calling thread, as the runtime does at SIGINT, and does nothing on Windows.** (#778)- **`Nix.Builder.Settings` gives the build configuration a store's settings give (`settingsBuildConfig`): the caches, fallback, the `allowSubstitutes` setting, how many times a download is tried (`settingsFetchRetry`, from `download-attempts`), cores, the sandbox, the build users and what a failed build keeps, each with upstream's default where no setting gives it.** The defaults only the machine can tell (`MachineDefaults`: the cores, the sandbox helper and bundled shell, whether the process is root, the user pool's directory, the certificate bundle) are found once (`machineDefaults`), so a daemon gives each operation the configuration its connection's settings give without looking again. The command line applies its flags to the settings first, as upstream's flags set settings, and builds as it did. (#780)- **`Nix.Builder.Unpack.envOmit` is new.** (#762)- **The new `Nix.Daemon.Client` is a client of a daemon that speaks upstream's worker protocol, as upstream's remote store is one, over a transport it is given (`Nix.Daemon.Connection.Transport`).** `runClient` makes upstream's client handshake, offering the newest version and the features the codec carries (`offeredVersion`) and refusing a daemon older than 1.18, then runs a session's operations (`ClientT`): `setOptions`, the queries (`isValidPath`, `queryValidPaths`, `querySubstitutablePaths`, `queryReferrers`, `queryValidDerivers`, `queryDerivationOutputMap`, `queryAllValidPaths`, `queryPathInfo`, `queryMissing`), the framed uploads `addToStore` and `addToStoreNar`, `buildPaths`, `buildPathsWithResults`, `ensurePath`, `addTempRoot` and `addIndirectRoot`. What the daemon says while it works goes to a report the caller gives. A daemon's error is a `DaemonFailed` that `attempt` catches, the session going on; a request the agreed version does not carry is not sent (`NotSent`), so a daemon older than 1.19 is not asked `queryMissing`, one older than 1.22 `queryDerivationOutputMap` and one older than 1.34 `buildPathsWithResults`, whose answers upstream's client works out itself; a broken connection is a `ConnectionLost`. Requests are written as `Nix.Daemon.Ops.putRequest` writes them, so below 1.27 `queryValidPaths` sends no substitute flag, as upstream's client sends none. (#781)- **`Nix.Store` exports `checkNarClaim`, which holds an archive's hash and then its size to what a path's info claims, and `narHashMismatch` and `narSizeMismatch`, upstream's refusal of each.** (#768)- **The new `Nix.Daemon.ClientStore` gives a command's store operations (`StoreOps`) through a daemon, as upstream's remote store does for its commands.** `withDaemonStore` runs an action over a connection made at the first operation that asks the daemon something and closed when the action ends, so a command that asks nothing of the store never connects. After the handshake the client sends its settings as upstream's remote store does, unless the daemon grants `disable-set-options`, which `Nix.Daemon.Client.offeredVersion` offers as upstream's client does. `clientSettings` builds them from the configuration: keep-failed, fallback and cores as set, cores 0 where nothing sets them as upstream's client sends its own default, and upstream's defaults for the rest. A daemon takes a client's cores as upstream's does, so a client's 0 gives a build the default count of the machine it runs on, whatever the daemon's own `cores` says. Queries ask the daemon which paths are valid and what a path references. An evaluation's copies of paths and its derivations are sent to the daemon as upstream's client sends them, each derivation after every source and derivation it refers to, because a daemon needs each reference valid first, and the path the daemon answers must be the one evaluation computed. Each copy and derivation is given a temporary root before the daemon is asked which it holds, and so is a fetched path evaluation adopts, as upstream roots a path before it skips sending it, so a collection between the question and the use cannot remove what the client relies on. A daemon's refusal fails the operation with its message and the connection goes on. A connection that cannot be opened, in its connecting, its handshake or its settings, fails the operation that tried, and every operation after fails with upstream's `opening a connection to remote store '...' previously failed` without trying again. Only a failed handshake is worded `cannot open connection to remote store '...': ...`, as upstream words one; an error from making the connection, or from the settings, is reported as it is. A store is named `daemon` at the default socket and otherwise `unix://` and the path with each segment percent-encoded as upstream's `encodeUrlPath` encodes it (`Nix.Fetch.Url.encodeUrlPath` is exported for it). A connection that breaks, or whose upload fails reading a local file, is closed and the next operation opens another, which holds none of the earlier one's temporary roots. A source an add cannot read (a file or directory the process may not open, which the archive walk reports as `NovaCache.NAR.NarWalkError`) fails the add with the access's words, on a store over a daemon and on the local store alike, where `soAddEvalObjects` answers `Left` as it does for any refusal. A framed upload (`addToStore` and `addToStoreNar`, which run in `ClientT IO`) reads the daemon's messages on a thread of its own while it sends, so a daemon that answers each chunk with more output than the connection holds cannot stall it. A session that outlives one call is `openSession` and `continueSession` in `Nix.Daemon.Client`. `Nix.Daemon.Dial` connects to the daemon's Unix socket, or on Windows to its named pipe, and a refused connection to either is worded as upstream words it, with the address in double quotes. `soEvalWrites` lets a store take each tree evaluation writes as it is made (`builtins.toFile`, a fetcher's result, a copy of a path) where the store's directory cannot be written: it is handed an `EvalWrite`, a `TextWrite` (the only write that names references), a `FlatWrite` or a `NarWrite`, and answers whether it holds a path evaluation adopts. A read-only session hands over only what a fetcher fetched, and never adds what evaluation made. `Nix.Store.drvReferences` is exported. (#805)- **A store through a daemon (`Nix.Daemon.ClientStore.withDaemonStore`) builds, checks and roots out-links, as upstream's remote store does.** `soBuild` asks the daemon to build each derivation's named outputs, and a request that names no output is not asked; `soCheck` asks it to build every output of a derivation again under the check mode. A build the daemon fails stops with the daemon's message and its status, which from protocol 1.26 on is 1 because the daemon does not send it, as upstream's client reads it; a connection that cannot be used stops it with the reason and status 1. `soAddOutLinkRoot` makes the link in the client, refusing a link inside the store before the daemon is asked anything and a file in its place once the daemon holds the path with a temporary root, as the local store refuses them, and records the link's absolute spelling with the daemon as an indirect root; `Nix.Store.GC.makeOutLinkRoot` does it over a `LinkRooting`, which says how a store holds the path while the link is made and records the link, and `addOutLinkRoot` is that over a local store, whose lease already holds collection off. A daemon on Windows records a link by its drive-qualified or share spelling, collapsed over the host's separators and roots, and refuses a link that is not absolute before any work begins, as it has no directory to take one from; a daemon on POSIX takes a relative link from `/`, as upstream's does. The store settings a source set are sent as overrides, each under its own name whichever alias or `extra-` spelling set it, spelled as `nix.conf` spells it, and none that was left at its default. Only the settings nova-nix's configuration reads can be sent, so a store setting it does not read (`builders` and `connect-timeout`, for example) is not, whatever a source says. `clientSettings` takes the `Nix.Config.AssignedSettings` that `Nix.Config.loadConfigAssigned` reports beside the configuration (`assignedSettings` reads them from assignments), which records for each setting whether a plain assignment replaced it or only `extra-` assignments added to it, and `storeSettingOverrides` writes them. A list is sent in full under its own name, as upstream's client sends it. The default of `substituters` and of `trusted-public-keys` is empty here and names cache.nixos.org and its key in upstream's client, which sends a daemon the default and then the entries added to it, so a list that only `extra-` assignments built is sent with those two defaults before its entries (`https://cache.nixos.org/` and `cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=`), none merged and none dropped, and so is one whose `extra-` assignments added nothing. A list a plain assignment replaced is sent as it resolved. A daemon at upstream's defaults then keeps cache.nixos.org, and an untrusted client's added cache that the daemon trusts passes its filter, which takes the plain `substituters` name from such a client. A trusted client of nova-nix's own daemon that only extends either list turns on cache.nixos.org and its key there, as upstream's client would, and one that is not trusted has cache.nixos.org dropped from its list with upstream's warning unless that daemon's `substituters` or `trusted-substituters` names it. A set of paths that keeps its default is sent as an `extra-` assignment of the paths a source added, and not at all when it added none, because its default (the sandbox shell the binary was built with, the system paths of macOS) is not held here and is the daemon's to apply. A setting upstream declares on some systems only is sent from those alone, as upstream's client has it there alone: `sandbox-dev-shm-size` from Linux, `sandbox-build-dir` from Linux and FreeBSD, `darwin-log-sandbox-violations` from macOS, and `require-drop-supplementary-groups` from every system but Windows. Upstream's client takes the settings the options message carries as fields (keep-failed, fallback and cores), `experimental-features` and `use-xdg-base-directories` out of its overrides and sends only its store library's and its file transfer's settings, so the evaluator's settings, `develop`'s prompt and the daemon command's `trusted-users` and `allowed-users` are not sent. What the daemon says while it works reaches the command's logger as the calls the local store makes for the same work: a message as a message at the error level, as upstream's client reports one, a build or a substitution as an activity of the logger that its builder's lines and its stop belong to, and a post-build hook's line as a message, through `Nix.Daemon.Client.Relay`. `Nix.Daemon.Ops.activityStart` reads an activity a daemon starts as the store's own, the inverse of `storeActivity`, and a build on a machine or a repair as a build. An activity a failed operation leaves open is stopped when the operation ends, before another operation on the same store starts. `Nix.Builder.Sandbox.renderSandboxMode` is the spelling `parseSandboxMode` reads back. (#807)- **`Nix.Store.DB.openStoreDB` and `openStoreDBReadOnly`, and `Nix.Store.openStore` through the first, refuse a store whose paths all lie under another directory with a `userError`.** `Nix.Store.DB.foreignStoreDir` gives the directory a row was recorded under when it is not the one given, and `storeRowRange` gives the range of row text that lies under a store directory. (#818)### CLI- **`nova-nix --help` lists each flag under the commands that take it, and each nix.conf setting with what it does, printed from one reference of the CLI that `docs/cli.json` also renders.** The help named the command for some flags and not for others, so `--strict`, which `build` refuses, read as a flag of every command. Two entries said what the code does not do: `--trusted-key` was the key for the substituter, but a trusted key is checked against the signatures of every substituter, those nix.conf configures included; and `--pure-eval` left no search path, but the bundled `<nix/*>` expressions stay on it, as upstream still resolves `<nix/*>` from its built-in copy. `--expr` and `--cache`, which appeared only in the command lines, have entries of their own; `push` has a line for `PATH...` and one for `--all`, one of which it requires; the usage line is `nova-nix COMMAND [FLAG...]`, where it named `--nix-path` alone of the flags that may come before a command; the system nix.conf directory is given for both platforms; and the text wraps at 80 columns. The test suite checks the reference against the parser, that every command it lists for a flag accepts the flag and that a flag takes a value exactly when its entry names one, and runs each example that shows its output. (#413)- **`nova-nix build --check` builds a derivation again beside its valid outputs and fails when one comes out different, as `nix-build --check` does.** A path that came from a binary cache was only ever trusted; a check holds it to a build. The rules are those of upstream's build mode `bmCheck` at 2.24.9. The mode covers the derivation the build was asked for and no other: its inputs are substituted or built as ever (`DerivationGoal::gaveUpOnSubstitution` gives each input's goal `bmNormal`), since the rebuild needs them and a path that was substituted never fetched them. An output that is not valid is substituted first, as under any mode, and a derivation still short of an output stops with upstream's `some outputs of '<drv>' are not valid, so checking is not possible`, before any input is looked at (`outputsSubstitutionTried`). The derivation itself is then built here and never substituted. Its builder writes each output to a scratch path while the valid one stays where it is, the scratch path's hash is rewritten to the output's own in what the builder wrote, so that an output holding its own path or a sibling's compares equal, and the NAR hash of the result is compared with the one the store recorded, which is all upstream compares (`registerOutputs`, local-derivation-goal.cc). The first output that differs stops the check with upstream's `derivation '<drv>' may not be deterministic: output "<path>" differs`, after nova-nix's own `build failed (exit 104):`, and the command exits with upstream's status for it, 104 (`Worker::failingExitStatus`), so a caller can tell it from a build that broke; every other failure still exits 1, where upstream's status for a failed builder is usually 100. Whatever the comparison finds, the rebuild registers nothing, the outputs it is compared with are as they were, and what it wrote is removed, unless `keep-failed` keeps the rebuild of an output that differs; the substitutions and builds before it add to the store as in any build. A fixed output is held to its declared hash first, and a reference cycle between the rebuilt outputs fails a check as it fails a build. A check that passes is logged as `[check]`. Five things differ from upstream. Its `run-diff-hook` and `diff-hook` settings, which run a program on the valid output and the rebuilt one before the check fails, are not implemented. It marks a path it has checked as ultimately trusted and signs it; nova-nix's check does neither. A check here wants every output of the derivation valid, where upstream's wants only the outputs the build asked for, which for `nix-build` is the one it prints. nova-nix checks as upstream does outside a Linux sandbox, through the scratch path and the rewrite, in its own Linux sandbox too: an output that holds its own path where a rewrite of the hash cannot reach it, compressed for one, differs under a check here, as it does under upstream's on macOS, and not under upstream's in a Linux sandbox, which builds at the output's own path inside a chroot. And a builder is handed its output under the directory its store's files are in, as before, where upstream builds a store kept outside its own directory only in a Linux chroot that shows it there: an output that records its whole path therefore checks equal here only against one built in a store kept in the same directory. (#425)- **`nova-nix trust` reports what a derivation's closure relies on: its fixed-output derivations, those a build runs as builders and those holding prebuilt code, each file named with its kind, those not fully read, and the builders and sources the closure takes from outside itself.** Every closure bottoms out in fixed-output derivations, whose bytes a hash pins whatever fetches or builds them, but which of them are readable source and which are prebuilt code was not visible anywhere. The classification rests on facts, never on a name or a URL's suffix, which this repository's own recipes disprove: stage0-pe32's source archive also holds the `hex0-seed.exe` its chain starts from. One fact is in the graph: a fixed-output derivation runs as a builder when a derivation's builder is inside its output, or inside the tree a builtin such as `builtin:unpack`, which runs nothing from the closure, makes from it and any others. Each entry says whether a builtin fetched it or the closure built it, and names any other fixed-output derivation pinned to the same hash, as stage0-pe32's `hex0.exe`, built by running the seed, is pinned to the seed's. The other fact is in the bytes: prebuilt code found by its header, a PE image, an ELF file (an image or an object), a Mach-O file, a COFF object in the plain or the bigobj form, or an ar archive such as a static library, whose members are not read. The scan looks in a fetched file, in each file of a fetched tree, and in each file of a tar archive, plain or compressed with gzip, bzip2, xz or zstd, the format told by the bytes. An archive inside another is not opened, and a file in another archive format the scan knows, such as zip or an MSI installer, is reported as not read rather than as holding no prebuilt code. A fixed-output derivation that a builtin fetches with no input of its own is fetched first, or substituted, so that its bytes can be read; any other is only substituted, with the paths it references, from a cache that holds it, since making it would run its builder, so nixpkgs' `fetchurl` and `fetchFromGitHub`, which run `curl` or `git`, are read when a cache holds their outputs. Such a substitute is taken whatever the derivation's `allowSubstitutes` says, since the attribute chooses between building and substituting and trust builds none of these. A failed substitute of such an input stops the command, as upstream's substitution of a path fails when a substituter fails, whatever `fallback` says (`PathSubstitutionGoal::init` at 2.24.9), and a fetch that fails stops it too. nixpkgs' `meta.sourceProvenance` is not read: it is a maintainer's claim, made during evaluation and absent from the `.drv`. The report says what the closure relies on, not whether any of it is safe. (#458)- **`--help` and `--version` are answered after every command, as they were after `build` and `trust`, and a run whose stdout has lost its reader, as `nova-nix --help | head -1`, reports nothing and ends with the status its work gives it.** `eval --help`, `push --help`, `store --help`, `store delete --help` and `store gc --help` failed with the parser's `unknown ... flag: --help` and status 1. A write to stdout after its reader had gone, such as the help's second line once `head -1` had read the first, failed with `error: <stdout>: hFlush: resource vanished (Broken pipe)` and status 1, and `store delete`, which prints each path as it deletes it, stopped after the first. Upstream's main thread blocks SIGPIPE (`startSignalHandlerThread`, libutil/unix/signals.cc at 2.24.9), so a write through `std::cout` to a pipe with no reader fails with EPIPE, which only sets the stream's error state: nix-instantiate writes its result that way (`processExpr` in nix-instantiate.cc), nothing is reported, and the command goes on to its own exit status. nova-nix now drops the rest of a write to stdout once its reader has gone, and still reports any other failure of a write. (#471)- **A Boolean setting given a value it cannot take is refused naming the setting, where it named the alias it was set through: `build-fallback = maybe` is refused as `Boolean setting 'fallback' has invalid value 'maybe'`, as upstream refuses it.** Upstream's `BaseSetting<bool>::parse` (config.cc at 2.24.9, configuration.cc at 2.36.0) throws with the setting's own name, which `Config::set` reaches through the alias's entry in the same table, and nova-nix's integer settings already named theirs that way. `fallback` is the only Boolean setting nova-nix reads that has an alias. (#472)- **`push` uploads a NAR larger than 64 MiB in parts of 64 MiB through nova-cache's multipart upload, so a cache behind a proxy that refuses a large request body takes it.** Each NAR went in one `PUT /nar/<file>`, which Cloudflare, in front of cache.novavero.ai, refuses with 413 for a body over 100 MB. Upstream's `HttpBinaryCacheStore` also sends each file in one PUT (`upsertFile` in http-binary-cache-store.cc), so the parts follow nova-cache's protocol: `POST /nar/<file>/uploads` begins an upload, `PUT /nar/<file>/uploads/<id>/<n>` sends each part in order, and `POST /nar/<file>/uploads/<id>` completes it with the part count and the total size. A NAR of 64 MiB or less still goes in one PUT, and so does a larger one when the cache answers the beginning with 404, as a nova-cache without the multipart upload does, so a push to such a cache works as before. A part, or the request that begins an upload, that fails as upstream's transfer layer retries a transfer, its response lost or an error status such as 503, is sent again with upstream's attempts and backoff, which it applies to an upload as to a download (`TransferItem::finish` in filetransfer.cc): the server replaces a part it holds, so a part that did arrive is not doubled. A part answered 404 or 409 means the server no longer holds the parts before it, and a new upload begins. A completion answered with anything but 200, or not at all, may still have joined the NAR, so the push goes on and the narinfo decides: the server checks its FileSize and FileHash against the stored NAR, and a narinfo it refuses then uploads the NAR again. The narinfo is sent in the second phase with the others, so a path is still never announced before its references. A push begins at most three uploads of one NAR, then fails naming the request and the server's answer. A push request that gets no response is reported with the client's failure alone, where it printed the client's whole request record, and a refused `narinfo-hashes` request carries the server's message. The compressed NAR is still held in memory whole, as for one PUT: nova-cache's zstd encoder is one-shot, and an upload is begun under the object's name, which for zstd is the hash of the whole compressed file. (#560)- **`nova-nix build` links its output from `./result` and makes the link a root the garbage collector keeps, as `nix-build` does, and `--no-out-link`, or its other spelling `--no-link`, links nothing.** It linked nothing unless `--out-link` was given. The link is named as nix-build names it (the loop over the built outputs at the end of `main_nix_build` in nix-build.cc): `./result`, or the path `--out-link` gives, for the output `out`, and that path with `-NAME` appended for any other output, so `-A dev` links `./result-dev`. nix-build's `-2`, `-3` and so on for a second and later derivation do not arise, since `build` builds one. The link is made and registered as an `--out-link` was, by upstream's `addPermRoot` rules: a link already there that points into the store is replaced, and anything else at the path fails the command after the build, with no path printed. A build that fails, or a check that finds an output different, links nothing, since upstream's `Store::buildPaths` throws before nix-build links (`main_nix_build` in nix-build.cc, and build/entry-points.cc at 2.24.9, where 2.36.0 has `Worker::buildPaths`). nix-build's `--no-out-link` links into a temporary directory it deletes on exit (the `tmpDir` and the `--no-out-link` case of `main_nix_build` in nix-build.cc), which leaves a dangling record that its next collection removes with a `removing stale link` line (`LocalStore::findRoots` in gc.cc); here nothing is linked or recorded, which leaves the store as upstream leaves it, less that record. Of several link flags on one command line the later wins, as nix-build's does, since it sets its link as it reads each flag (the `--no-out-link` and `--out-link` cases of `main_nix_build` in nix-build.cc): `-o a --no-out-link` links nothing, `--no-out-link -o a` links `a`, and `-o a -o b` links `b`, where a second `--out-link` was refused. A script that runs `build` now leaves `./result` in its working directory, and since a link into another store is replaced only when that store is the platform store, a script that builds into two scratch stores from one directory fails at the second build's link; `--no-out-link` keeps such a script as it was. On Windows the link is a symlink, which needs Developer Mode or an elevated shell, so without either a build fails at its link unless `--no-out-link` is given. (#638)- **`push --cache file:///DIR --secret-key-file KEY` writes a binary cache to a directory, as upstream's `nix copy --to file:///DIR` does, so builds can be shared from any static web server or file share.** `push` reached only a nova-cache server, which signs what it receives. The directory gets the layout upstream's `LocalBinaryCacheStore` writes at 2.24.9: `nix-cache-info` holding `StoreDir: /nix/store` (`BinaryCacheStore::init` in binary-cache-store.cc), without which upstream's HTTP substituter reads no cache, a `<hash>.narinfo` for each path, and its NAR under `nar/`, named by the hash of the file (`BinaryCacheStore::addToStoreCommon` in binary-cache-store.cc). It also gets the empty `realisations`, `build-trace-v2` and `log` directories. Upstream's `file://` store creates `nar`, its realisations directory and `log` whenever it opens a cache, to read it as well (`LocalBinaryCacheStore::init` in local-binary-cache-store.cc), and a reader that cannot create them, without write access to the directory, drops the cache with only a warning (`getDefaultSubstituters` in store-api.cc at 2.24.9, store-registration.cc at 2.36.0). The realisations directory is `realisations` through Nix 2.34.9 and `build-trace-v2` from 2.35.4, so both are made. Each narinfo is signed with the secret key, a file in the form `nix-store --generate-binary-cache-key` writes, as upstream's binary cache store signs every narinfo with the key its `secret-key` setting names (`BinaryCacheStore::addToStoreCommon` in binary-cache-store.cc at 2.24.9, `BinaryCacheStore::uploadNarInfo` at 2.36.0). A key file whose second half is not the public key of its seed is refused, since upstream's signer, libsodium's, signs with that half as the public key, and what it signs with such a key verifies under no key. A path whose narinfo is in the directory is skipped and a NAR whose file is there is not written again, as upstream skips them; every NAR is written before any narinfo; each file is written beside its name and renamed onto it, with the permissions the umask leaves, so a web server running as another user can read it; and a `nix-cache-info` naming another store directory is refused in upstream's words. The NARs are uncompressed unless `--compression zstd` is given, where upstream's default is xz: nova-cache decodes xz but has no encoder. A `file://` cache needs `--secret-key-file`, since a substituter refuses a narinfo with no signature, nova-nix's and upstream's alike, unless `require-sigs` is off, the path is content-addressed, or, for upstream's, the cache is marked trusted; it refuses `--key-file`, a server's API key, and a server refuses `--secret-key-file`. A `file://` URL names an absolute path after an empty host, as upstream requires, and not a filesystem root such as `file:///`, which a variable that expanded to nothing leaves; one with a query, a fragment or a percent-escape is refused, since upstream reads the query as store settings and decodes escapes, and on Windows `file:///C:/DIR` names `C:/DIR`. A `--cache` that is no `http://`, `https://` or `file://` URL is refused before the store is opened, where it failed at the first request. (#639)- **`nova-nix eval`, `build` and `trust` take a directory, a `<NAME>` the search path finds, and `--arg` and `--argstr`, and call a function the target evaluates to, as `nix-instantiate --eval` and `nix-build` do.** They took a file or `--expr` alone, and kept a function as the value it is. A directory stands for its `default.nix` (`resolveExprPath`, eval.cc). An argument longer than two characters and written in angle brackets is found and read as `import <NAME>` finds and reads its file (`lookupFileArg`, common-eval-args.cc): a name the search path does not hold fails with the same message, and a file found in the store keeps its store path, so a path literal in it names a place in that store path and the target gives the derivation `import <NAME>` gives. `--arg NAME EXPR` passes an expression, parsed with its relative paths against the working directory before the target is read and evaluated only when the function uses it, and `--argstr NAME STRING` a string; a later flag for a name replaces an earlier one (the `--arg` and `--argstr` flags of the `MixEvalArgs` constructor and `MixEvalArgs::getAutoArgs` in common-eval-args.cc). The expression, the string and a `<NAME>` are the bytes the command line gives, as upstream reads them; a name is an attribute name, which is text here, so one whose bytes have no UTF-8 reading is refused. A function with a set pattern is called as upstream's `autoCallFunction` calls it (eval.cc): one that takes `...` with every argument, any other with the arguments its formals name, its defaults filling the rest, and a set with `__functor` as the function its functor gives. A formal with neither an argument nor a default fails with upstream's `cannot evaluate a function that has an argument without a value` message, which upstream follows with the formal's position and nova-nix, whose formals carry none, does not. `eval` calls the value only when an argument is given, as `nix-instantiate --eval` does (`processExpr` in nix-instantiate.cc). `eval --aterm` takes any of these targets, where it took only `--expr`, and calls the value whether or not an argument is given, as `nix-instantiate` does before it writes a derivation (`getDerivations` in get-drvs.cc). `build` and `trust` call it before each component of the `-A` path is selected from it and once the path has selected it, as `nix-build` does through `findAlongAttrPath` and `getDerivations` (attr-path.cc, get-drvs.cc), so `build '<nixpkgs>' -A hello` calls nixpkgs' function before it selects `hello`. A URL or `channel:` target, which upstream downloads, `--arg-from-file` and `--arg-from-stdin` are not accepted, and a command given no target still asks for one, where upstream reads `default.nix` in the working directory. (#644)- **`nova-nix eval`, `build` and `trust` read `--expr` as the bytes the command line gives, as upstream does.** The expression was decoded as text first, so a byte with no reading in the file-system encoding, such as a Latin-1 byte in a string literal, became U+FFFD and could change a derivation without a word. On Windows, where the command line is UTF-16, an expression holding an unpaired surrogate, which has no UTF-8 form, is refused. (#644)- **`nova-nix eval` computes the store paths of `builtins.toFile`, `builtins.path` and `builtins.filterSource` without writing them, as `nix-instantiate --eval` does, and `--read-write-mode` writes them as `eval` did before.** `eval` wrote each such object into the store, making the store if there was none, so evaluating `builtins.path { path = ./f; }` changed the store and, in a store upstream Nix also manages, failed where upstream prints the path. `nix-instantiate --eval` runs read-only (`main_nix_instantiate` in nix-instantiate.cc): it copies with `FetchMode::DryRun` (`addPath` in primops.cc) and names a `toFile` result without adding the text (`prim_toFile`), and `eval` now gives the same paths and writes none of them. `trust` evaluates the same way, so in a store upstream Nix manages it no longer fails on a `toFile` or `builtins.path` the evaluation makes. What a fetcher fetches is still written, and now registered as it lands, making the store's database if there is none, since upstream's fetchers add their results in any mode (`fetch` in fetchTree.cc, `downloadFile` in tarball.cc and `Input::fetchToStore` in fetchers.cc at 2.24.9); a fetch pinned by a `sha256` whose path the store already holds returns that path without downloading or writing, as upstream's does (`fetch` in fetchTree.cc at 2.24.9, and at 2.34.9, whose ensurePath returns at once for a valid path), so a second evaluation of the same pinned fetch does not download it again. `--read-write-mode` evaluates as `build` does: it writes what evaluation makes, adds it and every derivation it recorded to the store once evaluation succeeds, so a later evaluation finds them valid, and adds nothing, and so is refused nothing in a store upstream Nix manages, when evaluation made nothing, and builds or substitutes what an import from derivation names, through `--substituter`, `--trusted-key`, `--fallback` and `--exec-wrapper`, which `eval` now takes. `nova-nix build` writes as before. (#668)- **`nova-nix profile add`, `profile remove` and `profile list` keep a profile of generations in upstream's layout, each generation a root the garbage collector keeps, so a package added to the default profile puts its programs under `~/.nix-profile/bin`.** They are `nix profile`'s commands of those names at 2.35.4. A profile is a link to one of its generations, `PROFILE-1-link`, `PROFILE-2-link` and on beside it, and each generation is a store path named `profile` holding the packages' files linked into one tree, as `builtin:buildenv` links them, and a `manifest.json`, version 3, written byte for byte as upstream writes it, added as a NAR-hashed path whose references are every package's paths, as upstream adds it, so its store path is computed the way upstream computes one. A new generation is one past the highest, unless the highest already names the path, and each is linked as `build` links its output, so it is an indirect root `store gc` follows and `store gc --print-roots` lists. The default profile is upstream's for a user who is not root: `profiles/profile` under `$NIX_STATE_HOME`, else `$XDG_STATE_HOME/nix`, else `~/.local/state/nix`, and on Windows `nix\state` under the Local AppData folder, linked from `~/.nix-profile`, or from `profile` in the state directory when nix.conf's `use-xdg-base-directories` is on; every profile command makes the directory and the link when they are missing, as upstream's do, and `--profile` names another profile. `profile add` takes what `build` takes and builds the outputs upstream installs (the one `outputSpecified` selects, else those `meta.outputsToInstall` names, else every output), or a store path, or a link into the store such as `./result`; names the package after its paths' names without their versions, with `-1`, `-2` and on appended to a name already taken; gives it `--priority`, 5 by default; and fails a file two packages of one priority hold with upstream's message, its hints naming nova-nix's commands. `profile remove` takes a name, a store path, `--regex` (a POSIX extended regular expression matching the whole name, ignoring case) or `--all`, prints upstream's lines, and refuses a line that selects nothing, or `--all` beside another selector, as usage errors, reported as nova-nix reports its other usage errors. It refuses a number as upstream refuses an index, in words of its own, `does not support indices`: upstream's say it no longer supports them, which describes upstream's history, and nova-nix never took one. `profile list` prints upstream's lines, a name in bold and `(inactive)` in red where 2.36.0 styles stdout, on a terminal whose `TERM` is not `dumb` or wherever `CLICOLOR_FORCE` or `FORCE_COLOR` is set, and never under `NO_COLOR` or `NOCOLOR` (a name holding an escape sequence of its own keeps it there, where 2.36.0 takes every escape out of the line), or with `--json` the manifest, indented when stdout is a terminal unless `--pretty` or `--no-pretty`, upstream's flags, say otherwise. Manifests of versions 1 to 3 are read. Where nova-nix differs from upstream: a change reads the profile's link, makes the new generation's store path, then takes the profile's lock, `PROFILE.lock`, and starts again with upstream's `changed while we were busy; restarting` if the link moved meanwhile, as `nix-env` does; upstream's `nix profile` takes no lock, so two changes at once there can both start from one manifest and the later drop what the earlier added. The lock file stays once released, as every nova-nix lock file does. Every profile command refuses a profile whose current generation is outside the store it uses, the store and the profile compared with their links resolved, and names `--store` and `--profile`, since a user with upstream Nix installed shares `~/.nix-profile` with it while nova-nix's store is elsewhere, and a generation read against the wrong store names paths that store does not hold; upstream has one store, and its `profile list` lists any profile. And a profile only `nix-env`'s `manifest.nix` describes is refused rather than read, a version 1 or 2 manifest's flake element, which upstream names from its URL, is refused, a flake element of version 3 keeps the fields it was read with where upstream parses and renders them again, and `--priority` takes an int with no binary unit suffix, where upstream takes a suffix and narrows a 64-bit value. Root's profile is where any user's is, where upstream keeps root's under its state directory. On Windows every link is a symlink, which needs Developer Mode or an elevated shell, and a switch removes the profile's link and makes it again, since a rename cannot replace a directory link there. (#713)- **`nova-nix develop` starts `bash` with the build environment of a derivation, and `nova-nix print-dev-env` prints that environment, as upstream's `nix develop` and `nix print-dev-env` do, on Linux and macOS.** Both take `build`'s targets and its evaluation, store and sandbox flags. A derivation whose builder is not `bash` is refused in upstream's words. The environment is captured as upstream captures it: a copy of the derivation named `NAME-env`, whose builder runs upstream's 2.35.4 `get-env.sh` to write what bash holds once the stdenv's setup has run, so that the copy's path is upstream's at 2.34.9 and 2.35.4. The copy is built or downloaded with what it depends on, as `build` builds, and a second run builds nothing. The shell runs upstream's rcfile: `--command` runs a command with every argument after it, `--phase` and the phase flags (`--unpack` through `--installcheck`, `--check` among them) run a phase through `runPhase`, and the `bash-prompt`, `bash-prompt-prefix` and `bash-prompt-suffix` settings set an interactive shell's prompt. `--ignore-env`, `--keep-env-var`, `--unset-env-var` and `--set-env-var`, with 2.24.9's spellings as aliases, shape the shell's environment, which also gets `NIX_GCROOT` and `SHELL`; their conflicts are upstream's usage errors, and those upstream finds only once the environment is built are found then here too. nova-nix replaces itself with the shell, as upstream does, so that the shell has the terminal and its signals to itself and the command exits with its status, and no descriptor nova-nix holds, such as a connection a substitution left open, reaches the shell. The shell is `bash` found on the `PATH` of the environment it starts with, which is what upstream starts with flakes off, where `nixpkgs#bashInteractive` cannot resolve. `print-dev-env --json` prints the environment as upstream's does, over several lines when stdout is a terminal and on one otherwise, or as `--pretty` and `--no-pretty` choose. Upstream's `develop` leaves an empty temporary directory behind on every run, and an empty rcfile when it refuses its flags; nova-nix leaves neither. On Windows both commands are refused, since no Windows stdenv's builder is bash yet. The garbage collector does not yet keep the environment while a shell runs. (#715)- **The command-line reference, which `--help` prints, says what `eval`, `trust`, `store gc`, `develop` and `profile remove` do, where it said otherwise.** `eval` writes `builtins.toFile` and `builtins.path` to the store only under `--read-write-mode`; without it, it builds an output a path's context names only when its derivation's `allowSubstitutes` is false and `always-allow-substitutes` is off, refusing to substitute any other. `trust` in a store upstream Nix's database also manages refuses a closure only when it has a fixed-output input. `store gc --print-roots` lists the roots in such a store too. `--ignore-env` keeps the variables `--set-env-var` sets as well as those `--keep-env-var` names. `profile remove --regex` matches a package's identifier: for one a flake added, its flake reference and attribute, and for any other the names of the store paths it holds, without their versions. (#738)- **A push that fails on an exception, such as a path whose tree cannot be read, says `push failed:` once, where it said it twice.** `Nix.Push.pushPaths` put the prefix on an exception's message, and `nova-nix push` put it on every failure it was given, so such a failure read `push failed: push failed: ...`. `pushPaths` now reports an exception as it reports its other failures, unprefixed. (#738)- **`Nix.Develop.Capture.captureDerivation` captures a derivation with a fixed output beside others, or under another name than `out`, input-addressed, as upstream's `nix develop` does, and refuses only a floating content-addressed or impure output, the one reason its refusal gives.** Upstream's `getDerivationEnvironment` (develop.cc at 2.36.0) defers every input-addressed and fixed output before anything reads the outputs together, and its reading of a `.drv` (derivation/aterm.cc) checks no output against another, so such a derivation is captured; nova-nix refused it with `the derivation has a floating content-addressed or impure output`, which it has not. nova-nix's evaluator makes no such derivation, so `develop` and `print-dev-env` are unchanged. (#738)- **`nova-nix build` realises only the output it prints, the one the derivation's `outputName` names, as `nix-build` does, so with that output valid it builds and downloads nothing, whatever the state of the derivation's other outputs.** `nix-build` asks for each derivation's `outputName` alone (`main_nix_build` in nix-build.cc, the same at 2.24.9, 2.34.9 and 2.36.0); nova-nix asked for every output, so a missing sibling output, such as a `dev` a collection deleted, was downloaded or built again. A build the requested output needs still builds every output of the derivation, as upstream's does. `--check` still checks every output. (#738)- **`nova-nix profile history`, `profile rollback` and `profile wipe-history` show a profile's generations, switch it back to an earlier one, and delete the ones it no longer needs, so that the next `store gc` takes what only they kept.** They are `nix profile`'s commands of those names at 2.36.0. `history` prints upstream's lines for each generation in order of number: `Version N (DATE) <- M:`, where the date is the day in UTC its link was made and `M` the generation listed before it, then each package added, removed or at other versions than in that generation, with the empty-set sign for none and an epsilon for an empty version, or `No changes.`; it sets the current generation's number in green and the others' in bold where upstream 2.36.0 styles stdout, on a terminal whose `TERM` is not `dumb` or wherever `CLICOLOR_FORCE` or `FORCE_COLOR` is set, and never under `NO_COLOR` or `NOCOLOR`. `rollback` switches to the newest generation below the current one, or with `--to N` to generation `N`, every `--to` read as upstream reads it, a binary unit after it included, the last winning, and says `switching profile from version M to N`; a change after a rollback makes the generation after the newest, as upstream numbers one. `wipe-history` deletes every generation but the current one, or with `--older-than Nd` those made before its cutoff but the newest of them, which the profile held at the cutoff, and warns of one made after the cutoff that a later one predates, as upstream does; it says `removing profile version N` for each. `--dry-run` on either says what it would do and changes nothing. A generation's time is its link's own modification time, and the next collection removes a deleted generation's root record with upstream's `removing stale link` line. The refusals are upstream's, each one `error:` line: `profile version N does not exist`, `no profile version older than the current (N) exists`, the two `invalid number of days specifier` messages, and those for a `--to` that does not read, which upstream follows with a `Try 'nix --help'` line that nova-nix does not print. Where nova-nix differs: both commands keep the profile's lock file once they release the lock, as every nova-nix lock does, where upstream deletes it; both refuse a profile whose current generation is outside the store in use, as every profile command does, so a profile upstream Nix keeps in another store is neither switched nor wiped; `history` refuses a generation only `nix-env`'s `manifest.nix` describes, as `profile list` refuses such a profile, where upstream reads it; `--older-than` multiplies its days into seconds in 64 bits, where upstream's product is an int that more than 24855 days overflow; and of two links for one number, such as `profile-3-link` and `profile-3-link.tmp`, a rollback takes the later in name order, where upstream takes the later in directory order. (#744)- **On Windows a variable set to nothing counts as set, as upstream reads it, so an empty `NO_COLOR` turns colour off there as it does elsewhere.** A Windows variable was read through base's `lookupEnv`, which reads a value of no characters as unset. nova-nix now asks `GetEnvironmentVariableW` for the space the value needs first, as upstream does, which is none only for a variable that is not set, so every variable nova-nix reads, `NO_COLOR` and `NIX_STATE_HOME` among them, is set when it is set to nothing. (#744)- **`nova-nix trust --json` prints the report as one JSON document, and the report names a file of prebuilt code that is a copy of an input the closure runs as a builder as that input.** The lines are for a reader; the JSON is for a check, which can then hold a closure to what it relies on without reading prose. It has a `version`, the fixed-output inputs keyed by output path, each with its `class`, how it comes to be, the inputs pinned to the same hash, the builders inside it, and the prebuilt code and unread files its scan found, then the builders outside the closure, in its input sources and the builtins, each with its count of derivations, and the input sources themselves. Keys are camelCase and store paths full, as upstream's JSON output spells its own, and `--pretty` and `--no-pretty` lay it out as they do `print-dev-env --json`. Every file of prebuilt code now carries its SHA-256, and one whose bytes are those of a fixed-output input a build runs as a builder, hashed flat, is named as that input: `pkgs/windows`' stage0-pe32 source archive holds a copy of the 1,623-byte seed, which the report now gives as the seed rather than as more prebuilt code. (#757)- **`NIX_CONFIG_HOME` holds the user's `nix.conf`, as upstream 2.36.0 reads it.** Upstream's `getConfigDir` returns `NIX_CONFIG_HOME` itself when the variable is set, the directory `nix.conf` sits in rather than one with a `nix` directory beneath it, and otherwise `nix` under the XDG config home (users.cc at 2.36.0); its user config files are that directory's `nix.conf` and then each `XDG_CONFIG_DIRS` entry's, unless `NIX_USER_CONF_FILES` names others. nova-nix read the XDG config home's file whatever `NIX_CONFIG_HOME` said. An empty `NIX_CONFIG_HOME` is set, as upstream reads it, and names `nix.conf` in the working directory. (#775)- **`nova-nix key generate-secret --key-name NAME` prints a new Ed25519 secret key for signing a binary cache, and `nova-nix key convert-secret-to-public` prints the public key of the secret key on stdin, byte for byte as upstream's `nix key` commands do.** A cache `push` writes to a directory is signed with a secret key file, and nova-nix had no way to make one: the reference pointed at upstream's `nix-store --generate-binary-cache-key`. The secret key is `NAME`, a colon and the base64 of 64 bytes, a seed from the system's source of randomness and then that seed's public key, as libsodium makes the key upstream prints, with no line feed after it. The public key is the secret key's last 32 bytes under the same name, read off as upstream reads it rather than derived from the seed again, also with no line feed. Stdin is read whole and as it is, as upstream reads it. The base64 is read up to its first `=`, skipping line feeds, so a key echoed with a line feed after it is read, and what follows a padded key is not read at all. A character outside base64 before the padding is refused with upstream's report: an `error:` line, the trace `while decoding key named ''` after an ellipsis on the next, and `error: invalid character in Base64 string: '...'` below it, each line indented by the width of `error: `. A key with no colon, no name or no bytes is refused the same way, with `error: key is corrupt`, and a key that is not 64 bytes with `error: secret key is not valid` alone. Each refusal exits with status 1. The name is the bytes the command line gives, unchecked, as upstream takes it, and the last `--key-name` given wins. Without one the command is refused with upstream's `required argument '--key-name' is missing`. Both commands take `--store` and leave it unused, as upstream's take that setting as every command does. (#765)- **SIGTERM and SIGHUP interrupt nova-nix on POSIX, as SIGINT does and as upstream takes all three: a command ends saying it was interrupted, and a build running ends its builder's process group.** Each ended the process at once, which, with a builder in a session of its own, left the builder running. (#778)- **`nova-nix daemon` serves the store to clients over a Unix socket, in upstream Nix's worker protocol, on Linux and macOS.** It listens where upstream's daemon does, at `$NIX_DAEMON_SOCKET_PATH`, else `daemon-socket/socket` in `$NIX_STATE_DIR` or `/nix/var/nix`, or where `--socket-path` says, on a socket every user may write, as upstream's is, so the directory it is in decides who reaches it. It admits and trusts each client as upstream's daemon does, by `trusted-users` and `allowed-users`, which name users, groups as `@GROUP` and everyone as `*`, refusing a member of `build-users-group`, which defaults to `nixbld` for a daemon run as root; `--force-trusted` and `--force-untrusted` decide without asking who a client is, as upstream's flags do. A client the daemon does not trust is limited as upstream limits one: it may not repair, its settings are held to those upstream lets it set, its substituters to `trusted-substituters` and those the daemon uses, and it is shown roots without what holds them. Each connection is served on a thread of its own, with temporary roots of its own that go with it, and the daemon holds the store open while it runs, so a collection waits for it to stop. It answers queries of the store (which paths are valid, their info, referrers and derivers, a derivation's outputs, the roots, a path's NAR), keeps temporary and indirect roots, and builds, substitutes and adds paths, as the entries below describe; a client asking it to add signatures or collect garbage is told it does not do so yet, and one asking it to repair, optimise or verify the store is told nova-nix does not do so. A path too long for a socket address is refused, where upstream binds one from its directory, and on macOS a group's members include those the directory counts, as upstream's do. `trusted-users`, `allowed-users` and `trusted-substituters` (and its older name `trusted-binary-caches`) are read from `nix.conf`. (#772)- **`nova-nix daemon` builds and substitutes for its clients, and tells them what realising paths would take.** BuildPaths and BuildPathsWithResults realise each derivation's outputs asked for, building them or substituting them from the caches the connection's settings name, and check them when a check is asked for; EnsurePath substitutes a path, failing as upstream does with "path '...' is required, but there is no substituter that can build it"; QueryValidPaths substitutes what it is asked to first, a failure a warning, as upstream's daemon does; QuerySubstitutablePaths says which paths a cache offers; and QueryMissing works out the derivations to build, the paths to substitute with their download and unpacked sizes, and those unknown, as upstream's `queryMissing` does. Each operation runs under its connection's settings, with no cache when the client says not to substitute, as upstream's worker has none then, and a daemon run as root builds as `build-users-group`'s members. The client is told what the store does as upstream's daemon tells it: each message as a line at its level, and each build, check and substitution as the activity upstream's derivation and substitution goals start, each line a builder writes a result of it. Results with a build report one for each derivation that ended, as upstream 2.36.0 reports them: one realised as another's input is built, a failure is reported under the request whose own derivation failed, one whose input no request asked for failed did so with upstream's "Cannot build '...'. Reason: 1 dependency failed.", and one left unrealised when another failed is left out, as upstream leaves out a goal that never finished. A store path asked for that no cache holds has no substituter, and one whose references no cache holds failed for them, in upstream's words. A derivation asked for that the store does not hold is substituted first, and one no cache gives fails its request with upstream's "failed to obtain derivation of '...'", nothing else being realised, as upstream's worker stops then. A fixed-output derivation whose output has other contents than it fixes is reported as upstream reports a hash mismatch, as an output rejected, where a builder that fails is a permanent failure. A failure upstream's goals throw, such as a cache that cannot be asked or an output a derivation does not have, fails the whole call, as upstream's does. A build's start and stop times are not recorded and read as 0. Repairing is refused before anything is done, as nova-nix does not repair. (#780)- **A daemon client that hangs up has its work stopped.** `nova-nix daemon` watches each connection for its client to hang up, as upstream's daemon does, and stops the work it is doing for that client as an interrupt stops it: its builder is ended with every process it started, and its locks, temporary roots and database connection are released. The sandbox helper closes every descriptor it inherits past the standard ones, as an unsandboxed builder's start closes them, so a sandboxed build holds no other client's connection open. On Windows a build that is stopped waits for its builder's job to end before it unwinds. (#780)- **`nova-nix daemon` adds paths for its clients: the derivations and sources they send as dumps, and NARs with what their paths claim of themselves, one at a time or several together.** AddToStore makes a dump into the path its content address makes, as upstream's daemon does, and answers the path's info: a text, as a `.drv` is sent, by its SHA-256 with the references sent; a NAR by the algorithm it names, with references only for SHA-256; and a file's contents by the algorithm it names. AddToStoreNar and AddMultipleToStore import a NAR as upstream's store imports one: a path already valid is answered without its NAR being written; a path that is not content-addressed is refused a client the daemon does not trust, whatever it asks, unless a key the daemon trusts signed it, one in `trusted-public-keys` or the public key of one in `secret-key-files`, or `require-sigs` is off, with upstream's "cannot add path '...' because it lacks a signature by a trusted key"; and a NAR whose hash is not its info's, or that ends before the size its info states, a tree that does not reproduce the content address it states, an address that does not make its path, a fixed address other than a NAR's SHA-256 stated with references, a derivation whose outputs are not the paths its inputs make, and a reference that is not valid are refused in upstream's words, as is a `trusted-public-keys` entry or a `secret-key-files` file that does not read. Upstream's warning of a path that "claims to be content-addressed but isn't" reaches the client at upstream's error level, where upstream prints it, so a client that hears errors alone hears it. A NAR that goes on past the size its info states is refused as an archive cut short at that size, where upstream refuses it as a size mismatch. Each path added, or found valid, is a temporary root of the connection, as upstream's store roots what it adds. What a client sends is written to a staging directory in the store and moved to its path under the path's lock once it has been checked, as upstream 2.36.0 stages an import, so a refusal leaves nothing at a store path, and an upload a client abandons or hangs up in is removed. A text hashed other than with SHA-256 is refused, where upstream's daemon stops on an assertion, and so is a dump that goes on past its archive's end, which upstream takes. A NAR's path is registered at the time its info states, or at the time of its import where its info states 0, as upstream registers one. The git-hashing method is still refused, as upstream refuses it without its experimental feature, and so is repairing. `trusted-public-keys` is empty unless nix.conf sets it, where upstream's default holds the key of cache.nixos.org. (#799)- **The daemon names every path under `/nix/store` to its clients, wherever the store it serves keeps its files, as upstream's daemon names a store's paths by its store directory and not by the physical directory its files are in.** nova-nix computes a store path under `/nix/store` whatever directory `--store` names, but its daemon named paths on the wire under the directory the files are in: a client computing the same paths under `/nix/store` would refuse them as outside its store, and on Windows, where that directory is `C:\nix\store`, the daemon refused every path a client sent as not absolute. The daemon's messages to a client name paths under `/nix/store` too. (#803)- **`nova-nix daemon` serves the store on Windows, over the named pipe `\\.\pipe\nova-nix-daemon`, and names each client by its Windows account.** Windows has no Unix socket that names its peer, so the daemon listens on a named pipe, or on the `\\.\pipe\NAME` that `$NIX_DAEMON_SOCKET_PATH` or `--socket-path` names. It creates the pipe as its first instance, so it refuses to start where another process already has the pipe rather than join a pipe someone else controls, and the pipe refuses clients on other machines. The pipe's DACL gives SYSTEM and Administrators full control and Users the right to read and write data and nothing more, so while the daemon has the pipe no other user's process can create an instance of it and take a client in its place. A daemon whose token holds Administrators enabled, as an elevated administrator's does, owns the pipe as Administrators and gives its own account no entry: the processes of that account that are not elevated hold Administrators for deny only, so they use the pipe as any user does and can neither create an instance nor rewrite the DACL. A daemon without Administrators owns the pipe as its account and gives the account the access that creating its next instance takes, and no right to delete the pipe or take its owner. A process at Medium integrity or above makes a pipe with no integrity label, which Windows reads as Medium, so clients at Medium integrity write it; a client at Low integrity cannot. (#803)- **The daemon reads who a client is as the client connects, before it has read a byte, and matches the client's account against `trusted-users` and `allowed-users` by SID.** It impersonates the client, reads its token's user and the groups the token grants by, and stops, in one call, so a client the daemon refuses has sent nothing and holds neither its pipe instance nor a thread. An entry names an account as Windows resolves a name, or by its SID, and a group after `@`. A bare name is an account of this machine, so `root` or `alice` cannot name an account of a domain the machine belongs to; another domain's account is `DOMAIN\NAME` or `NAME@DOMAIN`, and a well-known one is `BUILTIN\Administrators` or `NT AUTHORITY\SYSTEM`. An account whose name holds a space is named by its SID, since the settings are lists split at whitespace. Windows has no root, so `trusted-users` defaults there to `@S-1-5-32-544`, the machine's administrators, whose tokens enable the group only while elevated; elsewhere it stays `root`. `build-users-group` refuses a client by the groups Windows holds for its account, not by the groups its token shows, which a token can set aside, and a client whose group membership or whose build-users group Windows cannot tell is refused where a mistaken answer would let a build account in. A client running with a restricted token is refused rather than taken as its user. (#803)- **A client of the daemon's pipe checks who made the pipe before it sends anything, and refuses a pipe a trusted account did not make.** `Nix.Daemon.Pipe.connectPipe` reads the owner and the integrity label of the pipe it opened, with the read access it already holds, so a user can check a daemon that is elevated or a service, which a check of the daemon's process could not do. It trusts a pipe owned by its own account, SYSTEM, Administrators or `NT SERVICE\nova-nix`, the virtual account of the service the daemon is to run as, and refuses a pipe made by a process below Medium integrity, naming the pipe. LOCAL SERVICE, NETWORK SERVICE and the other services' accounts are not trusted, since other services share them. Windows lets a process give a pipe it makes only its token's user or a group its token holds enabled with the right to own objects as it, Administrators in an elevated administrator's token, and any other owner only with the restore privilege, so the owner says who made the pipe, and a user who is not elevated, an administrator among them, owns what it makes as itself. The daemon sets the owner itself, since the owner Windows gives by default is a security policy's to change. The client opens the pipe letting the daemon identify it but not act as it, and while every instance is busy it waits for one to free, at most 15 seconds, before it says the pipe is busy. (#803)- **The daemon's accept loop on Windows waits half a second after a failed accept and stops after ten failures in a row.** A pipe that kept failing would otherwise spin and fill the log. The daemon does not watch a Windows client for its hangup, so the work for a client that has gone ends when the daemon next fails to send to it, and it does not yet run as a Windows service or build as build accounts. (#803)- **A command reaches the store through a daemon, nova-nix's or upstream's, when it cannot write the store and the daemon is there, and `--store`, nix.conf's `store` and `NIX_REMOTE` choose `auto`, `daemon`, `unix://PATH`, `local` or a store directory, as upstream's do.** A user who cannot write a shared store now evaluates, builds and keeps profiles in it through its daemon, as upstream's `auto` store does. The value is `--store`, else the `store` setting (`NIX_CONFIG` included), else `NIX_REMOTE`, else `auto`, so the setting overrides the variable and the flag overrides both. `auto` opens the store directly when this process can read and write its `.nova-nix` directory, and otherwise goes through the daemon when something is at its socket, or on Windows its pipe, without connecting to find out. The connection is made when a command first needs the store, so a command that never asks it does not fail for a daemon that is not there, and one that does fails with upstream's `cannot connect to socket at "PATH": REASON`. On Windows the probe also asks whether the process may keep the store, since a store the service created is the service's and is refused to other processes. A `unix://PATH` is percent-decoded, split at `/` and folded, and must be absolute, as upstream reads it, `unix:/PATH` with one slash reads the same, a literal space in the address is refused, and `unix://` alone is the default socket. A value that is none of those and has no path separator, such as a misspelt `daemon`, is refused as `Cannot parse Nix store 'VALUE'`, as upstream refuses it, so a directory in the working directory is written `./store`. A store directory is still read as the store itself, where upstream reads a path as the root of a store beneath it, and on Windows so is a drive path or one that starts `\\?\`, where upstream reads a drive path with a `/` as a URL whose scheme is the drive's letter. A store URL's settings and other schemes are refused, since nova-nix opens none of them, and where a Linux system has no `/nix` and no daemon, upstream makes a chroot store under the user's data directory for a user who is not root, which nova-nix does not: it opens the platform store directly, where the opening fails as it would have. `--substituter`, `--trusted-key` and the sandbox flags reach a daemon as the settings they set, as upstream's flags do. A daemon that does not trust the user says it ignored `--trusted-key` and the sandbox flags, and a `--substituter` URL that its `substituters` and `trusted-substituters` do not list, and takes one that they list without a word. The `store` setting is sent when a source set it (`NIX_REMOTE` only gives its default), as upstream's setting renders it: `auto` for the empty reference, and `unix://PATH` with the path as written. `--store` replaces the value that is sent, and for `develop`, `print-dev-env`, `profile add` and `profile remove`, which model upstream's `nix` command, whose flag marks the setting as set, it is sent for `--store` alone, where `build` and `eval`, which model `nix-build` and `nix-instantiate`, send nothing for it. A store directory is opened directly and sends nothing. Upstream's daemon resolves its own `store` setting from `--store`, nix.conf and `NIX_REMOTE`, may serve a store that is itself a daemon, and warns when that store names its own socket; `nova-nix daemon` reads `--store` alone and refuses one that names a daemon, since it serves a store it opens itself and does not proxy to another. Through a daemon the refusal of a store upstream Nix's database manages does not apply, an output that `--check` finds different exits 1, as upstream's client reports its daemon's failure, and `store gc`, `store delete` and `--exec-wrapper` are refused with the reason, since they need the store opened directly. (#810)- **`push` and `trust` work through the daemon.** `push` asks the daemon for each path's references, NAR hash and deriver and reads its NAR from the store's directory, as upstream's client of a daemon on the same machine reads it: the daemon is asked what it records of the path, never for its NAR. `trust` has the daemon fetch and substitute its fixed-output inputs: a fetch that fails stops the command, and so does a substitution the daemon fails for a reason other than that no substituter offers the path or something it references. A path the daemon holds asks no substituter anything. The daemon's result does not tell a download that failed from a path no substituter offers, so through a daemon an input whose download failed, or whose references' download failed, is left unread and the report names it as not read, where a store opened directly stops the command; everything else matches. `trust` reads what the daemon holds from the store's directory. Each path whose record or files a push or trust relies on is rooted for the connection before the daemon is asked about it, so a collection cannot remove it between the answer and the read of its files; the list `push --all` starts from is not rooted, so a path collected between the listing and its read fails the push. A daemon older than protocol 1.34 cannot say how a substitution ended, so `trust` through one fails for an input the daemon does not hold. `push --all` words a failure to list the store's paths as `push failed: REASON`, for a store opened directly and through a daemon alike. (#815)### Evaluation- **Evaluation spends a fraction of the time it did collecting garbage: the drvPaths of firefox, git, python3 and gimp from nixpkgs evaluate in 6.7 seconds where they took 24.5, and a minimal NixOS system's in 19 seconds where it took 149.** A thunk not yet forced reached the environment its code runs in through a GHC stable pointer, freed only when the thunk was forced, and nixpkgs leaves most of the thunks it makes unforced: those two evaluations ended holding about 1.9 million and 3.9 million such pointers. GHC marks every stable pointer on every collection, minor ones included, so collecting took 74% and 87% of the time. A pending thunk now holds its environment's C pointer, as upstream's holds its `Env *`, and collecting takes 9% and 12%. A frame whose bindings refer to it, those of a `let`, a `rec` set or a function's formals, is allocated before the thunks that point at it and its slots are filled after, as upstream builds `env2` in `ExprLet::eval`, `ExprAttrs::eval` and `EvalState::callFunction` (eval.cc at 2.24.9). The peak memory footprint falls by 8% on both evaluations, measured back to back on one machine, and the drvPaths are unchanged. (#428)- **`__curPos` evaluates to the position it is written at, `{ column; file; line; }` in a file and `null` in an `--expr` argument, where it failed with `undefined variable '__curPos'` when forced.** Upstream's parser reads the identifier as a position, never as a variable, wherever it is an expression (`expr_simple`, parser.y), and `ExprPos::eval` answers `EvalState::mkPos` of it (eval.cc), the set `builtins.unsafeGetAttrPos` gives for an attribute: the file's path as a string and the line and column of the identifier, or `null` for text with no file behind it. The parser here now does the same, so no binding of the name reaches it: `let __curPos = 1; in __curPos` is the position, as it is upstream, where it was `1`, and so is `__curPos` under a function whose argument is named `__curPos` or a `with` whose set has that attribute. `inherit __curPos;` copies a variable, as upstream's `inherit` builds one without that check, so with nothing binding the name it fails as an undefined variable before anything is evaluated, where it failed only when the attribute was forced. nixpkgs' Firefox wrapper sets `pos = __curPos;`, so `firefox-bin` failed to evaluate. The position differs from upstream's where `unsafeGetAttrPos`'s does: the file of a file outside the store reached through a symlinked directory is its path with every symlink resolved, where upstream's is the path as written. (#468)- **A hash's base64 is read as upstream reads it, up to the first `=`, so an SRI or base64 hash with text after its padding, such as `sha256-HS/n40Ng8S5N14DtEH/upwlxdzwCoOEJA40EMdCcLw4=io`, is the digest spelled before the padding.** The decoder removed every `=`, newline and carriage return and decoded what was left, so a character after the padding became part of the digest, giving a 33rd byte or an encoding it refused, and a last character whose unused bits were not zero was refused. The hashes nixpkgs gives `nmgui` on unstable, and `cosmic-workspaces-epoch`, `guake`, `journalist` and `quintom-cursor-theme` on 24.11, failed this way. Upstream's `base64Decode` (util.cc at 2.24.9, `base64::decode` in base-n.cc at 2.36.0) stops at the first `=` and reads nothing after it, skips a newline, refuses any other character outside the standard alphabet, a carriage return among them, and drops the bits left after the last whole byte whatever their value, and so does the decoder here, for `builtins.convertHash`, a fixed-output derivation's `outputHash`, and the `sha256` of `builtins.fetchurl`, `builtins.fetchTarball` and `builtins.path`. A hash's algorithm tag is split off as upstream's `getParsedTypeAndSRI` splits it (hash.cc at 2.24.9, `parseAnyHelper` at 2.36.0): at the first `:`, else at the first `-`, and a tag that names no known algorithm is an error, so a separator after the padding still decides the tag, and `sha256-...=:x` names the unknown algorithm `sha256-...=`. A hash not in SRI form is read as base16, nix32 or base64 by its length in bytes, as upstream counts it, so a character after the padding that UTF-8 spells in more than one byte makes the length wrong. A base64 digest that is refused or decodes to the wrong length fails with upstream's message for both, `invalid SRI hash '...'` or `invalid base-64 hash '...'`, since upstream catches the decoder's exception without rethrowing it and lets the length check report it (the `Hash` constructor in hash.cc at 2.24.9, `parseLowLevel` at 2.36.0). (#469)- **Every reader of an attribute name a program computes refuses a name with string context, as upstream's does: `listToAttrs`, a dynamic attribute, a select or `?` path, `getAttr`, `hasAttr`, `removeAttrs`, `catAttrs` and `groupBy`.** Each read the name's text and dropped its context, so `builtins.getAttr (builtins.appendContext "a" { ... }) { a = 1; }` was `1`, and a `derivation` whose `outputs` held such a name passed where upstream's fails, since the wrapper makes its output attributes with `listToAttrs`. Upstream reads each name with `forceStringNoCtx` (`getName` and `ExprAttrs::eval` in eval.cc, and `prim_getAttr`, `prim_hasAttr`, `prim_removeAttrs`, `prim_listToAttrs`, `prim_catAttrs` and `prim_groupBy` in primops.cc), which refuses one with context as `the string 'a' is not allowed to refer to a store path (such as '...')`, naming the context's first element, and now so does nova-nix, with `builtins.unsafeGetAttrPos`'s reader. A name that is not a string is refused with that function's `expected a string but found ...` where each reader had a message of its own; a dynamic attribute whose name is null still binds nothing. (#475)- **`derivationStrict` forces a derivation's attributes in name order and only then looks for its builder and system, so the error it reports is the one upstream's reports.** It forced `system`, then `builder`, and refused either missing, then checked `outputs` and read `args`, all before the rest of the attributes, so `(derivation { name = "w"; builder = "b"; all = throw "all"; }).drvPath` failed with `required attribute 'system' missing` where upstream fails with `all`, a repeated output was reported ahead of a throwing attribute sorting before `outputs`, and with both `builder` and `system` throwing the error was `system`'s. Upstream reads `__structuredAttrs` and `__ignoreNulls` first, then makes one pass over the other attributes in name order that reads `args`, `builder`, `system` and `outputs` at their keys, and checks that the builder and system are present after it (`derivationStrictInternal` in primops.cc), and nova-nix now does the same, for a structured derivation too. As upstream's does, a derivation that passes its attributes through the environment takes its outputs from the words of the `outputs` entry, so `derivationStrict` given `outputs = "out dev"` has the outputs `out` and `dev`. An output name that is not a valid store path name is refused after that pass. (#486)- **`builtins.readDir` lists a directory holding an entry it cannot stat, and only forcing that entry's value fails, as `builtins.readFileType` on it fails.** readDir stats every entry, so one entry whose stat the system refused failed the whole call, as it did for a directory that can be read but not searched, where every entry's stat is refused, and on Windows for a directory holding a file with a deny ACE, and for `C:/`. Upstream's `readDirectory` gives an entry whose `lstat` is refused with `EACCES` or `EPERM` no type (posix-source-accessor.cc at 2.24.9), and `prim_readDir` binds such an entry to a deferred application of `builtins.readFileType` to its path under the directory with its symlinks resolved (primops.cc), so the listing names every entry and forcing one fails with readFileType's `getting status of '...': Permission denied`. readDir now does the same; any other failure to stat an entry still fails the listing, as upstream's does. `builtins.path` with a filter and `builtins.filterSource` read such an entry's type with an `lstat` of its own, as upstream's path filter does (`EvalState::callPathFilter` in primops.cc), so they fail on it as `readFileType` does, where they failed as the listing. (#491)- **Hash strings are parsed as upstream's `Hash::parseAny` and `Hash::parseSRI` parse them, so `builtins.convertHash` refuses a tag that disagrees with `hashAlgo`, a fixed-output derivation whose `outputHashAlgo` names no algorithm upstream knows takes its algorithm from `outputHash`'s tag, and `builtins.fetchGit` accepts a `narHash` that spells the fetched hash with text after its padding.** Five cases differed from upstream 2.24.9. A base16 or nix32 digest that did not decode failed with `hash '...' is not a valid base16 sha256 hash`, where upstream's `Hash` constructor reports `invalid base-16 hash '...'` and `invalid base-32 hash '...'` (hash.cc at 2.24.9). An unknown algorithm, in `builtins.hashString`, `builtins.hashFile`, `builtins.convertHash` or a hash's tag, failed with `unknown hash algorithm '...'`, the first two after the builtin's name, and without the `, expect 'md5', 'sha1', 'sha256', or 'sha512'` upstream's `parseHashAlgo` adds (hash.cc at 2.24.9). `builtins.convertHash` ignored `hashAlgo` when the hash carried a tag; upstream parses `hashAlgo` first and hands it to `Hash::parseAny` (`prim_convertHash` in primops.cc), so an unknown `hashAlgo` is refused whatever the hash, and a tag that names another algorithm fails with `hash '...' should have type '...'` (`Hash::parseAny` in hash.cc). A fixed-output derivation refused an `outputHashAlgo` it did not know; upstream reads it with `parseHashAlgoOpt` (`derivationStrictInternal` in primops.cc), which gives no algorithm for a name it does not know, so `outputHash`'s own tag decides, and an untagged hash fails with `hash '...' does not include a type, nor is the type otherwise known from context` (`Hash::parseAny` in hash.cc), as an untagged hash given to `builtins.convertHash` without `hashAlgo` now does too. A known `outputHashAlgo` that disagrees with the tag is still refused, as upstream refuses it. `builtins.fetchGit` compared a declared `narHash` with the fetched one as text; upstream reads it with `Input::getNarHash` (fetchers.cc) before fetching anything, as an SRI hash that must be SHA-256 or as the empty string for a digest whose every byte is zero, and compares the hashes (`InputScheme::checkLocks` in fetchers.cc at 2.24.9, `Input::checkLocks` at 2.36.0), so a spelling with text after its `=` matches, a prefixed one fails with `hash '...' is not SRI`, a SHA-512 one fails with `narHash must use SHA-256`, and a mismatch names the pin in SRI. The refusal of a tag that disagrees with the algorithm the context expects is upstream's `hash '...' should have type '...'` for `outputHash` and for the `sha256` of `builtins.fetchurl`, `builtins.fetchTarball` and `builtins.path` too, where it added the tag's own algorithm and a `derivation:` or builtin's name. (#490)- **`builtins.listToAttrs` reads an element's `value` only for the first element of its name, so `builtins.listToAttrs [ { name = "a"; value = 1; } { name = "a"; } ]` is `{ a = 1; }`, where it failed with `builtins.listToAttrs: element missing 'value'`.** Upstream's `prim_listToAttrs` (primops.cc at 2.24.9) forces each element to a set and reads its `name`, first to last, and looks `value` up only for a name it has not seen, since the first element of a name gives its attribute; nova-nix looked `value` up on every element before keeping the first of each name. Its failures are now upstream's, each with the line of context upstream gives it: an element without `name`, or the first element of a name without `value`, is `getAttr`'s `attribute 'name' missing` or `attribute 'value' missing` with the line `in a {name=...; value=...;} pair` (primops.cc at 2.24.9, `EvalState::getAttr` in eval.cc at 2.36.0), an element that is not a set is `expected a set but found ...`, and an argument that is not a list `expected a list but found ...`, where each had a message of its own. (#493)- **A position's column counts bytes, as upstream's does, so `builtins.unsafeGetAttrPos`, `__curPos` and a syntax error give upstream's column on a line with non-ASCII text before the position, where a character UTF-8 spells in several bytes took one column.** Upstream's lexer advances its location by the length in bytes of everything it reads (`adjustLoc`, lexer-helpers.cc, run for every match by `YY_USER_ACTION`, lexer.l), a position is the byte offset where its token begins (`ParserState::at`, parser-state.hh), and the position table makes its column one past that offset's distance from the start of its line (`PosTable::operator[]`, nixexpr.cc at 2.24.9, pos-table.cc at 2.36.0). The lexer here now counts the same way, so each position after a U+00E9 on its line is a column further than it was, for the character's second byte. A UTF-16 source's syntax error counts the bytes of its UTF-8, which is what the lexer reads. (#494)- **`==`, `!=` and list `<` force a value both sides share before taking it as equal to itself, so `let x = throw "x"; in [ x ] == [ x ]` fails with `x`, as it does under upstream.** Two references to one thunk were taken as equal without forcing it, so an error inside a shared value never surfaced: a list or set compared with another holding the same values was `true` however those values failed, and so was `d == d.out` for a derivation whose arguments throw, since the two sets hold one `outPath`. Upstream's `eqValues` forces both values first and only then takes a value as equal to itself (eval.cc); it compares two derivations by their `outPath` through the same function (eval.cc), which forces the derivation, and list `<` calls it on each pair of elements (`CompareValues` in primops.cc). A list literal holds a variable's own value under both, so `[ x ]` and `[ x ]` share `x`. A function or NaN that both sides share is still equal to itself, as upstream's is. (#495)- **`nova-nix eval` prints a derivation and exits, with and without `--strict`, and `builtins.deepSeq` on one returns, where each ran without end: a set or list reached a second time prints as upstream's repeated marker, in the eval result and in error and trace messages.** A derivation's `all` and output attributes hold the derivation itself, and the deep force behind `--strict` and `builtins.deepSeq`, and both printers, followed them each time they were reached. Upstream's `forceValueDeep` enters each value once (eval.cc), `printAmbiguous`, which `nix-instantiate --eval` prints through, prints a set or list it has printed before as the marker (print-ambiguous.cc), and so does the printer behind error and trace messages, whose `trackRepeated` is on by default (`PrintOptions::trackRepeated` in print-options.hh, `Printer::printAttrs` and `Printer::printList` in print.cc); the ones here now do the same. Each goes by identity, never by contents, so two equal sets made apart both print in full; here the identity is the C set, list or thunk cell the value lives in, which nothing frees before evaluation ends. The two printers differ where upstream's do. The result printer never marks an empty set or list, and takes a list of one or two elements as one per cell that holds it and a longer list as one however many cells hold it, since upstream keeps a short list's elements inside the value that holds the list and a longer one's in an array its copies share (`Value::listElems` in value.hh). The message printer takes a list with elements as one per cell that holds it, whatever its length, and marks the one shared empty set when it reaches it again, since upstream allocates a set built with room for no attributes as its one empty set (`EvalState::allocBindings` in attr-set.cc). A traced list that holds itself prints one level deeper than upstream's before the marker: upstream's trace hands its printer the argument's own value (`prim_trace` in primops.cc), and the printer here starts from a value with no cell. `--strict` forces the result in place and prints the result itself, where it printed a copy rebuilt while forcing, which held no set or list twice. (#488)- **Evaluating bytecode that holds a tag the compiler never writes, an unknown opcode or an unknown operator, formals, capture or binding tag, fails the evaluation with an error that names the tag, such as `corrupt bytecode: unknown binary operator tag 200`, where five of those cases stopped the program with a Haskell `error`.** Such a tag reaches the evaluator only from a corrupt bytecode store or from code built with `Nix.Eval.CBytecode.cbcEmit` rather than by the compiler. The store hands each tag back as a whole byte or word, so no type on the decoding side can rule one out, and each decoder answers a tag outside the set the compiler writes as a failure instead. The error is an evaluation error, which `builtins.tryEval` does not catch, and the one for an unknown opcode, which read `evalBytecode: unknown opcode`, names the opcode too. (#502)- **A derivation is fixed-output whenever its `outputHash` is set, an empty one or one that is not a string included, a fixed output's outputs must be `out` alone, and an empty hash, in `outputHash` or in the `sha256` of `builtins.fetchurl`, `builtins.fetchTarball` and `builtins.path`, is the all-zero hash upstream warns of.** `derivationStrict` took an empty `outputHash`, and one that was not a string, as absent, so `outputHash = ""` and `outputHash = 5` made an input-addressed derivation, and it wrote a fixed-output `.drv` with the one output `out` whatever `outputs` listed, so `.dev` of one with `outputs = [ "out" "dev" ]` was a missing attribute. Upstream reads `outputHash` in its pass over the attributes, coerced as every environment entry is, or as a string under `__structuredAttrs` (`derivationStrictInternal` in primops.cc), takes the derivation as fixed-output once it is set, refuses any outputs but `out` with `multiple outputs are not supported in fixed-output derivations`, and reads the hash with `newHashAllowEmpty` (`derivationStrictInternal`): an empty hash is the hash of `outputHashAlgo`'s algorithm whose every byte is zero, with `warning: found empty hash, assuming 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='` on stderr, and is refused with `empty hash requires explicit hash algorithm` when `outputHashAlgo` names no algorithm upstream knows (hash.cc). nova-nix now does the same, so `outputHash = 5` fails with `hash '5' has wrong length for hash algorithm 'sha256'` given that algorithm and with `hash '5' does not include a type, nor is the type otherwise known from context` given none, and `outputHash = null` is the empty hash unless `__ignoreNulls` leaves it out. The fetchers read their pins with the same function (`fetch` in fetchTree.cc, `prim_path` in primops.cc), where an empty one failed on its length: it is now the all-zero hash with the same warning, read with the other arguments before anything is fetched, as a pin that does not parse now is too. A fetch whose content does not match its pin fails with upstream's message: `hash mismatch in file downloaded from '...'` with both hashes in nix32 for `fetchurl` (`fetch` in fetchTree.cc at 2.24.9), and `store path mismatch in (possibly filtered) path added from '...'` for `builtins.path` (`addPath` in primops.cc); `fetchTarball` refuses a tree that does not match in 2.36.0's words, as the entry on its in-process unpacking says. The exit status is still 1, where upstream's `fetchurl` and `fetchTarball` exit with 102 (`fetch` in fetchTree.cc). (#500)- **The builtins that read a plain string refuse one with string context, as upstream's do: the regex of `match` and `split`, `getEnv`, the name of `toFile`, the algorithm of `hashString` and `hashFile`, `fromJSON`, `placeholder`, `parseDrvName`, `splitVersion`, both arguments of `compareVersions`, and the name `findFile` looks up.** Each read the string's text and dropped its context, so `builtins.toFile (builtins.appendContext "a" { ... }) "x"` wrote a file and `builtins.match` of such a regex matched. Upstream reads each with `forceStringNoCtx` (`prim_getEnv`, `prim_placeholder`, `prim_findFile`, `prim_hashFile`, `prim_fromJSON`, `prim_toFile`, `prim_hashString`, `prim_match`, `prim_split`, `prim_parseDrvName`, `prim_compareVersions` and `prim_splitVersion` in primops.cc), which refuses one with context as `the string 'a' is not allowed to refer to a store path (such as '...')`, naming the context's first element (eval.cc), and now so does nova-nix, with the reader that computed attribute names already use. A value that is not a string is refused in those positions with that function's `expected a string but found ...`, where each builtin had a message of its own. `findFile` reads the name after its search path entries, as upstream's does, so a failing entry is reported ahead of the name, and `match` and `split` compile the regex before they look at the subject, as upstream's do, so an invalid regex is reported ahead of a subject that is not a string. (#505)- **`builtins.split` of a string its regex does not match gives back the string with its context, as upstream's does.** It rebuilt the string without context, so `builtins.hasContext (builtins.head (builtins.split "x" s))` was false for a string `s` with context; upstream returns the argument value itself there (`prim_split` in primops.cc). The pieces of a string the regex matches carry no context under either. (#505)- **`builtins.addErrorContext` adds its message to the trace of a failure inside it, which `nova-nix eval` prints above the error, and forces the message only when its value fails.** It returned its second argument and added nothing, and it forced both arguments as it was applied, so `builtins.addErrorContext "ctx-marker" (throw "x")` reported `error: x` alone where nix-instantiate prints a line of context, `ctx-marker`, above it, and `builtins.addErrorContext (throw "a") 1` failed with `a` where upstream gives `1`. Upstream's `prim_addErrorContext` forces the value inside a `catch`, and only there coerces the message, as a string, a path or a set with `__toString` or `outPath`, without copying a path into the store, then adds it to the failure's trace and rethrows the failure (primops.cc at 2.24.9), and nova-nix now does the same. The failure keeps its kind, so a throw inside stays catchable by `builtins.tryEval`, and nested contexts are listed outermost first. A message that fails itself, by throwing or by not coercing, leaves the value's failure in place, with a line naming the message's failure, as the entry for upstream 2.36.0's `addErrorContext` below describes, so `builtins.tryEval (builtins.addErrorContext 1 (throw "x"))` catches the throw. An empty message adds no line of its own, as upstream's `showErrorInfo` passes over a trace whose text is empty (error.cc). The parity job compares the line of context `ctx-marker` adds with nix-instantiate's. (#517)- **Evaluation runs 1.7 to 2.4 times as fast and allocates 40 to 50% less: the evaluator is compiled for the monad `nova-nix` runs it in.** The evaluator in `Nix.Eval` is written over any `MonadEval`, and nothing compiled it for `EvalIO`, the monad the executable and `Nix.Eval.IO` run it in, so every bind and every class method in it was a call through the instance dictionary, which GHC can neither inline nor fuse. The library now builds with `-fspecialise-aggressively -fexpose-all-unfoldings`, and `Nix.Eval.IO` specialises `eval`, `deepForce` and `selectAttrPath` to `EvalIO`, exporting rules that send a call at `EvalIO` in any module to that code. The flags alone would leave the executable's own call of `eval` on the dictionary-passing evaluator, since `eval` is small enough to be inlined into `Nix.Eval.IO` rather than given a rule there. `EvalIO`'s actions are also built one-shot, the trick GHC's own `IOEnv` uses, so an action takes the evaluator state and the IO world as arguments instead of returning a closure that waits for them. On `profiling/stress.nix`, `fib 30`, two million three-level selects and two million `elemAt`s, best of five on an Apple M2, time falls from 0.81, 2.22, 2.34 and 5.21 s to 0.46, 0.93, 1.32 and 2.47 s, with the one-shot actions worth 8 to 12% of it, and the results are unchanged. A clean build of the library takes about 13% longer, 94 s where it took 83 s on the same machine, the executable and test suite about 7% longer, and the stripped executable is 2% larger. The evaluator's source stays polymorphic, and the test suite still runs it in its pure monad. (#521)- **`outputHashMode = "nar"` hashes a fixed output as a NAR, as `recursive` does, and a mode upstream does not take is refused for every derivation, with or without an `outputHash`.** `derivationStrict` read `recursive` as a NAR hash and every other value as a flat one, so `outputHashMode = "nar"` gave the flat output's path and `outputHashMode = "foo"` was accepted. Upstream's `handleHashMode` reads the mode in its pass over the attributes, whatever else the derivation holds (`derivationStrictInternal` in primops.cc): `recursive`, kept as the older name of `nar`, and `nar` hash a NAR and `flat` the output's bytes (`ContentAddressMethod::parse`, content-address.cc; `parseFileIngestionMethod`, file-content-address.cc), `text` and `git` need the `dynamic-derivations` and `git-hashing` experimental features, and any other value fails with `invalid value '<mode>' for 'outputHashMode' attribute`. nova-nix now does the same. It implements neither feature, so `text` and `git` fail as upstream fails with them off, whatever `experimental-features` says, with `experimental Nix feature 'dynamic-derivations' is disabled; add '--extra-experimental-features dynamic-derivations' to enable it` and its `git-hashing` twin. A refused mode fails at its attribute in name order, under the line `while evaluating attribute 'outputHashMode' of derivation '<name>'`, so before a missing builder or system is reported, and `builtins.tryEval` does not catch it. An empty mode, which `outputHashMode = null` coerces to unless `__ignoreNulls` leaves it out, is refused too. From 2.33.0 upstream's `text` refusal also names the derivation and its mode; nova-nix keeps 2.24.9's words. The parity job compares the paths of `nar`, `recursive` and `flat` and these refusals with nix-instantiate's. (#528)- **`nova-nix eval` writes a census of its C data layer to the file `NOVA_NIX_C_STATS` names: the objects and bytes of each kind it allocated, those the result, the root environment, the import cache and the search path still reach once evaluation returns, and what finding them cost.** The C data layer holds most of an evaluation's memory, and nothing said where that memory went: a heap profile sees GHC's heap alone. Upstream reports its own figures under `NIX_SHOW_STATS` (`EvalState::maybePrintStats` and `EvalState::printStatistics` in eval.cc), counts of what it allocated; the census gives those counts for the C side and also what is still reached. It reads only what the allocators already keep, and its mark frees and writes nothing. An evaluation that writes it runs without the region collector, so it counts everything the evaluation allocated. What it reaches is exact for those roots. A C object that only a Haskell value outside them holds is counted as unreached. Symbols are reached through the values that hold them and not through the compiled code that names them, and code is counted but never marked, since nothing frees it before the session ends. (#531)- **A program's names are interned in the order upstream's parser interns them, so a set holds its attributes in upstream's order and `let za = 1; in ({ }: za) { zb = 1; za = 2; }` names `za` as the unexpected argument, as upstream does, where it named `zb`.** Both evaluators hold a set's attributes sorted by symbol (`Bindings`, attr-set.hh at 2.24.9), and a symbol's place is the order its name was interned in, so that order decides which of two failures wins wherever a walk over a set stops at the first: the unexpected argument a call names is the first in symbol order (`EvalState::callFunction` in eval.cc). Upstream's parser interns each name in the action of the rule that reads it (the grammar rules of parser.y), and bison runs a rule's action once the rule's right-hand side is parsed, the deferred actions of its GLR stacks included: a variable where it is read, an attribute path's names before the value bound to it, a `let`'s bindings before its body, a set of formals before the function's body and each formal after its default, an attribute path before its `or` default, and a plain `x:` argument and an `@` name after the function's body. nova-nix interned names as its compiler met them: a `let`'s body before its bindings, a function's body before its formals, an `or` default before its path, a variable bound in scope only where it is bound, and an attribute path written in several places as one set. The parser now notes each name where upstream's interns one, and the evaluator interns them in that order before it compiles. A key whose expression is an indented string of a single literal piece, which upstream's parser makes static, stays dynamic here and is interned only when it evaluates. (#525)- **`builtins.path { recursive = false; }` copies the one file at the path by its bytes, to the flat fixed-output path upstream gives it, and an argument `builtins.path` does not take is refused.** `builtins.path` never read `recursive`, so `recursive = false` still copied the file as a NAR and gave the NAR's path, and it passed over any argument it did not know, so a misspelt `sha256` left the copy unpinned. Upstream's `prim_path` reads its arguments one at a time in the set's own order (primops.cc at 2.24.9): `recursive` is a Boolean choosing a NAR or a flat copy, and any argument but `path`, `name`, `filter`, `recursive` and `sha256` fails at its turn with `unsupported argument '<name>' to 'addPath'`, before the path is looked for or anything is copied. For a flat copy `addPath` hands `fetchToStore` the path with its symlinks resolved, whose flat dump reads the file's bytes and calls no filter (`addPath` in primops.cc; the flat case of `dumpPath` in file-content-address.cc), so the pin is the SHA-256 of those bytes, a pin that differs fails with `store path mismatch in (possibly filtered) path added from '<path>'` as it does for a NAR copy, and a directory fails that read with `reading from file '<path>': Is a directory` (`PosixSourceAccessor::readFile` in posix-source-accessor.cc). nova-nix now does the same. From 2.26.0 upstream names `builtins.path` in the refusal of an argument where 2.24.9 names `addPath`, and from 2.34.0 it refuses a directory through another read, in other words; nova-nix keeps 2.24.9's. The parity job compares the flat copy's path, pinned and not, and both refusals with nix-instantiate's. (#537)- **The census `NOVA_NIX_C_STATS` writes counts the environments and attribute sets by the construct or builtin that allocated them, and the environments by number and by size.** Over a nixpkgs slice environments took nearly five times upstream's bytes and attribute sets numbered 1.6 times upstream's (#529, #530), and the census gave each kind's bytes without saying which constructs allocated them, so nothing showed which to make smaller or stop allocating. Every environment and attribute set allocation now names its site: a call, a call with formals, a closure, a `let`, a `rec` set and what each captures, `inherit (from)`, `with`, a set literal, `//`, and each builtin that makes a set. With the variable set the allocators count each allocation under its site from the arena's start: environments with their slots and bytes and by slot count, which also gives the number of environments, and sets with their bytes and how many equal a set that already existed, an empty set or a `//` result with an empty operand, neither of which upstream allocates (`EvalState::allocBindings` in attr-set.cc and `ExprOpUpdate::eval` in eval.cc). Without the variable an allocation tests one flag and counts nothing. `profiling/bench.sh --memory` reports the figures, the environments' slots beside upstream's `envs.elements`. (#539)- **A key written `${"a"}`, a double-quoted string with no interpolation between `${` and `}`, or a URI there, is the name it spells, as upstream's parser makes it, so `let ${"a"} = 1; in a` is `1` and `let a = 1; in { inherit ${"a"}; }` inherits `a`, where both were syntax errors.** Upstream's `attrpath` and `attrs` rules make a key a name when its expression is a plain string, an `ExprString`, and dynamic only otherwise (parser.y); a double-quoted string with no interpolation is one, and so is a URI (the `URI` case of `expr_simple` and the `string_parts` rule, parser.y), parenthesized or not. nova-nix made a key a name only when it was written as a double-quoted string, so a `${"a"}` key stayed dynamic: refused in a `let` and in an `inherit`, outside a `rec` set's scope, so `rec { ${"a"} = 1; b = a; }` failed as an undefined variable, and apart from the same name written bare, so `{ ${"a"}.b = 1; a.c = 2; }` failed when evaluated where upstream merges the two paths, and `{ b = 1; ${"b"} = 2; }` failed when evaluated where upstream refuses it as it parses. A dynamic key in an `inherit`, `inherit ${x};` or `inherit "${x}";`, fails with upstream's `dynamic attributes not allowed in inherit` at the key's start. A `${ }` key whose string is not UTF-8 is a syntax error at the key, as a double-quoted one already was, where it failed only when its set was evaluated; upstream makes a name of any bytes. A key whose expression is an indented string stays dynamic: upstream makes it a name when `stripIndentation` (parser-state.hh) leaves it a single piece, and this parser holds an indented string as its unstripped pieces until it is evaluated. (#542)- **A keyword other than `or` is no attribute name, as upstream refuses it, so `{ if = 1; }`, `x.then` and `inherit rec;` are syntax errors at the keyword, where they named an attribute `if`, `then` or `rec`.** Upstream's grammar takes an attribute name, in a binding, a selection, a has-attribute test or an `inherit`, as an identifier or `or` (the `attr` rule, parser.y), and its lexer makes `if`, `then`, `else`, `assert`, `with`, `let`, `in`, `rec` and `inherit` tokens of their own (the keyword rules of lexer.l), so an attribute named like one is written as a string there, `{ "if" = 1; }` and `x."then"`, as it now must be here. `true`, `false` and `null`, which upstream's lexer reads as identifiers, stay attribute names. (#543)- **The names upstream's evaluator interns as it starts are interned first, in its order, so `({ }: null) { zzz = 1; x = 2; }` names `x` as the unexpected argument, as upstream does, where it named `zzz`.** A set holds its attributes in symbol order, and a symbol's place is the order its name was interned in, so that order decides which failure wins wherever a walk over a set stops at the first. Upstream's `EvalState` interns its static symbols as it is constructed (the `EvalState` constructor in eval.cc at 2.24.9), then every name `createBaseEnv` installs, each followed by that name less a `__` prefix (`EvalState::createBaseEnv` in primops.cc, `EvalState::addConstant` and `EvalState::addPrimOp` in eval.cc), then the names of its `derivation` wrapper, which it parses last (the end of `EvalState::createBaseEnv` in primops.cc, primops/derivation.nix), before it parses a program; `x` is one of the wrapper's. nova-nix interned its builtins' names in name order when a program first used them, after the program's own. The order of the primops is the order their files' static initializers run in: link order at 2.24.9, and the same order at 2.35.0, which compiles the files as one unity build. The release builds of 2.27.0 through 2.34 link under GCC's link-time optimization, which runs the initializers in reverse, so there `getContext` comes before `toString`; nova-nix follows the order 2.24.9 and 2.35.0 share. The order still differs under `pure-eval`, where upstream leaves out `currentTime` and `currentSystem` and their `__` spellings, and with an experimental feature on, whose primops upstream then installs. (#540)- **A call to a set pattern checks for a missing argument before an unexpected one and words both as upstream does, naming the function, and a select of a missing attribute and `abort` word their failures as upstream does: `({ a }: a) { b = 1; }` fails with `function 'anonymous lambda' called without required argument 'a'`, `let f = { }: 1; in f { a = 1; }` with `function 'f' called with unexpected argument 'a'`, `{ a = 1; }.b` with `attribute 'b' missing` and `abort "boom"` with `evaluation aborted with the following error message: 'boom'`.** An argument's or attribute's name prints as upstream prints a symbol, bare when the lexer reads it as an identifier and otherwise as a string literal (`({ }: null) { "a b" = 1; }` names `'"a b"'`, the empty name `'""'`), as upstream writes a symbol through `printIdentifier` (the `operator<<` for `SymbolStr` in nixexpr.cc); the function's name prints as its binding spells it, as upstream passes it as a plain string. nova-nix named the unexpected argument first, as `unexpected attribute 'b' in function argument`, listed every missing argument and the keys given, named a missing attribute by its whole path with the set's keys, and printed `abort`'s message alone. Upstream's `callFunction` checks each formal in symbol order, which its parser sorts formals into, and stops at the first that has neither an argument nor a default, then names the first attribute in symbol order that no formal names (eval.cc, and `ParserState::validateFormals` in parser-state.hh); both carry the line `from call site`, and an argument that is not a set fails as `expected a set but found ...` with that line and `while evaluating the value passed for the lambda argument` (`EvalState::callFunction` in eval.cc). A function takes the name of the attribute a set or `let` binds it to, as does a function that is its body (`ParserState::addAttr` in parser-state.hh, `ExprLambda::setName` in nixexpr.cc), and is otherwise `anonymous lambda`. A select reads each name before it forces the value it selects from, fails at a value that is not a set as `expected a set but found ...` with `while selecting an attribute`, and names the one name a set lacks (`ExprSelect::eval` in eval.cc); `abort` words its message (`primop_abort` in primops.cc). The wording and the printing of names are the same at 2.34.9 and 2.35.4. Neither the position each of these errors carries upstream nor the `Did you mean` suggestions it prints with an unexpected argument or a missing attribute are printed, and the `from call site` line is not added where forcing the argument itself fails, nor `while evaluating the attribute` to a failure under a select. The traces are upstream's with `show-trace` off, its default, which adds no lines for the calls a failure in a function's body passes through (`EvalState::callFunction` in eval.cc). Upstream also names a function under a dynamic key, with the name the key evaluates to, each time it evaluates the set (`ExprAttrs::eval` in eval.cc); such a function is `anonymous lambda` here. (#540)- **Evaluation is faster and allocates less, and every read of and allocation in the C data layer runs where the evaluation reaches it: the evaluator reaches C through actions of its own monad.** Thunks, environments, attribute sets, lists, lambdas and the bytecode live in C, and the evaluator reached them through functions that looked pure and made their C call under `unsafePerformIO` whenever GHC demanded the result. Each read of an instruction's field built a lazy thunk and paid `unsafePerformIO`'s duplication check, and an allocation ran whenever its result was first needed rather than where the evaluation made it, which no collector of C memory can work with: a cell made at an unknown moment cannot be assigned to the force or call that made it. Every read, write and allocation is now an action of `MonadCData`, which every `MonadEval` has, so in the executable each one is a direct FFI call at its point in the evaluation. Two reads stay outside a monad, each in `Nix.Eval.CData` with the invariant that makes it sound: an interned symbol's bytes, which do not change once interned and are copied while no intern runs, and a whole computation run as a value, which is how the pure test evaluator runs. The `Show` and `Eq` instances of the C handles read no C memory: two thunks, sets, lists or environments are equal when they are one C object, and each shows as its address. On `profiling/stress.nix`, `fib 30`, two million three-level selects and two million `elemAt`s, best of five on an Apple M2, time falls from 0.54, 1.03, 1.59 and 3.07 s to 0.44, 0.58, 1.13 and 2.25 s and allocation from 2.43, 6.68, 8.08 and 13.07 GB to 1.86, 3.49, 5.48 and 8.15 GB, and two results change, each to upstream's, because the calls behind them now run where the evaluation reaches them; each has an entry of its own. A variable lookup that would read a slot its frame has not filled yet, which only a defect in the resolver or the frame builder makes, raises `CInvariantViolated` naming `nn_env_lookup_resolved` where it handed on a NULL cell that faulted at its first force. (#552)- **A failed `builtins.tryEval` returns a set of its own, so `nova-nix eval --strict` prints two failed results in full, where it printed the second as upstream's repeated marker.** Upstream's `prim_tryEval` builds the result's bindings on each call, a failed one included (primops.cc), and the printer marks a set as repeated only by identity, so `[ (builtins.tryEval (throw "a")) (builtins.tryEval (throw "b")) ]` prints `{ success = false; value = false; }` twice under both. Every failed `tryEval` here returned the same set. (#552)- **A type error shows an attribute that is still being forced as the potential infinite recursion marker, as upstream's does, where it showed the thunk marker.** Upstream renders the value a type error names as it builds the error: `forceList` hands the value to the message (eval-inline.hh), and `HintFmt` formats each argument as it is given (fmt.hh), while the attribute is still being forced, and the printer shows such an attribute as that marker (`Printer::printThunk` in print.cc). So `let x = { a = builtins.length x; }; in x.a` fails with `expected a list but found a set`, its `a` printed as the marker, under both. nova-nix rendered the message when it was shown, by which time the failed force had put the attribute back to unevaluated. (#552)- **Environments take less than half the memory they did: a call's environment of one value takes 16 bytes where it took 56, and one with no parent and no scopes takes 8 bytes and 8 per value, as upstream's does.** An environment was a 48-byte struct in front of a separate array of its values, with room in every one for a name table and with-scopes that only a `with`, a root environment and a frame whose names are not all static use, and over a nixpkgs slice environments took nearly five times upstream's bytes (#529). Upstream's `Env` is a parent pointer and its values (eval.hh). An environment of one to seven values and no scopes is now one word, its parent's address with its value count in the three low bits every environment's 8-byte alignment leaves clear, followed by its values; any other is a header word holding its value count and which fields follow, its values inline, then its parent when it has one and its name table and with-scopes when it has them. Everything an environment points to is found from the environment alone. An environment sees the with-scopes of the nearest environment on its parent chain that has its own, a `with`'s or a trimmed closure's, where each environment carried a copy of its parent's; a `with`'s environment copies the values of the one it is made in, and the census's counts by site and by size count them with it. On `profiling/stress.nix` the environments' bytes fall from 40.6 MB to 15.2 MB, and wall time is unchanged within run-to-run noise. What any program evaluates to is unchanged. (#559)- **A string value no longer takes a symbol, so the names an evaluation interns keep upstream's order however many strings it makes, and `builtins.seq "zb" (({ }: null) (builtins.listToAttrs [ { name = "za"; value = 1; } { name = "zb"; value = 2; } ]))` names `za` as the unexpected argument, as upstream does, where it named `zb`.** Upstream's symbol table holds names alone (`SymbolTable`, symbol-table.hh at 2.24.9): a string value points at bytes of its own (`Value::mkString`, eval.cc), and a set's attributes are sorted by the order their names were interned in, so that order decides which of two failures a walk over a set stops at first. nova-nix interned every string value in the same table, and so every string, URI, path and search-path literal, every source file's path and every store path and output name in a string's context, each moving the place of every name interned after it. A string's or a path's bytes now live in an arena of their own, made once where the string is made and shared by every cell that comes to hold it, as upstream copies a `Value` with the pointer to its bytes (value.hh at 2.24.9); the value of a string or URI literal, and of a path literal written in canonical form, is the literal's bytes in the compiled code, as upstream's `ExprString` hands out the value it holds (`ExprString::maybeThunk` in eval.cc). Equal strings made apart are two copies, where the symbol table kept one, as upstream's `makeImmutableString` copies the bytes of each string it makes (eval.cc); every empty string is one static, as upstream's is. A string holds at most 4 GiB of bytes, where upstream's has no bound of its own: its length is a `uint32_t`, the per-allocation limit across the C data layer, and a longer one fails evaluation with `CAllocationFailed` naming `nn_str_new`. The order in which a builtin makes the strings it returns no longer shows. The census `nova-nix eval` writes under `NOVA_NIX_C_STATS` counts strings as a kind of their own (`strings.*`), and its `symbols.*` lines count names alone: on `profiling/stress.nix` it counts 10,290 symbols where it counted 350,301, and 530,004 strings of 10.6 MB, and the bytes the allocators hold beyond their objects fall from 17.0 MB to 4.4 MB. (#559)- **`==` on two sets compares them pair by pair in the order their names were interned, each pair's names and then its values, so `{ zb = 1; za = throw "a"; } == { zb = 2; za = 1; }` is `false` and `{ zq1 = throw "x"; zq2 = 1; } == { zq1 = 1; zq3 = 1; }` fails with `x`, as under upstream.** The two sets' name lists were compared whole before any value, then the values in name order, so the first failed with `a` and the second was `false`. Upstream's `eqValues` compares two derivations by their `outPath`, takes sets of different sizes as unequal without forcing a value, and then walks both sets' `Bindings` together, comparing each pair's names and then its values and stopping at the first difference (the `nAttrs` case of `EvalState::eqValues` in eval.cc). `Bindings` are sorted by `Symbol`, whose order is the order the symbol table interned the name in (attr-set.hh, symbol-table.hh); a set here is sorted by its own symbol table the same way, and nova-nix interns names in upstream's order: its startup names first, then each name where upstream's parser interns it, and no string value at all, so two sets compare in upstream's order. The order decides only which failure wins, never whether two sets are equal. Comparing two sets reads one entry of each at a time, where it copied both sets' names and values first. (#559)- **`builtins.listToAttrs`, `builtins.groupBy` and `builtins.fromJSON` intern each name of the set they build as they meet it, as upstream's do, so `({ }: null) (builtins.listToAttrs [ { name = "zb"; value = 1; } { name = "za"; value = 2; } ])` names `zb` as the unexpected argument, as upstream does, where it named `za`.** A set holds its attributes in the order their names were interned (`Bindings`, attr-set.hh at 2.24.9), and that order decides which of two failures a walk over a set stops at first: the unexpected argument a call names and the pair `==` forces first. Upstream's `prim_listToAttrs` interns an element's name as it reads it, before the next element (primops.cc), `prim_groupBy` interns the name its function returns before it calls the function on the next element (primops.cc), and `builtins.fromJSON` interns a member's name as the parser reaches it, before the member's value (`JSONObjectState::key` in json-to-value.cc), so a name the document repeats keeps the place its first occurrence gave it and takes its last value. nova-nix collected each builtin's names by name and interned the ones new to its table in name order as it built the set. Each now interns a name where upstream's does, and `builtins.fromJSON` reads an object's members in document order, so `({ }: null) (builtins.fromJSON "{\"zb\": 1, \"za\": 2}")` names `zb`, and `builtins.listToAttrs [ { name = "zb"; value = throw "b"; } { name = "za"; value = 1; } ] == builtins.listToAttrs [ { name = "zb"; value = 1; } { name = "za"; value = throw "a"; } ]` fails with `b`, as under upstream. (#564)- **Every value lives in the C data layer: a builtin and a builtin applied to some of its arguments are C values, so no value sits in GHC's heap behind a StablePtr, and the census follows the whole value graph in C.** A builtin value and a partial application were the last values a thunk held as a StablePtr to a Haskell value, so a collector in C could not reach the cells a partial application held. A builtin is now its index, inline in its cell, and a partial application is a C object holding the builtin's index and the cells of the arguments it has taken, as upstream's `tPrimOp` and `tPrimOpApp` hold a primop and the values applied to it (value.hh at 2.24.9). The builtin bound under its own name is one static cell per builtin, as upstream binds one value per primop (`EvalState::addPrimOp`, eval.cc), so it is the same value in every file and survives the arena's teardown. `match` and `split` hold their pattern as a string and compile it through the cache keyed by the pattern on each call, as upstream's `RegexCache` does (primops.cc), where a partial application held the compiled regex; the regex engine is unchanged. Applying a builtin now selects its implementation by its constructor rather than by comparing its name with each builtin's: on an Apple M2, best of three, two million saturated builtin calls take 1.40 s where they took 1.74 s, and 200,000 calls through a stored `builtins.elem` and a stored `builtins.match` take 0.47 s where they took 0.53 s. The census `nova-nix eval` writes under `NOVA_NIX_C_STATS` counts partial applications as a kind of their own (`primopapps.*`). What any program evaluates to is unchanged. (#565)- **The `derivation` wrapper names its values as upstream's does, so `({ }: null) (import ./f.nix)`, where `f.nix` is `{ zz = 1; shared = 2; }`, names `zz` as the unexpected argument, as upstream does, where it named `shared`.** A set holds its attributes in the order their names were interned, and upstream interns its wrapper's names as it starts, before any program's (primops/derivation.nix at 2.24.9). nova-nix's wrapper named four of its values `paths`, `entries`, `shared` and `entry`, which upstream's names `strict`, `outputsList`, `commonAttrs` and `x`, so compiling it interned those four after the first program's names and before every name a file imported later brings. It now uses upstream's names, which nova-nix interns as it starts too, so compiling it interns nothing. Its structure, and every position a program can read from it, is unchanged. (#567)- **`builtins` no longer holds `fetchTree`, `fetchClosure` or `outputOf`, so `builtins ? fetchTree` is `false` and `builtins.fetchTree` fails as a missing attribute, as under upstream's default settings, where it was a function that failed when called.** Upstream registers the three only with an experimental feature on (`fetch-tree`, `fetch-closure` and `dynamic-derivations`; `primop_fetchTree` in fetchTree.cc, `primop_fetchClosure` in fetchClosure.cc and `primop_outputOf` in primops.cc), and nova-nix implements none of those features, so `builtins` leaves the three out whatever `experimental-features` says, and a program testing for one with `?` takes the branch it takes under upstream's default settings. Their names are no longer interned with the base environment either, where they took their place ahead of a program's own names. (#567)- **An evaluation builds its base environment once, and evaluates every file it imports in it, as upstream's does, where each imported file built the root environment and the `builtins` set again; and every C value the evaluation keeps from one step to the next is registered as a root.** Upstream's `EvalState` builds one base environment as it is constructed (`createBaseEnv`, primops.cc at 2.24.9), with the `derivation` wrapper in it, and keeps its import cache where its collector scans it (`fileEvalCache`, eval.hh). An evaluation session now builds its base environment as it starts, over the policy and the search path it is given, with the session's own `derivation` wrapper, where the wrapper was one value for the process. The empty list's cell is a C static, like `null`'s. So no constant of the program points into the C data layer's arena, and tearing the arena down and setting it up again starts evaluation afresh. The base environment, with the search path in `builtins.nixPath`, and each value the import cache keeps are registered as roots (`Nix.Eval.CRoots`), which the census `nova-nix eval` writes under `NOVA_NIX_C_STATS` marks from. What any program evaluates to is unchanged. (#567)- **An empty attribute set is one shared set wherever upstream shares one, and `//` with an empty operand gives the other operand's set, so neither allocates a set.** Upstream's `allocBindings` answers a size of 0 with its one `emptyBindings` (attr-set.cc), which `{ }` and every builtin that sizes its result by what it holds then hold, and `ExprOpUpdate::eval` copies the other operand's value when one is empty (eval.cc). nova-nix allocated a new set for each, and over the first 2,000 attributes of nixpkgs 24.11 the census counted 2,167,080 of its 5,815,653 sets as built empty or as an update with an empty operand (#530). Of the sets nova-nix makes, upstream sizes three before it knows they hold nothing, and gives each bindings of its own: `removeAttrs` of every attribute of a set (`prim_removeAttrs` in primops.cc), `intersectAttrs` of two sets with attributes and no name in common (`prim_intersectAttrs`), and a literal whose every name is a null `${...}` (`ExprAttrs::eval` in eval.cc); each is a set of its own here too. Both printers enter a set by its bindings (`Printer::printAttrs` in print.cc, `printAmbiguous` in print-ambiguous.cc), so these identities show where a value is printed: `let a = { x = 1; }; in [ a (a // { }) ]` prints the update as upstream's repeated marker under `nova-nix eval --strict`, where it printed the set twice, and an error or trace message prints each of the three empty sets of their own in full after the shared one, where it printed it as the marker. The census counts no shared set, and counts as shareable only a set made equal to one that already exists where upstream makes none, so the three are not. (#568)- **Evaluation runs in a session that owns the C data layer, so no caller sets the data layer up or tears it down: `Nix.Eval.IO.withEvalSession` sets it up when no session holds it, makes the session's state, and tears it down as the outermost session ends, on an exception too.** A library caller had to wrap evaluation in `bracket_ arenaInit arenaDestroy`, and leaving that out raised `ArenaNotInitialized` at the first C call. A session now owns the window: a nested session shares the arena of the one around it and forgets the roots it registered as it ends, so the roots a mark over the C data layer starts from, as the census's does, are what the open sessions hold. `nova-nix build` ends its evaluation's session before it builds, so the evaluation's memory is freed before the build starts. (#574)- **A builtin's deferred application of a function, one per element of `map`, `genList`, `mapAttrs` and `zipAttrsWith`, holds the function's and the arguments' cells and no environment, as upstream's is an app value: 16 bytes where it took 24, and 24 for a name and a value where it took 32; `concatMap` calls its function on each element and defers nothing.** Over the first 2,000 attributes of nixpkgs 24.11 those builtins allocated 3.87 million environments of 109.3 MiB, a sixth of the environments' bytes, and upstream 2.24.9 allocates none of them: its `prim_map`, `prim_genList`, `prim_mapAttrs` and `prim_zipAttrsWith` make app values holding the function and its argument, and `prim_concatMap` calls `callFunction` on each element (primops.cc at 2.24.9). A pending thunk now holds either code and the environment it runs in, or such an application: the cells of its function and arguments in an array of the environment pages, which forcing it applies in a call frame of its own with the function forced inside it, as upstream's `forceValue` on an app value does, and with a second frame for the first of two arguments, as upstream's two nested app values have. So the call depth at which a callback is refused, the error it raises and what `tryEval` catches are unchanged. The census `NOVA_NIX_C_STATS` writes counts the arrays as a kind of their own (`apps.*`), which the memory report of `profiling/bench.sh` gives a row. On `profiling/stress.nix` environments take 9.8 MB where they took 15.2 MB, beside 3.6 MB of applications' cells; it runs 3% faster, and a sum over a `map` of a `genList` of 100,000 elements 13% faster, while `fib 30`, which makes no such application, runs about 2% slower. What any program evaluates to is unchanged. (#575)- **The names an `inherit (from)` clause binds select from one environment holding the from-value, where each name had an environment of its own.** Upstream 2.24.9 makes one environment for the from-values of a binding set, in which each inherited name's select runs (`ExprAttrs::buildInheritFromEnv`, eval.cc); over the first 2,000 attributes of nixpkgs 24.11 nova-nix made 505,134 environments for `inherit (from)`, one per name (#529). The clause's from-value was already one thunk for all its names, so each name reads the same value it did. On a program evaluating `let inherit (s) p q r;` 100,000 times, `inherit (from)` makes 100,000 environments where it made 300,000. What any program evaluates to is unchanged. (#575)- **Reading a symbol id the symbol table does not hold raises `CInvariantViolated` naming `nn_symbol_text` or `nn_symbol_len`, and outside an evaluation session `ArenaNotInitialized`, where it read as an empty name.** Within a session only a defect makes such an id, and an empty name surfaced it as a wrong name far from its cause. The invalid id (`Nix.Eval.Symbol.invalidSymbolId`), an anonymous lambda's name, still reads as no name. (#576)- **An imported file is evaluated once per evaluation whatever its value, as upstream caches every file: `import ./f.nix == import ./f.nix` is `true` for a file whose set holds a function, and a trace in it prints once, where a file whose value is a set of 1,000 or more attributes was evaluated again by every import.** Upstream's `evalFile` answers a later import of a file from `fileEvalCache`, which keeps every file's value (eval.cc). Leaving a large set out of the cache freed nothing, since a session's values are freed when the session ends. (#582)- **A resolved variable lookup whose level or index holds nothing, and a code string index no emit returned, raise `CInvariantViolated` naming `nn_env_lookup_resolved` or `nn_bc_string`, where the process aborted; every other C bound aborts in every build, `NDEBUG` or not.** Each of those checks was an assert followed by a fallback for the same condition, commented as what a build under `NDEBUG` does, and no build defines `NDEBUG`, so the assert aborted first; under `NDEBUG` several fallbacks would have answered a plausible wrong value. The two the Haskell boundary already reports now return NULL for it to raise, so the defect is reported with its site, a level read from a corrupt bytecode word past `INT_MAX` among them, and the rest guard indices the library produced itself and keep only their assert. (#587)- **The library exports what its callers use, and an evaluation session alone sets up and tears down the C data layer.** The binding modules exported the layer's lifecycle, so a library caller could destroy the memory an open session was using, and exported names nothing outside their module used, which a caller could come to depend on. The lifecycle's foreign imports are in the internal `Nix.Eval.Arena`, where an evaluation session (`Nix.Eval.IO.withEvalSession`) calls them. (#589)- **A closure or string context element holding a tag the C side does not name raises `CInvariantViolated`, where it was read as a set pattern with a name or as a whole derivation's outputs.** A lambda's formals type and a context element's tag are read against the constants the C side names (`NN_FORMALS_*`, `NN_SCE_*`), so memory written past the library is reported with the site that read it rather than evaluated as another value. A with-scope count at its limit, which only corrupt state reaches, aborts at the check that names it, where it was reported as an allocation failure, so a C allocator's NULL means only that it could not allocate. (#595)- **A variable is looked up only as its kind requires, as upstream's `EvalState::lookupVar` does, and a closure trimmed under a `with` shares the scopes it sees.** A variable a `let`, a recursive set or a global binds was also searched for in the `with` scopes when no name table held it, and a `with` variable no scope held was searched for again in every name table. Neither second search could find anything, since the parser decides each variable's kind before evaluation, and a closure trimmed to its captures under a `with` held a copy of its scopes with the builtins appended for one of them. It now shares the scopes of the environment it is made in, and one made outside every `with` holds none. (#595)- **The parser makes `<name>` the call `__findFile __nixPath "name"`, as upstream's parser does, so neither the expression tree nor the bytecode has a node of its own for a search path.** The resolver turned that node into the same call before anything evaluated it, so the bytecode's search-path operation ran for no parsed source, and a node a library caller compiled by hand looked `builtins.findFile` up where the parser's call uses the `__findFile` in scope. (#597)- **A select, a has-attribute test and a variable look their name up by the symbol the compiled code holds for it, so evaluation allocates less, and a select interns a name it computes before it forces the value it selects from, as upstream's does: `builtins.seq ({ s = builtins.listToAttrs [ { name = "z" + "b"; value = 1; } ]; }.s.${"z" + "a"} or null) (({ }: null) (builtins.listToAttrs [ { name = "z" + "b"; value = 1; } { name = "z" + "a"; value = 2; } ]))` names `za` as the unexpected argument, as upstream does, where it named `zb`.** Upstream holds a variable's name and each static name of an attribute path as a symbol from parse to lookup (`ExprVar` and `AttrName`, nixexpr.hh) and finds it in a set by that symbol (`Bindings::get`, attr-set.hh). nova-nix's compiled code holds the same symbols, but each lookup turned its symbol back into text and interned the text again to get the symbol it started from: a variable once for every name table it walked and every `with` scope it tried, and a select or has-attribute test once for every name in its path. Each lookup now passes the symbol on, and a name a select or has-attribute test computes is interned once, where upstream's `getName` interns it (eval.cc): before a select forces the value it selects from (`ExprSelect::eval`), and after a has-attribute test forces the value it tests (`ExprOpHasAttr::eval`). nova-nix interned a select's computed name after that force, so a name the force interned, as `listToAttrs` interns the names of the set it builds, took the earlier symbol, and with it the earlier place in every set holding both. On `profiling/stress.nix` evaluation allocates 1.65 GB where it allocated 1.90 GB. (#599)- **A set binds its static names before its dynamic ones and checks each dynamic name, in source order, before it evaluates the next, and a name bound twice says where it was first defined, as upstream's does: `{ ${"a" + ""} = 1; ${throw "y"} = 2; a = 3; }` fails on `a` at the line and column of `a = 3`, where it failed with `y`, and `rec { ${"b" + ""} = 1; ${"a" + ""} = 2; a = 3; b = 4; }` names `b`, where it named `a`. Sets are also built with less allocation.** Upstream's `ExprAttrs::eval` binds a set's static attributes, then takes its dynamic ones one at a time in source order: it evaluates the name, in the set's own environment for a recursive set and in the enclosing one otherwise, skips a null, interns the name, and raises `dynamic attribute '%1%' already defined at %2%` for a name already bound, the name written as `printIdentifier` writes an attribute name, before it evaluates the next (`ExprAttrs::eval` in eval.cc). The position is the earlier definition's, as `Pos::print` writes it (position.cc): the file's path, or upstream's string marker for an `--expr` string, then the line and the column. nova-nix bound a non-recursive set's static and dynamic names together in source order, so an error in a later dynamic name could win over an earlier collision, and a recursive set checked each dynamic name against the earlier dynamic ones as it evaluated it, but against its static names only once it had evaluated them all, then named the first such collision in name order; neither message said where the name was defined. It also interned a set's dynamic names only as it built the set, in name order, so they took their places in symbol order, which decides the order of a set's attributes, by name rather than in source order, as upstream's take theirs. In an expression built through `Nix.Expr`, which can hold what the parser refuses, a static name repeated in a set now keeps its last definition, as it did in a recursive set with no dynamic name, where a non-recursive set, a recursive set with a dynamic name and a `let` with one refused it as a dynamic attribute already defined; and a `let` with a dynamic name binds its static names before it evaluates that name, where upstream's `ExprLet::eval` never evaluates one (#602). Each set is now built from the symbols its compiled code holds, where every static name was turned into text and interned again, so on `profiling/stress.nix` evaluation allocates 1.35 GB where it allocated 1.65 GB. (#604)- **`builtins.deepSeq` and `nova-nix eval --strict` force a set's values in the order the set holds them, by the symbols of their names, as upstream's do: `builtins.deepSeq { zb = throw "b"; za = throw "a"; } null` fails with `b`, where it failed with `a`. `mapAttrs`, `zipAttrsWith`, `intersectAttrs`, `builtins.path` and `scopedImport` read a set by those symbols too, and allocate less.** Upstream's `forceValueDeep` forces a set's values as it walks the set's `Bindings` (eval.cc), which are sorted by `Symbol`, the order the symbol table interned each name in (`Attr::operator<=>` in attr-set.hh, `Symbol::operator<=>` in symbol-table.hh). nova-nix forced them in the order of the names' text, so of two values that fail, the one whose name sorts first failed, where under upstream the one whose name was interned first does; the order decides only which failure wins. The builtins copied a whole set into a map keyed by each name's text and interned every name back into the symbol the set already held it under. Each now walks the set's own array, sorted by symbol, one entry at a time, and turns a name into text only where it is read as text. `intersectAttrs` walks the smaller of its sets and finds each name in the other, as upstream's does (`prim_intersectAttrs` in primops.cc), and `scopedImport` binds its scope's names by the scope set itself, as upstream binds the set's own values in the environment it evaluates the file in (`import` in primops.cc), where nova-nix copied them into a new set. On `profiling/stress.nix`, whose one `mapAttrs` maps 10,000 names, evaluation allocates 1.337 GB where it allocated 1.350 GB. (#605)- **A set, a `let` and a function allocate less and evaluate faster: their bindings and captured variables are read where the compiled code holds them, and the compiler counts a binding list's names.** Each time a set or a `let` was evaluated, its bindings were decoded into a fresh Haskell list, which was then walked up to five times, once for each thing the evaluator needed from it, such as whether its frame holds its names in slots, how many slots it has and how large the set is. Each time a closure or a frame was made, its captured variables were decoded into a list of pairs. The compiler now writes at the head of each binding list how many names it binds statically and how many of its bindings have a dynamic name, which give a frame's layout, its slot count and a set's size in two reads. The bindings are folded over where the compiled code holds them, a set with no dynamic name skips the pass that binds dynamic names, and a closure's captured slots are written into its env as they are read. Results are unchanged. On `profiling/stress.nix` evaluation allocates 1.18 GB where it allocated 1.34 GB, and its mutator time falls by about 9%. (#608)- **A function holds the names of its formals, its argument and itself as the symbols the compiled code holds for them, and a call to a set pattern finds each formal in its argument by its symbol and looks for an unexpected argument only when the argument holds attributes no formal takes, as upstream's does, so making, storing, reading and calling a function allocates less.** Upstream holds a formal's name, a function's argument name and the name its binding gives it as symbols from parse to call (`Formal` and `ExprLambda`, nixexpr.hh). Its `callFunction` looks each formal up in the argument by that symbol and counts the formals the argument fills, and only when, with no ellipsis, that count differs from the argument's size does it walk the argument for the first attribute no formal names (eval.cc). nova-nix's compiled code and closures held the same symbols, but each function made from the compiled code and each one read from a cell turned every name into text, each one stored in a cell interned every name again, and each call to a set pattern interned each formal's name to look it up, then, with no ellipsis, turned every attribute of its argument into text and compared it with every formal's name. Results and errors are unchanged. A fold making 600,000 calls to set patterns, with and without defaults, an ellipsis and an `@` name, allocates 3.16 GB where it allocated 4.35 GB, in about 25% less mutator time, and on `profiling/stress.nix` evaluation allocates 1.14 GB where it allocated 1.18 GB. (#611)- **`builtins.zipAttrsWith` refuses a first argument that is not a function before it forces the list, as upstream's does, so `builtins.zipAttrsWith 1 [ ]` fails with `expected a function but found an integer: 1` where it gave `{ }`.** It never checked its function: given sets, it built a set of applications of the `1` that failed only when one was forced, so `builtins.attrNames (builtins.zipAttrsWith 1 [ { a = 1; } ])` was `[ "a" ]`, and it forced the list as it was applied, so `builtins.zipAttrsWith 1 (throw "b")` failed with `b`. Upstream's `prim_zipAttrsWith` forces its first argument with `forceFunction`, which takes a lambda, a builtin or a set with `__functor`, and only then forces the list (primops.cc and eval.cc), so the function fails first whatever the list holds, and nova-nix now does the same. (#613)- **A binding, list element, call argument or default whose value is a variable holds that variable's own value wherever upstream's does, so `builtins.catAttrs "g" [ { g = map; } ] == [ map ]` is `true`, where it was `false`.** Upstream's `ExprVar::maybeThunk` binds a variable's own value when the slot it reads is filled and a thunk of its own when it is not, and makes a thunk for a variable only a `with` supplies (`EvalState::lookupVar` and `ExprVar::maybeThunk` in eval.cc), and `==` takes a value as equal to itself before it compares (`EvalState::eqValues` in eval.cc), which a function, never equal to another, shows. nova-nix shared a variable only when it read it by slot, and made each value a recursive set, a `let` or a default gives a name, but an inherited one, a thunk of its own, its frame not being built yet; it now shares a global, a variable of an enclosing scope and a name of a recursive set with a dynamic name as upstream does. A recursive set, a `let` and a set pattern fill their slots in symbol order, from an env whose slots start empty (`ExprAttrs::eval`, `ExprLet::eval` and `EvalState::callFunction` in eval.cc; `allocEnv` in eval-inline.hh), so a variable naming a sibling shares its value only when the sibling's name was interned first: `let s = rec { f = x: x; g = f; }; in builtins.catAttrs "f" [ s ] == builtins.catAttrs "g" [ s ]` is now `true`, as it is with `${"g" + ""} = f`, and with `rec { g = f; f = x: x; }` it stays `false`. A recursive set's dynamic names are bound once its static ones are (`ExprAttrs::eval`). A default naming a formal shares whatever that formal's slot holds, the argument's attribute when the call gives one, and a default naming the @-pattern shares the argument. A recursive set that binds `__overrides` makes every value but an inherited one a thunk of its own (`ExprAttrs::eval`), and does so here too, though nova-nix does not yet apply `__overrides` (#601). A constant in a recursive set, a `let` or a default is now a value rather than a thunk, as upstream's is. The compiler decides which bindings share as it compiles a frame, so a frame that has none pays one read of their count; on `profiling/stress.nix` evaluation allocates 1,134,852,296 bytes where it allocated 1,135,482,952, and a `let` binding a variable of an enclosing scope allocates 6% less over 200,000 evaluations. (#616)- **`nova-nix eval` writes a census of regions to the file `NOVA_NIX_REGION_STATS` names: at the end of each force of a thunk, the bytes the force allocated and the bytes of them still reachable, and the most bytes collectors freeing at those points would have held.** The census `NOVA_NIX_C_STATS` writes says what is unreachable once evaluation returns, not when it became so. A collector freeing at the end of a force can free only what the force allocated and nothing reaches through the older cells and with-scopes it wrote into or the roots it registered. The census records every such write, marks from them at each force's end, stopping at older objects, and frees nothing. It reports the closes by the bytes their regions allocated, the bytes allocated outside every force, which no such collector frees, and, for collectors that mark only at the regions past a threshold of bytes, the closes that mark, their work and the most bytes held at once, freeing single objects, only whole blocks at the allocators' block sizes and at four smaller ones, or only the lines of 256 or 128 bytes in a block that hold nothing reachable, as a collector reusing a block's free lines in place would. It also counts what a close reached after an earlier close found it unreachable, the pointer a collector would have freed under. And it simulates collectors that tenure what their closes mark: past their threshold each close marks only what no such close of theirs inside it tenured, and a close marks its region whole when it is outermost or, for a collector with a budget of 1, 16 or 256 MiB, when the closes inside have tenured at least that since; their roots are the stores into tenured or older cells, which a mark of the whole reads again for each region they are older than, and the pointers their marks find into untenured objects of regions around. It reports each one's work, the bytes its marks of the whole free and the most bytes it holds beside the collector that marks again at every close, and checks that none frees anything a mark reaches. `profiling/bench.sh --memory` runs it over its slice and reports it. Without the variable an allocation tests one more flag. (#617)- **The C data layer frees what a force of a thunk allocated once the force returns and nothing reaches it: attribute sets, list headers, lambdas, builtins' partial applications and strings with context one by one, and thunk cells, environments and strings a line of 128 bytes at a time, which later allocations reuse.** The layer freed nothing before its session ended, so one evaluation over nixpkgs held every set it had ever made, and sets are more than half of what it allocates. At the end of each force that allocated at least 16 KiB, a collector marks from the stores the force made into older cells and with-scopes and the roots it registered, entering only what no such close inside it already settled, and marks the force's whole region again once the closes inside have tenured 1 MiB since its last such mark; what the mark leaves unreached is freed. A line of a block of cells, environments or strings is freed once every object in it is, and an allocator that has filled its room next takes a run of free lines, numbered as a room of its own so that its objects are younger than every force under way. An evaluation under `NOVA_NIX_C_STATS` or `NOVA_NIX_REGION_STATS` frees nothing, since those censuses count what the evaluation allocated. A force at the top of an evaluation that allocates less than 16 KiB marks nothing, so what it leaves stays until the session ends. (#622)- **The census `NOVA_NIX_C_STATS` writes counts the entries `//` copies into the sets it makes, as upstream counts them in `nrOpUpdateValuesCopied`.** Over the first 5,000 attributes of nixpkgs 26.05, sets made at `//` hold 1,786.5 of the 2,378.3 MiB of sets nova-nix allocates, and upstream 2.34 copies fewer entries there than 2.24 does, by layering a small right operand on the left (`ExprOpUpdate::eval` in eval.cc), so the count shows how far nova-nix's `//` is from it. A `//` of two sets that hold entries counts the entries of the set it makes, as upstream adds the merged set's size (`ExprOpUpdate::eval` in eval.cc), and one with an empty operand, which gives the other operand and makes no set, counts none, as upstream's does. `profiling/bench.sh --memory` reports the count beside upstream's. (#637)- **`//` with a right operand of at most 16 attributes makes a layer on the left operand holding the right operand's attributes alone, as upstream 2.34 does, where it copied both operands into a new set.** Sets made at `//` held most of the bytes of sets nova-nix allocates over a nixpkgs walk (#628), and upstream 2.34 layers such a right operand on the left while the left's chain of layers holds fewer than eight sets, copying the right operand alone (`Bindings::maxLayers`, `eval-attrset-update-layer-rhs-threshold` and `ExprOpUpdate::eval`, in attr-set.hh, eval-settings.hh and eval.cc). A lookup searches the layers top first, and a walk over the set reads each name once, in symbol order, from its topmost layer, so every read answers as the merged set did. A larger right operand, or a left whose chain holds eight sets already, is merged into a new set as before. The census counts the entries a layer copies, the right operand's, as upstream adds them to `nrOpUpdateValuesCopied`, and counts a layer's own bytes, and its own entries among the sizes of the sets it reaches; the census, the object graph and the region collector follow a layer to the set under it. Over the first 2,000 attributes of the memory suite's walk of nixpkgs 26.05, `//` copies 24.5 million entries where it copied 50.1 million, the sets it makes take 433.9 MiB where they took 829.9 MiB, and in runs on macOS peak RSS falls by 287 to 336 MiB. (#652)- **A chain of `//` merges its operands from the first, as upstream 2.34's update queue does: `a // b // c` layers `b` on `a` and then `c` on that, where it made `b // c` first and merged `a` with it.** `//` groups to the right, so a chain parses as `a // (b // c)`. Upstream 2.34 gathers a chain's operands, descending only into an operand that is itself an update, and once it has evaluated them all folds them into one set from the leftmost (`ExprOpUpdate::eval` and `ExprOpUpdate::evalForUpdate` in eval.cc), so a chain of small sets on a large one copies the small ones alone, once each. A chain one of whose operands fails merges none. (#656)- **`nova-nix build` builds or substitutes what a path's context names before `import`, `builtins.readFile` and the other builtins that read a path read it, as upstream's import from derivation does, and `nova-nix eval` realises it as upstream's read-only evaluation does.** A path reader read the path as it was on disk with its string context dropped, so importing a derivation's output failed with `path '/nix/store/<hash>-<name>' does not exist` until something else had built it. Each reader now realises its argument's context first, as upstream's `realisePath` does (primops.cc): `import`, `builtins.scopedImport`, `readFile`, `pathExists`, `readDir`, `readFileType` and `hashFile`, `builtins.findFile` for each search path entry, and `builtins.path` and `builtins.filterSource` for a path in the store. Every path the context names must be valid, checked in upstream's order, and then each output it names is realised; when outputs several derivations lack are named, the derivation reported is the first by name, as upstream's worker takes its goals. `nova-nix build` and `nova-nix eval --aterm` add what evaluation has fetched, written or named before that (the sources it coerced, the trees it wrote, the derivations it recorded), so the store holds what upstream's would, and `build` realises through the same store handle its own build uses. `nova-nix eval` and `nova-nix trust` add nothing, as `nix-instantiate --eval` runs read-only (`main_nix_instantiate` in nix-instantiate.cc), and plain `nix-instantiate` does not. A path evaluation computed, a coerced source or a `builtins.toFile`, `builtins.path` or `builtins.filterSource` result or a derivation, is not valid there unless the store already holds it, so `import (derivation { ... })`, and equally `builtins.readFile (builtins.toFile "x" "y")`, fail with upstream's `path '<path>' is not valid`. What a fetcher fetched is readable there, since upstream's fetchers add their results in any mode (`fetch` in fetchTree.cc at 2.24.9). An output of a derivation the store holds is built when it may not be substituted (`allowSubstitutes = false`), and otherwise refused with upstream's `cannot substitute path '<path>' - no write access to the Nix store`, also for whatever that build would substitute; the output refused is the one upstream's worker tries first, by path name and then path, so a derivation's `out` comes before its `dev`. In a store upstream Nix's database manages that realisation opens nothing, so a substitution is refused in upstream's words and only an output that has to be built meets nova-nix's refusal of the store. The read-only queries make no store, metadata, database or lock, and open a store's database read-only, which writes nothing to it; SQLite still makes the `-wal` and `-shm` files a database in WAL mode needs beside one that lacks them. A database without the store's tables, as a first open cut short leaves, reads as holding nothing, as a store upstream's read-only evaluation has just made the tables of does (the new-store case of the `LocalStore` constructor in local-store.cc), and a fetched path is never asked about. What evaluation writes itself, a fetch or a `builtins.toFile` result, still makes the store directory. In a store upstream Nix's database manages, where nova-nix holds no rows, a path counts as valid when its tree exists. A failure carries upstream's line of context, `while realising the context of path '<path>'`, or `while adding path '<path>'` from `builtins.path` and `builtins.filterSource`, which also give it to a failure of the filter or the copy; `builtins.tryEval` does not catch it, and `builtins.pathExists` answers it with the failure rather than `false`. `builtins.hashFile` refuses an unknown algorithm, `builtins.filterSource` a filter that is not a function, and `builtins.path` an argument it does not take, a `filter` that is not a function or a `name` that is not a string without context, before the path's context is realised, as upstream's do; `builtins.path` gives the last two upstream's line of context, and names a copy whose `name` is empty by the path's base name. `builtins.findFile` names the entry and the path's base name, as 2.35.4 does, and where the releases word the refusal differently the newest's words are used. Under `--restrict-eval` and `--pure-eval` the closure of each output realised becomes readable, as 2.34.9 allows it (`EvalState::allowClosure` in eval.cc). (#657)- **`allow-import-from-derivation` and `trace-import-from-derivation` are read from `nix.conf` and `NIX_CONFIG`, and `--no-allow-import-from-derivation` turns the first off for one run of `eval`, `build` or `trust`.** With it off, a builtin that reads a path whose context names a derivation's output fails with upstream's `cannot build '<drv>^<output>' during evaluation because the option 'allow-import-from-derivation' is disabled`, naming the first output in upstream's order, once every path the context names is valid and before anything is added or built, so an output already valid is refused too (`EvalState::realiseContext` in primops.cc); `builtins.tryEval` does not catch it, as upstream's catches only an assertion, and a read-only `eval` refuses as a `build` does. With `trace-import-from-derivation` on, each such read warns `built '<drv>^<output>' during evaluation due to an import from derivation` before it builds anything, as 2.34.9 does (`EvalState::realiseContext` in primops.cc); the warning has no effect with the first setting off, as upstream's has none. There is no `--allow-import-from-derivation`: as for every setting, a flag only moves the setting from its default, so a machine configured to refuse an import from derivation keeps refusing it whatever the command line says. (#665)- **`builtins.fetchurl` and `builtins.fetchTarball` return the fetched store path as a string carrying itself as context, and so does the `outPath` of what `builtins.fetchGit` returns, as upstream's do.** Each returned a path value, so `builtins.typeOf` gave `"path"` where upstream gives `"string"`, the result printed unquoted, and `+`, `toString` and `builtins.isPath` treated it as a path. Upstream sets a fetcher's result with `allowAndSetStorePathString` (`fetch` in fetchTree.cc at 2.24.9 and 2.34.9) and fetchGit's `outPath` with `mkStorePathString` (`emitTreeAttrs`), a string whose context is the store path itself, so naming it in a derivation depends on that path rather than copying it to the store again as a path value would be. (#674)- **A path value inside a store path is copied to the store under its base name when it is coerced, as every other path is, so a derivation in a nixpkgs imported from a store path gets upstream's drvPath and output path.** The path coerced to itself, with the enclosing store path as context, wherever it was interpolated, named in a derivation's `args` or environment, joined by `concatStringsSep` or written by `toJSON`. Upstream's `copyPathToStore` has no store case (eval.cc): it copies the path under `path.baseName()`, so `./build.kaem` in a nixpkgs fetched with `fetchTarball`, from a channel or as a flake input becomes `/nix/store/<hash>-build.kaem`, and a path that is exactly a store path is copied under its `<hash>-<name>` base name. Every derivation naming such a path therefore had a drvPath and output path of its own, nothing above it substituted from cache.nixos.org, its closure took in the whole enclosing tree, and its builder read its source inside that read-only tree: nixpkgs 26.05's `minimal-bootstrap.mescc-tools` now evaluates to `/nix/store/53zd871rgpcvi7qmqkffxhzaiq0is7k4-mescc-tools-1.9.1`, the path cache.nixos.org holds, where nova-nix gave another. drvPaths change for anyone whose nixpkgs lives in the store. The copy is read from the store nova-nix was given, so under `--store` and on Windows it is found where the store text names it, under the case-hack the store's volume keeps. (#676)- **What a coerced store path now does follows from the copy, as upstream's does.** A read-only `eval` computes the copy's path without writing it, so `import "${/nix/store/<hash>-<name>}/default.nix"` fails with `path '/nix/store/<hash>-<hash>-<name>' is not valid` where it used to import, as upstream's read-only `realisePath` refuses it; `import /nix/store/<hash>-<name>`, which copies nothing, and `--read-write-mode` still import it. Under `--pure-eval` or `--restrict-eval` a path inside a store path that is not allowed is refused when it is coerced, as upstream's accessor refuses the read, where it used to coerce to itself unchecked. (#676)- **A coerced path that is a symlink is copied as the link, with the links among its ancestors followed, inside a store path and outside it, as 2.34.9 and newer copy it; 2.24.9 copied what the link points to.** Upstream's `copyPathToStore` resolves a path's ancestors only from 2.34.9 (`SymlinkResolution::Ancestors`, eval.cc), where 2.24.9 resolved it in full (eval.cc), and nova-nix follows the newest release: `"${./link}"` gives the copy of the link where it gave the copy of its target. Under `--pure-eval` or `--restrict-eval` the link is read in place, so a link to a path outside the allowed ones is copied rather than refused, as upstream's accessor reads it. `builtins.path` and `builtins.filterSource` still copy what a link points to, as every release does (`addPath` in primops.cc), now inside a store path too, where they copied the link, and `builtins.storePath` of a path inside a store path that is a link names what it points to, as upstream resolves it in full (`prim_storePath` in primops.cc). Every link these follow is read in the store nova-nix was given once a path is in the store, a host link into it and an absolute link inside it included, as upstream resolves a path over the union of the host's file system and the store (`rootFS` in the `EvalState` constructor, eval.cc, from 2.34.9), so under `--store` elsewhere a path through a host link into the store reaches what it names there. The store directory and its ancestors are never taken for links for a path in the store, as upstream's store accessor looks for links only beneath the store directory (`PosixDirectorySourceAccessor::openParent` in posix-source-accessor.cc at 2.35.4 and 2.36.0), so with a `--store` directory that is a symlink store text stays in the store and `readFileType`, `filterSource` and a filtered `builtins.path` of a store path read it. On Windows a reparse point whose target no path value names, a volume mount point or a UNC link, is not walked and is left for the read to cross, as a POSIX read crosses a mount. (#676)- **Making an attribute set, a lambda, a builtin's partial application or a string with context outside an evaluation session raises `ArenaNotInitialized` naming its C entry point, as every other C data-layer allocation does, where it made an object the next session's end freed.** The arena's teardown frees these objects one by one from a record of each kind, so one made outside every session sat below every region the collector runs and was freed when the next session ended, under whoever still held it. The thunk arena, the env pages, the string arena, the symbol table and the bytecode store already refused outside a session, and a list through its items, which come from the env pages. (#703)- **A chain of `//` evaluates its operands last to first, as upstream 2.34 and later do, where it evaluated them first to last as 2.24.9 does: of two operands that fail, the later one fails the chain, `1 // "x"` refuses the string, and an operand's traces print after those of the operands after it.** Upstream 2.34's update queue gathers a chain by evaluating each update's right operand and then its left, checking each is a set as it is evaluated (`evalForUpdate`, eval.cc). Where the pinned releases differ, nova-nix follows the newest, and the parity rows whose chains hold two operands that fail run from 2.34.0. (#704)- **`builtins.addErrorContext` keeps its value's failure when evaluating the message fails too, with a line naming the message's own failure, as upstream 2.36.0 does: `builtins.addErrorContext (throw "a") (throw "b")` fails with `b`, and a throw inside it stays catchable by `builtins.tryEval` whatever the message is.** Up to 2.35.4 upstream lets the message's failure escape in place of the value's. Upstream 2.36.0 rethrows the error it caught after evaluating the message, adding `while evaluating the error message passed to builtins.addErrorContext, another error occurred: ...` to its trace when that fails (`prim_addErrorContext` in primops.cc), so that the type of the value's failure, which decides whether `tryEval` catches it, is kept. nova-nix follows the newest pinned release. (#706)- **Operators bind as upstream's grammar declares them: `-5 ? a` is `(-5) ? a`, which is `false`, `++` binds tighter than `*` and `+`, `a ? b ? c` is `(a ? b) ? c`, and `!` may stand as the operand of a tighter operator, as in `1 + !x`.** Upstream's grammar (parser.y, the same at 2.24.9, 2.34.9 and 2.36.0) binds, loosest first, `->`, `||`, `&&`, `==` and `!=`, the comparisons, `//`, `!`, `+` and `-`, `*` and `/`, `++`, `?`, and unary `-`, and a prefix operator's operand there runs as far as the operators tighter than it, so `a + !b + c` is `a + !(b + c)`. nova-nix bound unary `-` looser than `?`, so `-5 ? a` failed on negating a Boolean where upstream answers `false`; bound `++` looser than `+`, so `1 * [ ] ++ throw "c"` failed on the product where upstream reaches the throw; refused a second `?`; and refused `!` after a tighter operator, so a file holding `let x = 1 + !true; in 2` did not parse where upstream evaluates it to `2`. `a == b == c` and `a < b > c` are still refused, at the second operator, as upstream refuses them. (#736)- **`builtins.baseNameOf` drops a single trailing `/` from a string, as upstream does, so `baseNameOf "a//"` is `""` where it was `"a"`.** Upstream's `legacyBaseNameOf` (primops.cc, the same at 2.24.9, 2.34.9 and 2.36.0) removes one final slash, unless it is the whole string, and returns what follows the last slash before it; nova-nix dropped every trailing slash and every empty component. `baseNameOf "a/"` is still `"a"`, and a path value is unchanged. (#736)- **A set with `__functor` is called as a function by every builtin that calls a function it was given, as upstream's `callFunction` calls one: the predicate of `filter`, `any`, `all` and `partition`, the comparator of `sort`, the function of `groupBy` and `foldl'`, `genericClosure`'s `operator`, and the filter of `builtins.path` and `builtins.filterSource`.** nova-nix applied the functor only where a call is written in source or deferred, as `map`'s are, and these builtins refused a functor with `attempt to call a set, which is not a function`. Upstream's `callFunction` (eval.cc, the same at 2.24.9, 2.34.9 and 2.36.0) applies `__functor` to the set and then to the argument wherever it is called. (#736)- **`builtins.partition` forces each element before it calls its function on it, as upstream's does, so `builtins.partition (x: true) [ (throw "e") ]` fails with `e`.** Upstream's `prim_partition` (primops.cc, the same at 2.24.9, 2.34.9 and 2.36.0) forces every element in list order as it partitions, where nova-nix passed each one unforced, so an element the function never looked at could hold a failure that never surfaced. `any`, `all`, `filter` and the other higher-order builtins still pass their elements unforced, as upstream's do. (#736)- **A builtin checks each argument before it forces the next, as upstream's primops do, so of two bad arguments the earlier one's refusal is the error: `builtins.hasAttr 1 (throw "x")` fails with `expected a string but found an integer: 1`, and `builtins.storePath` under pure evaluation is refused before its argument is forced.** nova-nix forced every argument of these builtins as it was applied and checked them only once all were there, so a later argument that failed to evaluate hid an earlier one of the wrong type. Upstream's primops (primops.cc and context.cc, the same at 2.24.9, 2.34.9 and 2.36.0) force and check their arguments one at a time, first to last: `hasAttr`, `getAttr`, `catAttrs`, `match`, `split`, `compareVersions`, `toFile`, `concatStringsSep`, `appendContext`, `removeAttrs`, `intersectAttrs` and `bitAnd`, `bitOr` and `bitXor` check the first before they force the second; `hashString` and `hashFile` refuse an algorithm they do not know before they force what they hash; `substring` checks its start, refusing a negative one with `negative start position in 'substring'`, before it forces the length, and the length before the string; `replaceStrings` compares the lengths of its two lists, refusing a difference in upstream's words, and forces every string it replaces, before it forces the string it works on; `findFile` reads every entry, and realises each one's context, before it forces the name; and `concatMap`, `any`, `all`, `partition`, `groupBy` and `foldl'` force their function with upstream's `forceFunction`, which takes a lambda, a builtin or a set with `__functor`, before they force their list, so `builtins.any 1 [ ]` fails with `expected a function but found an integer: 1` where it was `false`. A first argument of the wrong type is refused with upstream's `expected ... but found ...` where nova-nix had words of its own. `findFile` reads an entry as upstream does: its `prefix` may be absent, and then is empty, its `path` is coerced as a string, so a set with `outPath` is a path, and one without a `path` is refused with `attribute 'path' missing`. A builtin applied to only some of its arguments still forces each as it is applied, where upstream forces none of them until the last. (#736)- **`builtins.fromTOML` refuses a date or a time with upstream's `while parsing TOML: Dates and times are not supported`, where it returned the text as a string.** Upstream (fromTOML.cc, the same at 2.24.9, 2.34.9 and 2.36.0) turns an offset or local date-time, a local date or a local time into a value only under the `parse-toml-timestamps` experimental feature, and otherwise refuses it once the document has parsed. nova-nix does not implement that feature, so it refuses each one whatever `experimental-features` says, after the rest of the document has parsed, as upstream does with the feature off. (#736)- **`builtins.toFile` refuses contents that refer to a derivation in upstream's words, naming the file and the reference: `files created by builtins.toFile may not reference derivations, but x references !out!...-d.drv`.** nova-nix refused them with `builtins.toFile: files created by toFile may not reference derivations`, naming neither. Upstream's `prim_toFile` (primops.cc, the same at 2.24.9, 2.34.9 and 2.36.0) names the first element of the contents' context that is no plain store path, in the order it keeps a context: a derivation's every output, `=` and its `.drv`, ahead of one output, `!out!` and its `.drv`; nova-nix names the same one. (#736)- **`throw` and `abort` coerce their message as string interpolation does, as upstream's do: `throw { __toString = self: "m"; }` throws `m`, a throw `builtins.tryEval` still catches, and `throw 1` fails with `cannot coerce an integer to a string: 1`.** nova-nix took only a string, and refused anything else with `builtins.throw: expected a string` or `builtins.abort: expected a string`. Upstream's `throw` and `abort` (primops.cc, the same at 2.24.9, 2.34.9 and 2.36.0) read their message with `coerceToString` at its defaults, so a set with `__toString` or `outPath` is a message, and a path is one as the store path it is copied to. (#736)- **`builtins.fetchurl` names the file it fetches as upstream does: by its `name` attribute when one is given and not empty, and otherwise by the base name of the whole URL, a query or fragment included.** nova-nix ignored `name`, and named the file by the URL's last component with any query or fragment cut off, or `source` when that was empty, so `builtins.fetchurl { url = ".../f?x=y"; sha256 = ...; }` and any fetch given a `name` had another store path than upstream's. Upstream's `fetch` (fetchTree.cc, the same at 2.24.9, 2.34.9 and 2.36.0) reads `name` with the other arguments, and when it is empty takes `baseNameOf` of the URL, which drops trailing slashes and keeps everything after the last one, so a URL ending in `/` is named by the component before it. (#736)- **`builtins.parseDrvName` splits a name at the first dash that something other than an ASCII letter follows, as upstream does: `foo-.1` is `foo` and `.1`, `foo--1` is `foo` and `-1`, and `foo-_1` is `foo` and `_1`.** It split only at a dash a digit follows, so these kept the whole string as the name and an empty version. Upstream's `DrvName` (names.cc, the same at 2.24.9, 2.35.4 and 2.36.0) splits at the first dash whose next character `isalpha` rejects, and upstream 2.36.0 sets no locale, so only `A` to `Z` and `a` to `z` are letters and a dash before a byte outside ASCII splits too. A dash that ends the string splits nothing, so `foo-` stays whole. A profile already named an element by this rule, through a second copy of the split; both now use the same one. (#750)- **`builtins.parseFlakeRef` and `builtins.flakeRefToString` read and write flake references as upstream 2.36.0 does, and the `experimental-features` setting, with `extra-experimental-features` and the `--extra-experimental-features` flag, turns on what they need.** A reference is read as upstream reads one: as a flake ID such as `nixpkgs/nixos-24.05`, then as a URL (`github:`, `gitlab:`, `sourcehut:`, `git+`, `hg+`, `path:`, `flake:` and tarball or file URLs), then as an absolute path, each input checked as its scheme checks it and refused in its words. The GitHub, GitLab, sourcehut, path and registry forms need `flakes`, as upstream's do, and a reference that names one with the feature off is refused with upstream's `experimental Nix feature 'flakes' is disabled` message; Git, Mercurial, tarball and file references need none. Upstream 2.36.0's `nix` adds `getFlake`, `parseFlakeRef` and `flakeRefToString` to every evaluator whatever the features, so `builtins ? parseFlakeRef` is true with none on; `__getFlake` is bound, as upstream binds it, and a call fails as one of `fetchMercurial` does, until flake evaluation lands, and `builtins` leaves it out, so `builtins ? getFlake` stays false. The names 2.36.0 interns as it starts take the same places here: the internal `fetchFinalTree` among fetchTree.cc's primops, and the three flake primops after every registered one. An unknown feature's name is dropped from the setting with upstream's warning, which is printed as the command starts. (#773)- **A refusal raised during evaluation reads as the refusal alone, as upstream's does: copying a tree that holds a FIFO fails with `file '<path>' has an unsupported type`, where it failed with `user error (file '<path>' has an unsupported type)`, and a FIFO given as the source itself is no longer reported as a failed read, `opening file '<path>': file '<path>' has an unsupported type`.** The evaluator rendered a refusal that the walk, the store or the database raises in its own words through GHC's display of the exception, which wraps the message in `user error (...)`, and it reworded one raised while reading a source as that read's failure. Upstream prints such refusals bare, and each now reads as its message. A filtered `builtins.path` or `builtins.filterSource` whose tree the NAR parser refuses fails with the parser's refusal, where it was prefixed with `builtins.path: internal NAR round-trip error: `, as upstream's restore of its own dump refuses such an archive in its parser's words. (#760)- **A filtered `builtins.path` or `builtins.filterSource` refuses an entry 64 levels below the source's root with `path '<path>' exceeds maximum NAR directory depth of 64`, as upstream's dump refuses it.** Upstream archives a filtered tree through the same dump as any other (`SourceAccessor::dumpPath` in archive.cc at 2.36.0), which refuses a node at depth 64, the root at 0, once the filter has kept it and before reading it. nova-nix walks a filtered tree itself to call the filter, and that walk counted no depth, so such a tree was archived and then refused only by the NAR parser, in its words rather than the dump's. (#764)- **A string a builtin reads without context is refused naming its first context element as upstream 2.34.0 and later display one: a path by its store path, a derivation's outputs by its `.drv`'s store path and ` (deep)`, and one output by the `.drv`'s store path, `^` and the output's name.** Upstream builds the message from `NixStringContextElem::display` (eval.cc at 2.36.0), so `builtins.match`, `builtins.toFile`'s name, `builtins.compareVersions`, a derivation's name and a computed attribute name each say `(such as '/nix/store/...-a')`. nova-nix named the element by its encoding, as 2.24.9 did, which wrote a path by its base name and a derivation's outputs and one output as `=` and `!out!` prefixes. (#776)- **`builtins.fetchurl` and `builtins.fetchTarball` download through nova-nix's own HTTP client, so a transient failure is retried as `builtin:fetchurl` and the substituter retry one, and `filetransfer-retry-attempts` (or its older name `download-attempts`) in nix.conf sets how many times every download and upload is tried.** The evaluator's fetchers ran `curl -sSfL` once, and `fetchTarball` piped curl into tar through `sh`, so a dropped connection or a 503 failed the evaluation where upstream's fetchers, which go through its one transfer layer, try again: up to `filetransfer-retry-attempts` times, 5 by default, retrying only what a retry can outlive. A 404 and the other refusals are not retried, and neither is a hash mismatch, which upstream checks once the transfer has finished. A failure now reads `builtins.fetchurl: fetch failed: HTTP 404 fetching URL` in the words the rest of nova-nix's downloads use, where it quoted curl's stderr; success and the hash mismatch read as they did. The setting was not read before; upstream's one setting governs every transfer, and here it governs the evaluator's fetchers, `builtin:fetchurl`, the substituter and push alike. Its value error names `filetransfer-retry-attempts` whichever name set it, as upstream's does. (#782)- **A `file://` URL is read as curl reads it for upstream's `builtins.fetchurl`, and restricted mode admits one only as upstream's does.** The fetch percent-decodes the path, drops a query and a fragment, and accepts an authority that is empty, `localhost` or `127.0.0.1`, as curl does; a URL naming another host fails. Restricted mode checked the URL's remainder as it was spelled, so `file:///allowed/..%2F..%2Fsecret` passed as one name under `/allowed` while curl read `/secret`. It now refuses, as upstream does, a file URL upstream's URL parser does not take: one with an authority (`localhost` included), a character RFC 3986 does not allow unescaped, a malformed escape, or a path segment that decodes to `/` or a NUL. Any other file URL has its decoded, canonical path checked, which is the path the fetch reads. A directory named by a file URL now fails the fetch, where macOS's curl returned an empty file. (#782)- **`builtins.fetchTarball` unpacks in process as upstream 2.36.0 does, so a tarball's tree, and with it its store path, is the archive's own, and neither it nor `builtins.fetchurl` runs `curl`, `sh` or `tar`.** A tarball is downloaded through nova-nix's own HTTP client, with upstream's retries, or read from the file a `file://` URL names. It is decompressed by what its first bytes announce (gzip, bzip2, xz, zstd or none) and read as libarchive reads tar: ustar with its prefix, GNU long names and pax headers. Its entries are placed by the rules of upstream's tar sink: the last entry at a path wins, a non-empty directory cannot be replaced, and a hard link names what its target is at that point in the archive, with upstream's warning when the target is replaced. The lone top-level directory is the tree only when the archive holds nothing else at its top, so a tarball with two top-level directories keeps both, and a macOS archive's AppleDouble `._` entries are files, as upstream reads them; nova-nix stripped the first path component of every archive and let macOS's `tar` apply AppleDouble entries as metadata. The tree's NAR is streamed into the store's restore, never extracted to a directory first, so a pair of names a case-insensitive volume folds keeps both. A pin the tree does not match is refused in 2.36.0's `NAR hash mismatch in input` words, a `file://` tarball that is missing or a directory in its words, and a failure of the fetch carries upstream's `while fetching the input` line. A tree holding a name that upstream's tree builder refuses, `.git` in any spelling NTFS reads as the same name (`.GIT`, `git~1`, `.git.`), is refused in its words before the store path is computed. A zip archive and a sparse archive member are refused as not yet supported. Upstream's libarchive also decompresses lzip, lzma, lz4, lzop, compress, lrzip, grzip, uuencode and RPM streams, some through an external program, and nova-nix does not: a tarball in one fails with `Failed to open archive (Unrecognized archive format)`, as does any body that is no archive at all. Upstream 2.36.0 copies a fetched tree into the store only when a context needs it; nova-nix writes it at once. (#816)### Store- **`store gc` and `store delete` refuse a store directory that upstream Nix's database also manages, such as `/nix/store` where upstream Nix is installed, and name that database.** The collector deletes every entry in the store directory that nova-nix's own roots do not keep, and a path upstream registered has no row in nova-nix's database, so in a store shared with a single-user upstream install, or with nova-nix run as root, `store gc` deleted every upstream path and left upstream's database naming paths that no longer existed; `store delete` removed a named upstream path the same way. The refusal looks for upstream's database where upstream's local store keeps it: `/nix/var/nix/db/db.sqlite` for `/nix/store`, and `<root>/nix/var/nix/db/db.sqlite` for a store upstream opens with a root at `<root>/nix/store` (`LocalFSStoreConfig` and `LocalStore` at 2.24.9). It looks only beside a directory named `nix/store`, the name of upstream's default store and of every store it opens with a root, both as the store is spelled and as its links resolve, so a store of nova-nix's own beside upstream's, such as `/nix/nova-store`, is collected as before. A store is refused too when that path cannot be examined, such as under a directory this user cannot search, since it may be that database. An upstream whose state directory is moved, by `NIX_STATE_DIR` or by its build, is not recognised, nor is a store reached through a bind mount. `store gc --print-roots` still lists the roots. (#442)- **`deleteStorePaths` replaces `withLiveSet` and `deleteStorePathChecked`, so a delete's live set cannot outlive its collector lock or come from another store.** `withLiveSet` handed its callback a `LiveSet` the callback could return, and `deleteStorePathChecked` took the live set and the store separately, so a library caller could delete with a live set after the collector lock was released, or with another store's: the liveness check then read the roots as they stood when the set was made, or another store's roots, and the delete removed a live path. The live set is now made and consumed inside one call. `store delete` runs on `deleteStorePaths` and prints what it printed. (#446)- **`build` refuses a store directory that upstream Nix's database also manages, such as `/nix/store` where upstream Nix is installed, and names that database; `eval` refuses one at the evaluation's first write to it.** A path upstream registered has no row in nova-nix's database, so a build that came to build or substitute such a path took upstream's tree for a leftover of its own: it removed the tree before the builder ran, again when the build failed, and before unpacking a substitute, leaving upstream's database recording a NAR hash the new tree need not have, or a path that no longer existed. The build is refused before anything is evaluated, for the same stores `store gc` and `store delete` refuse, so a store of nova-nix's own beside upstream's, such as `/nix/nova-store`, builds as before. An evaluation's own store writes, such as a fetcher's result, clear a tree that does not reproduce its address, which in such a store may be one upstream registered or is writing, so an evaluation stops with an error at its first write there; one that writes nothing, such as `eval` computing a derivation's path, is not refused. `push` and `store gc --print-roots`, which change no path in the store, are not refused. (#452)- **The library's checked delete refuses a name that is not one entry of the store directory, where it removed a path outside the store, the store directory itself or the store's metadata directory.** `deleteStorePathRaw` and `deleteStorePaths` joined the name they were given to the store directory, and that join keeps an absolute name as it is and follows `..`, so `/etc/x` or `../x` passed the liveness check, found no registration row and was removed as a tree without one, with a lock file left beside it. The empty name joined to the store directory itself, `.` to everything in it, and `.nova-nix` named the metadata directory that holds the store's database and roots. Such a name is now refused before the delete takes a lock or looks for a tree: the empty name, a `/` or a `\`, a dot-leading name, a `:` and a NUL, which are the rules `store delete` already applied to the last component of each argument, with the separators and NUL added. Upstream's delete is never handed a name: `nix-store --delete` resolves each argument to a store path first (`opDelete` and `GCOptions::pathsToDelete`, a `StorePathSet`, at 2.24.9). `store delete` refuses what it refused before; its refusal of an empty name no longer repeats the argument. (#457)- **A path added to the store takes upstream's canonical metadata: every file and directory is made `0444`, or `0555` when its owner may execute it, and every node, a symlink's own included, has the modification time 1, a second past the epoch, as upstream's `canonicalisePathMetaData` leaves them (posix-fs-canonicalise.cc at 2.24.9).** nova-nix cleared only the owner's write bit, so a path kept the times it was written with and the group and other bits of whatever wrote it: a file a NAR or `builtin:unpack` marked executable could be executed by its owner alone, and a `.drv` stayed writable. Upstream canonicalizes a build's outputs (`registerOutputs`, local-derivation-goal.cc at 2.24.9, derivation-builder-impl.cc at 2.36.0), a substituted or downloaded path (`LocalStore::addToStore`, local-store.cc) and whatever `addToStoreFromDump` adds, which is every other store write an evaluation makes and each `.drv` (local-store.cc). Here that is a build's outputs, a substituted path, each store object an evaluation writes, as it writes it (`builtins.toFile`, `builtins.fetchurl`, `builtins.fetchTarball`, `builtins.fetchGit`, `builtins.path` and `builtins.filterSource`), the sources a build restores, and each `.drv` a build writes, including a tree on disk that already reproduces its address, or that `builtins.fetchGit`'s cache names, and is kept as it is. So `eval` alone leaves a `builtins.fetchTarball` tree as `nix-instantiate` 2.24.9 does: a file `0444` and an executable `0555`, each with the time 1, where nova-nix left what its restore wrote, `0644` and `0744` under the usual umask, with the time of the restore. As upstream's does, the walk drops the setuid, setgid and sticky bits, leaves a symlink's mode alone, keeps a node's access time to the whole second, gives a node another user owns to the process's user and group, and fails a path holding a node that is not a regular file, a directory or a symlink with `file '<path>' has an unsupported type`. A NAR records only the owner's execute bit, which the canonical mode keeps, so no store path or NAR hash changes. Upstream also clears a node's file flags on macOS, which nova-nix does not. On Windows, where upstream sets no times and has no modes, each file and directory is given the read-only attribute, as before, and the same time, and a symlink the time. (#477)- **On Windows a store directory nova-nix creates, and its `.nova-nix` state directory, can be changed only by the user nova-nix runs as, SYSTEM and Administrators, a directory it creates on the way to the store, such as `C:\nix`, is open to them alone, and a build directory is that user's alone, where each took the permissions of the directory it was made in.** A directory made under a drive root takes the root's permissions, which let every signed-in user (Authenticated Users) modify it, so under the default `C:\nix\store` any user of the machine could change, replace or delete store paths and the store's database, rename a `C:\nix` nova-nix had made and put a store of their own in its place, and change a build's sources and outputs while it ran. nova-nix now creates each of these directories with a protected access control list, which takes nothing from its parent, in the one `CreateDirectoryW` call that makes it, so the directory never exists with its parent's permissions. A store directory and its state directory grant full control to the user, SYSTEM and Administrators and read and execute to Users, the rights, inheritance and principals install-nova-nix sets on `C:\nix`; a parent directory nova-nix creates on the way to the store grants full control to the user, SYSTEM and Administrators and nothing to other users; a build directory grants full control to the user alone, as its mode 0700 does on macOS and Linux. Each grant is inherited by what is made below, so store paths and a build's tree are covered too. A directory that already exists keeps the permissions it has. install-nova-nix accepts a `C:\nix` this release creates, since it grants nothing to an account the installer does not trust, and gives it the installer's own permissions, which add read and execute for Users. A store created inside a private folder, such as a `--store` under the user's profile, now grants Users read and execute, as a store's permissions do wherever it is, where it took the folder's own list before, which under the profile grants other users nothing. Upstream's local store creates its directories with `std::filesystem::create_directories` on every platform and sets no access control list on Windows (`createDirs`, file-system.cc, and the `LocalStore` constructor, local-store.cc, at 2.24.9). macOS and Linux are unchanged. (#659)- **A derivation whose source is a symlink builds, and a copy is restored from the tree evaluation hashed.** A coerced path that is a link is copied as the link, as 2.34.9 and newer copy it, and the build driver restores it as the link; `src = ./link`, with `link` pointing at a directory or a file, had failed with `refusing to register /nix/store/...-link: .../link changed after evaluation hashed it`, since evaluation hashed what the link pointed to and the restore dumped the link. Evaluation still follows the links among a path's ancestors, so the restore now reads the path evaluation read, those links resolved, rather than the path as written: a coerced path below an absolute link inside a store path, as a NAR carries one into another store path, is restored from the store nova-nix was given rather than through the link on the host, and the tree is read under the case-hack its resolved text calls for, as evaluation read it. A copy `builtins.path` or `builtins.filterSource` makes, of what a link points to, is written by evaluation itself and never restored this way. (#676)- **On Linux and macOS a file's executable flag in a NAR is the owner-execute bit of its mode, as upstream's dump reads it, where nova-nix asked whether it could execute the file.** Upstream's `PosixSourceAccessor` (posix-source-accessor.cc at 2.36.0) takes `st_mode & S_IXUSR`; nova-nix's `Nix.Store.ExecBit.isExecutable` answered from `access(2)`, which differs for a process running as root, which may execute a file any of whose execute bits is set, and for a file whose access control list refuses execution, so in those cases a path's NAR, and so its NAR hash and any path made from it, differed from upstream's. Windows, which keeps the flag in a stream of the file, is unchanged. (#739)- **On Windows nova-nix refuses a store when its directory, its `.nova-nix` state directory or a directory on the way to them below the drive root belongs to an account other than the user nova-nix runs as, SYSTEM and Administrators, has no DACL, or lets any other account change it, and the error names the directory and what is wrong with it.** A drive root lets every signed-in user create a folder in it, so on a machine where install-nova-nix never ran another user could create `C:\nix` first; nova-nix then made its protected store inside a folder that user owned, and as its owner they could give themselves the right to delete what it holds, move the store aside and put a store and database of their own in its place, which the next build would run from. nova-nix now holds each of these directories that already exists to install-nova-nix's rule for `C:\nix`: its owner is the user, SYSTEM or Administrators, it has a DACL, and no allow entry of any kind, an inherit-only one included, grants another account a right that changes it. Read and execute for Users is no change. A directory is checked before nova-nix creates anything in it or reads anything from it, an evaluation's write into the store and a read-only command's queries of the database included, since a database another account controls is as dangerous to read as to write; the error says to move the directory aside and let nova-nix or install-nova-nix create it. A `C:\nix` either of them creates passes for the user it was created for, and so does a store under the user's profile; another user's nova-nix refuses it, since it lets its creator change it. A store in a folder that took a drive root's permissions is refused, a `C:\nix` an earlier nova-nix release created among them. The drive root itself is not checked, since its default permissions let other users create a folder in it but not delete or rename one already there. A link is checked as itself, not as what it leads to, so a link the user made stands, where install-nova-nix refuses one at `C:\nix`. A store upstream Nix's database also manages, whose tree answers a read-only command's queries, is checked before the tree is read. Upstream Nix has no such check: on Linux and macOS only root can create a directory in `/`. macOS and Linux are unchanged. (#742)- **The garbage collector quotes a root, a link or a target in double quotes, as upstream does from 2.35.4 on: `removing stale link from "<record>" to "<out-link>"`, `skipping invalid root from "<link>" to "<target>"`, `cannot read potential root "<path>"`, and the refusals `creating a garbage collector root ("<link>") in the Nix store is forbidden` and `cannot create symlink "<link>"; already exists`.** These lines quoted the path as upstream 2.24.9 does, in single quotes, or, inside the parentheses of the in-store refusal, not at all. Upstream 2.35.4 and 2.36.0 format these paths with `PathFmt`, which writes a path between double quotes and escapes nothing inside, and nova-nix follows the newest pinned release. `deleting '<path>'` and `Cannot delete path '<path>' since it is still alive` keep their single quotes, as upstream's do, since it formats those store paths as strings. (#751)- **A store path's info records whether this store built it, the signatures it came with and the content address its name was made from, and the store lists each valid derivation's outputs, in the columns and the table upstream's database has.** A built output is ultimately trusted, and a fixed one has the address it was checked against; a substituted path keeps its narinfo's signatures and the address its tree was held to; a source, a write evaluation made and a `.drv` have the address their paths are made from. Upstream records the same (`ultimate`, `sigs` and `ca` in `ValidPaths`, and `DerivationOutputs`), and a daemon answering for the store reads them back. A database an earlier nova-nix made gains the columns, empty in every row it holds, and the table, filled from the derivations it holds, the first time it is opened for writing. (#749)- **Registering a path whose name ends in `.drv` reads it as a derivation, and one that does not parse is refused with `error parsing derivation '...'`, as upstream's store refuses it.** Upstream lists a derivation's outputs from its file when it registers it, so a `.drv` that is not a derivation never becomes valid there. (#749)- **A garbage collector root for an out-link whose name has no UTF-8 reading keeps that name: the link is made, recorded and found again under the bytes it was given.** The link's spelling went through text, which replaced each such byte with U+FFFD, so the link was made under a name other than the one asked for, and its record held that name. Upstream keeps a root's path as bytes. (#749)- **A collection, a checked delete and `store gc --print-roots` read, for a store in a directory upstream's local store uses, the roots under upstream's `gcroots` and `profiles` in its state directory, `/nix/var/nix` for `/nix/store`, beside the store's own.** Upstream's clients keep their profiles and their out-links' roots there, and upstream's collector reads both directories, so a nova-nix store that serves them would otherwise collect what they keep. (#756)- **On Windows registering a store path gives each of its files and directories the store's account as owner and a protected access control list no build account can change, and where the machine has a local `nixbld` group, the store directory lets that group create entries in it and nothing else.** Builds are to run as build accounts in a local `nixbld` group, as upstream's Linux builds run as `nixbld` users, and a path a build made would otherwise keep the permissions its build gave it, so the account that built it could change or delete it once it was valid. Registration now sets, on every node of the path, a link included and not followed, the account nova-nix runs as as the owner, as upstream gives each node of a path to the store's user, and a protected DACL that grants that account, SYSTEM and Administrators full control, Users and the `nixbld` group read and execute, and the node's owner read-control alone (OWNER RIGHTS), which takes the place of the rights an owner otherwise keeps whatever the DACL says. A node registration cannot read, as one a build gave a DACL that grants the account nova-nix runs as nothing, fails the registration, naming the node, rather than being passed over with the access its build gave it. An access control list is no part of a NAR, so a path's hash is unchanged. Where the machine has a local `nixbld` group, a store directory nova-nix creates grants its entries to itself alone and the group FILE_ADD_FILE, FILE_ADD_SUBDIRECTORY, traverse, read attributes and synchronize, so what a build makes there takes its own token's default DACL rather than one passed down; the check of a store's directories accepts that grant on the store directory alone, and only applying to the directory itself. A machine with no `nixbld` group keeps a single-user store as it was: its store directory passes its entries down as before, and a registered path grants what it would have inherited, with the user as its owner. (#758)- **A store whose database holds paths, none of them under the directory the store is opened at, is refused, with an error saying where they are, instead of being read as empty and built into again.** nova-nix records each valid path in the store's database as the full path under the directory it was registered at, and the outputs built in the store name that directory too. A store opened under another directory, such as a drive that comes up under another letter or a store moved or renamed on any platform, therefore found none of its paths valid, and a build ran over the outputs already there, which still name the old directory and cannot work from the new one. The open now fails with `store 'NEW' was made at 'OLD', and its paths and the outputs built in it name that directory; use it from there`, for a database opened to write and one opened to read alike, before anything is written to the database. A recorded directory that is not an absolute path on the host, such as a relative spelling, is not named as one to use: the error says the store records its paths under another directory, as in the path it quotes. A store that holds a path under the directory it is opened at opens, so one already built into at its new directory is not locked out, and so does a store with no paths yet, at any directory, and a store moved back to where it was made. (#818)### Builder- **A builder's environment holds `NIX_BUILD_CORES`, from the nix.conf setting `cores`, so nixpkgs' `setup.sh` runs `make` for a package with `enableParallelBuilding` with as many jobs as it does under upstream.** nova-nix set no such variable, and setup.sh reads an unset one as 1, so every such package built on one core. Upstream sets it in every builder's environment from `settings.buildCores` (`LocalDerivationGoal::initEnv`, local-derivation-goal.cc at 2.24.9, `UnixDerivationBuilderImpl::initEnv` in unix-derivation-builder.cc at 2.36.0) before it copies in the derivation's environment, so where a derivation's attributes reach the environment, which they do not under `__structuredAttrs`, an attribute of that name wins, as it does here. The setting is read as upstream's `cores` is (`Settings::buildCores` in globals.hh at 2.24.9, `LocalSettings::buildCores` in local-settings.hh at 2.36.0): an unsigned integer under the grammar `max-call-depth` takes, also set through its alias `build-cores`; `0` gives the default count below, as upstream 2.36.0 resolves it when it builds, where 2.24.9 passed it through; a value that does not parse is refused as `setting 'cores' has invalid value '...'`, naming `cores` when it was set through `build-cores`, as upstream's error does; and `extra-cores` is an unknown name. A value past an unsigned 32-bit integer is refused, where upstream multiplies a unit suffix in 64 bits and keeps the low 32 (`string2IntWithUnitPrefix` in util.hh), so that its `cores = 4G` is 0, the default count. With nothing setting it, or with `0`, the value is upstream's default (`Settings::getDefaultCores`, globals.cc). On Linux that is the CPU limit of the process's cgroup when it has one, found as upstream's `getMaxCPU` finds it (current-process.cc): the first `cgroup2` mount in `/proc/mounts`, read as glibc's `getmntent` reads it, joined to the group `/proc/self/cgroup` lists under no name, which is parsed as upstream's `getCgroups` parses it (linux/cgroup.cc), and that group's `cpu.max` quota over its period, rounded up after the division in single precision as upstream divides. A quota past a signed 32-bit integer, which the kernel accepts, is no limit here, where upstream's `std::stoi` throws an exception its `catch (Error &)` does not catch and every command aborts. Otherwise it is the hardware thread count upstream's C++ runtime reports for `std::thread::hardware_concurrency`, at least 1, read through the same call, `sysconf(_SC_NPROCESSORS_ONLN)`: libc++ makes that call on macOS (16.0.6, which nixpkgs 24.05 builds upstream with), and on Linux libstdc++ calls glibc's `get_nprocs`, the function glibc's `sysconf` answers that name with (sysdeps/posix/sysconf.c at glibc 2.39). On Linux the glibc is the host's, where upstream's is nixpkgs' 2.39, and the two count the CPUs online alike on every glibc release but 2.34, whose `get_nprocs` counts the process's affinity mask. On Windows, where upstream has no local builder, the count is GHC's `getNumProcessors`. Upstream's `--cores` flag is not implemented. (#436)- **A build runs in a directory it creates under the store's state directory, `.nova-nix/builds`, with mode 0700 on macOS and Linux, where it ran in the system temporary directory under its first output's hash.** The build removed that path and then created it with a call that accepts a directory already there, and anyone can compute the name from the derivation, so in a world-writable `/tmp` another local user who created the directory first owned the directory the build ran in and could change its sources and scripts before the outputs were registered. The directory's default mode also let other users read what the build unpacked. The name did not depend on the store either, so two builds of one derivation into two stores at once shared one directory, and the second removed the first's tree mid-build. Upstream creates each build directory with `mkdir` and mode 0700 and never enters one that exists (`createTempDir`, file-system.cc at 2.24.9), and since 2.30.0 roots them at its state directory by default (`LocalBuildStoreConfig::getBuildDir`, local-store.cc), documenting that `build-dir` must not be world-writable. Each store's state directory holds that store's builds, and whoever can write there can already rewrite the store's database. The name is still the first output's hash, where upstream's is `nix-build-<drv name>-<n>`: the build holds that output's path lock throughout, so the name belongs to one build at a time, and a directory a killed build left there is removed before the next build of the derivation creates its own. The directory is removed when the build ends even when the builder left a read-only tree in it, as upstream's `deletePath` removes one. On Windows the directory, which was in the per-user temporary directory, is the user's alone, as the entry on Windows store permissions says. A derivation with no outputs, whose build fails whatever its builder does, fails before its builder runs. (#449)- **A built output's registration names the `.drv` that built it, so `nova-nix push` writes its narinfo with upstream's `Deriver` field.** Upstream records the derivation as the deriver of every output it registers from a build (`newInfo.deriver = drvPath` in `registerOutputs`, local-derivation-goal.cc at 2.24.9, derivation-builder-impl.cc at 2.36.0), and a narinfo names it by its basename. nova-nix registered a built output with no deriver, so its pushed narinfo had no `Deriver` line, while a substituted path kept the deriver its cache's narinfo named. Upstream's `keep-derivations` and `keep-outputs`, through which its garbage collector reads the deriver, are still not implemented. (#473)- **`builtin:fetchurl` restores the NAR it downloads when the derivation's `unpack` is true, and makes its output executable when `executable` is true, as upstream's does, so a `<nix/fetchurl.nix>` fetch with either attribute builds.** The bundled `<nix/fetchurl.nix>` declares a recursive hash for either, and nova-nix's builtin refused every recursive hash, so such a fetch evaluated and then failed to build. Upstream's builtin (`builtinFetchurl` in builtins/fetchurl.cc) restores the download as a NAR when `unpack` is `1`, decompressing it with xz first when the URL ends in `.xz` and never otherwise, writes it as the output file when `unpack` is anything else, and then sets the output's mode to `0755` when `executable` is `1`. nova-nix does the same, restoring through the streaming restore the substituter uses and decompressing through nova-cache's xz decoder, so neither the download nor the archive is held whole. Under `executable` it marks a regular file and leaves a directory as it is, since a NAR records no mode for a directory. A restored root that is a symlink fails that URL, and the next is tried, rather than being followed: upstream's `chmod` follows the link, but in the build's child process, after its `chroot` when the build is sandboxed and as the build user when there are build users (`LocalDerivationGoal::runChild` in local-derivation-goal.cc at 2.24.9, `UnixDerivationBuilderImpl::runChild` in unix-derivation-builder.cc at 2.36.0), where a file outside the build is absent or not the build user's to change, so the `chmod` fails the build there, while nova-nix runs a builtin as the invoking user and following the link would change the file it names. The output is held to the hash the derivation declares, in the mode it declares whatever made the output, as upstream's `registerOutputs` holds it: a flat hash needs a regular file its owner may not execute and is of its bytes, and a recursive one is of the output's NAR, the executable flag included. Registration then gives it the store's canonical metadata, so an executable file and every directory are `0555` and every other file `0444`, as upstream leaves them. A fetch of an `.xz` URL without `unpack` keeps the bytes it downloads, as upstream's does. As with a flat hash, each URL a derivation lists is held to the hash before the next is tried, so a mirror that serves the wrong tree is passed over. Three things differ from upstream. nova-nix restores only an archive in the canonical form upstream writes, failing one with bytes after its end or with a file's fields out of order, where upstream's restore stops reading at the archive's end and takes those fields in either order (`parse` in archive.cc at 2.24.9). An archive that fails to parse is retried as a torn transfer is, as the substituter retries one, where upstream fails the build at once. And the xz decoder's memory is bounded at nova-cache's default of 1 GiB, as the substituter's is, where upstream's libarchive decoder has no bound; the largest xz preset needs about 65 MiB. (#501)- **An output under a flat fixed-output hash must be a regular file its owner may not execute, read without following a symlink, as upstream requires of every build's, and any other fails with upstream's `output path '<path>' should be a non-executable regular file since recursive hashing is not enabled (one of outputHashMode={flat,text} is true)`.** Upstream reads the output with `lstat` and refuses any other form in `registerOutputs` (local-derivation-goal.cc at 2.24.9, derivation-builder-impl.cc at 2.36.0). nova-nix refused only a directory, in words of its own, and followed a symlink: a symlink output was hashed as the file it named and registered as the symlink, and an executable file was registered `0555` under a hash that records no mode. The rule holds for every builder, a spawned one and `builtin:fetchurl` alike, and for the rebuild `nova-nix build --check` compares. (#501)- **Only a fixed-output derivation's builder sees the variables its `impureEnvVars` lists, as upstream decides by the derivation's type: a floating content-addressed output, an impure one, and a fixed output beside others or not named `out` no longer pass them.** The variables reached any build with an output that names a hash algorithm, which a floating content-addressed output does too. Upstream passes them to a derivation whose type is not sandboxed (`LocalDerivationGoal::initEnv` in local-derivation-goal.cc at 2.24.9, `UnixDerivationBuilderImpl::initEnv` in unix-derivation-builder.cc at 2.36.0), and the type is fixed-output only for one output, `out`, with the hash that fixes it (`BasicDerivation::type` in derivations.cc at 2.24.9, `derivation::type` there at 2.36.0). A floating output, which names an algorithm and no hash, is sandboxed (the same function), and a fixed output beside others or named otherwise makes a derivation upstream refuses (again `BasicDerivation::type`). Upstream also passes them to an impure derivation, which takes the experimental `impure-derivations` feature that nova-nix does not implement. nova-nix makes no floating or impure derivation and reads none upstream writes, since upstream writes such an output with no path (`Derivation::unparse` in derivations.cc at 2.24.9, `unparse` in derivation/aterm.cc at 2.36.0), so one reaches the builder only from the library or a `.drv` written by hand. The rule is the one `nova-nix trust` uses to find a closure's fixed-output derivations. (#642)- **A builder's program, arguments and environment entries end at their first NUL, as upstream's exec takes them.** Upstream passes each argument and each `NAME=VALUE` entry it builds to `execve` as a C string (`stringsToCharPtrs` in util.cc and `LocalDerivationGoal::runChild` in local-derivation-goal.cc at 2.24.9), so its builder gets each up to the first NUL a derivation's string holds, which `builtins.fromJSON` can put there. nova-nix refused to spawn a builder whose environment held a NUL, since the process library refuses one, and on Windows a NUL in a value started another variable and one in an argument ended the command line. Each is now cut at its first NUL before the spawn, so the builder gets what upstream's gets, with one exception in an unsandboxed build: an entry left with no `=`, by a name holding a NUL, is one the process library cannot pass, and is left out. Upstream passes it, and no `getenv` finds a variable in it. (#673)- **A build directory, or a sandbox's chroot, that an earlier build left and that cannot be removed is moved aside, with a warning, and the build goes on.** Both are named by the derivation, so a leftover that cannot be removed, such as a directory another user made there through a descriptor a fixed-output builder handed out, which the user may neither empty nor change, failed every later build of the derivation. It now moves to the first free name of its path with `.leftover.` and a number after it, beside it in the store's state directory, and the warning names both paths. Removal that runs out of descriptors on a tree deep enough leaves a chroot the next build moves aside the same way. (#673)- **A build's output that its group or anyone else may write is refused, every output is made canonical before it is read or changed, and a fixed output is replaced by a fresh copy of itself before it is hashed, as upstream's are.** Upstream refuses such an output with `suspicious ownership or permission on '...' for output '...'; rejecting this build output`, since someone other than the build may have changed it, then makes the output canonical, so nothing in it is setuid, or open to another user's write or swapped link, while it is rewritten and scanned (`registerOutputs`, local-derivation-goal.cc at 2.24.9, derivation-builder-impl.cc at 2.36.0). nova-nix made an output canonical only once it was placed. A fixed output's fresh copy leaves behind the inode the builder wrote, so a descriptor the builder passed out of its build cannot change what is registered (the fresh copy in `registerOutputs`); the copy is made canonical in its turn, and it is the copy that is scanned and hashed, before it leaves the chroot. A fixed output that references a store path, itself included, is refused with upstream's `illegal path references in fixed-output derivation '...'` (the fixed-output reference check in `registerOutputs`), which nova-nix let through; upstream registers such an output under the path its references give it before it fails the build, and nova-nix registers nothing, as for a hash mismatch. On Linux an output's extended attributes, ACLs among them, are removed as it is made canonical, as upstream removes them (`canonicalisePathMetaData_` in posix-fs-canonicalise.cc), but for the three upstream's `ignored-acls` keeps by default, `security.selinux`, `system.nfs4_acl` and `security.csm`. A directory in an output that its owner may not search is given search before it is read, so it ends at 0555 where upstream's canonicalisation gives it 0444 and a single-user upstream build, not run as root, then fails to read beneath it. A sandboxed build's outputs go through all of it in the chroot and move into the store only when registered (the final move in `registerOutputs`), so a check's outputs, and the copy of an output that was already valid, never enter the store. A hash rewrite of an output's file opens it without following a link, and refuses one swapped in. An output holding a node another user owns is refused with upstream's `invalid ownership on file '...'` (`canonicalisePathMetaData_` in posix-fs-canonicalise.cc at 2.24.9) before it is made canonical, which would change that node, a hard link into the output among them. A directory output moves into the store by a rename, given owner write for it as upstream's `movePath` gives it (local-derivation-goal.cc at 2.24.9, unix/file-system.cc at 2.36.0), so it keeps its inodes and hard links, and a rename that fails fails the build, except across volumes, where the move copies. An output that is a symlink is there whatever it names, as upstream reads it with `lstat` (`registerOutputs`), where nova-nix took one naming nothing, or a sibling output not yet in the store, for a missing output. nova-nix now runs with upstream's file-creation mask, 0022, as every upstream command does (`initNix`, shared.cc): everything it creates is made under it, the store and its database, push and fetch caches, garbage-collector roots and out-links among them, and so is everything a builder it starts creates, so no ordinary build's output is refused. (#673)- **On Linux a build runs in a sandbox by default, as upstream's does: in fresh user, mount, PID, IPC and UTS namespaces, with a chroot that holds the closure of its inputs, and in a network namespace of its own, holding only a loopback interface, unless the derivation is fixed-output.** Upstream sandboxes every build on Linux unless `sandbox` says otherwise (`Settings::sandboxMode` in globals.hh at 2.24.9, `LocalSettings::sandboxMode` in local-settings.hh at 2.36.0), and nova-nix ran every builder with the whole filesystem and the network in reach. A build an evaluation starts for an import from a derivation runs in the sandbox too, whichever command evaluates. The new `nova-nix-sandbox` helper, a C program installed beside `nova-nix`, makes the namespaces and the chroot and executes the builder, following upstream's `startBuilder` and `runChild` (local-derivation-goal.cc at 2.24.9): the setup runs between the namespaces' creation and the builder's exec, where nova-nix can run nothing, since the process library gives no hook between fork and exec and a child forked from the threaded GHC runtime may make only async-signal-safe calls. The helper is spawned with an empty environment, so its dynamic loader reads no variable a derivation sets, such as `LD_PRELOAD`; the builder's environment travels in the helper's plan and is applied only at the builder's `execve`, as upstream's is (`LocalDerivationGoal::runChild` in local-derivation-goal.cc at 2.24.9, `UnixDerivationBuilderImpl::runChild` and `execBuilder` in unix-derivation-builder.cc at 2.36.0). A build sees what upstream's sandboxed build sees: uid 1000 and gid 100, mapped to the invoking user, or as root to the build user and its group, upstream's `/etc/passwd` and `/etc/group`, the host name `localhost`, itself as PID 1, a fresh `/proc`, a tmpfs `/dev/shm`, upstream's `/dev` nodes, a writable `/tmp`, its build directory at `sandbox-build-dir`, `/build`, which `NIX_BUILD_TOP`, `TMPDIR`, `TEMPDIR`, `TMP` and `TEMP` name, and upstream's `HOME`, `/homeless-shelter`. The directory bound there is one inside the build's own, as upstream binds `topTmpDir + "/build"` (`LocalDerivationGoal::startBuilder` in local-derivation-goal.cc at 2.24.9, `ChrootDerivationBuilder::setBuildTmpDir` at 2.36.0), so a builder that opens what it sees to everyone leaves the 0700 directory around it closed to every other user. Its environment still differs from upstream's: `PWD`, `TERM` and `NIX_OUTPUT_CHECKED` are not set, the builder's `argv[0]` is its whole path where upstream's is its base name, and its output reaches the log through a pipe where upstream's goes through a pseudo-terminal. An output that is already valid, or that a check builds again, is still written at a scratch path whose hash is rewritten in it afterwards, as outside the sandbox, where upstream's sandboxed build writes it at its own path, which the chroot leaves free (`LocalDerivationGoal::needsHashRewrite` and `LocalDerivationGoal::startBuilder` in local-derivation-goal.cc at 2.24.9, `ChrootDerivationBuilder::needsHashRewrite` at 2.36.0). A fixed-output build gets the host's network, its `/etc/resolv.conf`, `/etc/services` and `/etc/hosts`, and the `ssl-cert-file` bundle at `/etc/ssl/certs/ca-certificates.crt`; any other gets `/etc/hosts` naming the loopback. Every host path is bound read-only, the build directory alone writable, where upstream binds them plainly: a builder that runs as the invoking user could otherwise change a valid store path, the bundled shell later builds run, an `--exec-wrapper` launcher, or a file of the user's a `sandbox-paths` entry names. The one exception is upstream's too: where the kernel will not mount a devpts of the sandbox's own, the host's `/dev/pts` and `/dev/ptmx` are bound writable instead (`LocalDerivationGoal::runChild` in local-derivation-goal.cc at 2.24.9, `ChrootLinuxDerivationBuilder::enterChroot` at 2.36.0). A `sandbox-paths` target, or `sandbox-build-dir`, that is not absolute or has a `..` component is refused, since joined to the chroot it names a path outside it, and so is one whose path crosses a link in the chroot, such as `/dev/fd` or a link an earlier entry copied in; upstream joins a target to its chroot as it is and follows what it finds. Each directory on the way is opened by its descriptor, which takes search on it and not read, and a bind is made read-only through the descriptor of the mount just made, not by its path. Once the builder has ended, before anything reads an output, the chroot is closed to every other user: the directories from its root down to its store directory become 0700, and every directory in the store directory's subtree, an output's own included, becomes 0700, each read without following a link and changed only once its parent is closed, since a fixed-output builder, which keeps the host's network, could have passed another user a descriptor for one of them. Whether the builder left an output writable by others is read first, so such an output is still refused. A process of the same user, a concurrent build among them, is not kept out. A bind is read-only through every mount beneath its source, which a recursive bind brings along, on any kernel: in one step through `mount_setattr` from Linux 5.12, and before it by remounting each mount `/proc/self/mountinfo` lists there. The builder gains no privileges through its exec, from a setuid program or file capabilities a `sandbox-paths` entry makes reachable, as upstream's builder gains none by default (`allow-new-privileges`, globals.hh at 2.24.9, local-settings.hh at 2.36.0), and it starts with an empty session keyring of its own, so it does not inherit possession of the invoking user's session keyring. That is all the keyring stops: a builder that runs as the invoking user's uid is shown the user's keys in `/proc/keys`, and that uid may link the user keyring into the builder's own, so a builder that tries can read the keys the user keyring holds. Only a filter refusing `keyctl`, `add_key` and `request_key` closes that, as it would for upstream's single-user builds; a builder that runs as a build user, upstream's or nova-nix's as root, has no keys of the invoking user's. An interrupt, or nova-nix's end, makes the helper kill the builder, whose PID namespace the kernel ends with it, and a helper killed outright takes the builder with it unless the builder has cleared its own parent-death signal, which upstream's builder, PID 1 of its namespace too, can as well; nova-nix returns from an interrupt only once the helper has reaped the builder, so no process a builder started outlives the build, and the chroot is removed after them. The helper puts `SIGCHLD` back to its default before it starts a builder, as upstream's `initNix` does (shared.cc), so a nova-nix started with `SIGCHLD` ignored still sees its builder end. The settings are upstream's, under its names, aliases and defaults: `sandbox` (`build-use-chroot`, `build-use-sandbox`) takes `true`, `relaxed` or `false`, and refuses anything else with `option 'sandbox' has invalid value`; `sandbox-paths` (`build-chroot-dirs`, `build-sandbox-paths`, and `extra-` for each) binds `TARGET=SOURCE` entries, with `?` after a source that may be missing and a store source's closure bound beside it; `sandbox-fallback`, `sandbox-build-dir`, `sandbox-dev-shm-size`, `require-drop-supplementary-groups` and `ssl-cert-file` are read too. `build`, `eval` and `trust`, each of which evaluates, take `--sandbox`, `--no-sandbox` and `--relaxed-sandbox`, and upstream's `--build-use-chroot` and `--build-use-sandbox`, which mean `--relaxed-sandbox` as upstream's do: it registers the setting's older names on all three flags, and the last registration holds them (`Args::addFlag` in args.cc). Under `sandbox = true` a derivation setting `__noChroot` fails with upstream's error; under `relaxed` it, and a fixed-output derivation, builds unsandboxed. A setup step that fails is reported with the words of upstream's error for it and the system's text for the errno, after `while setting up the build environment: ` on the same line, where upstream prints that context as a trace line and the error after an `error:` of its own. A derivation whose builder is a host program, such as `/bin/sh`, now needs `--no-sandbox` or a `sandbox-paths` entry binding it: a release archive for Linux carries a static busybox in `libexec/nova-nix/sh`, which `sandbox-paths` names as `/bin/sh` unless an assignment replaces it, as packaged upstream Nix carries its sandbox shell, and a `cabal install` keeps upstream's empty default. BusyBox is GPL-2.0, so each release also carries, beside the archives, the source that busybox was built from, Ubuntu's source package for that version, which the copyright notice beside the binary names. Ubuntu since 24.04 lets an unprivileged process make a user namespace but denies it capabilities there unless an AppArmor profile with a `userns` rule covers the program, so there a build runs unsandboxed unless such a profile names `nova-nix-sandbox`; upstream's root daemon is not restricted that way. A system that cannot make the sandbox builds without it under `sandbox-fallback`, as upstream does, but prints one warning naming the cause, where upstream prints nothing, since nova-nix run by a user other than root falls back on every stock Ubuntu; with `sandbox-fallback = false` the build fails with upstream's `this system does not support the kernel namespaces that are required for sandboxing`. As root a sandboxed build runs as a member of `build-users-group`, as the entry on build users below describes; with `build-users-group` empty it is refused before anything is set up, whatever `sandbox-fallback` says, since the builder would map to root on the host, and `--no-sandbox` builds it unsandboxed. Windows builds are not sandboxed, and `sandbox = true` there falls back the same way. (#673)- **A derivation whose builder is `builtin:buildenv`, the derivation `nix-env` evaluates for a user environment, builds as upstream's does: its output links every package its `derivations` attribute names into one tree, with `manifest.nix` linked to its `manifest`.** Such a derivation reached the path that spawns a builder, which refused it, since its `system` is `builtin`, with `no way to run a builtin builder on this machine`. The tree is upstream's `buildProfile` (builtins/buildenv.cc at 2.35.4), rule for rule. Packages are taken in order of priority, where the lower number wins, then of path, each path once, and each package's `nix-support/propagated-user-env-packages` queues the packages it names, which follow every package given at priority 1000 and up, one number per queued path in path order. An entry is linked where nothing stands. A directory where a link to a directory stands turns the link into a directory of the tree's own, holding what the link led to, resolved through every link, at the link's priority, and then the new entries at theirs; where the link leads to anything else, the build fails with upstream's `collision between ... and non-directory ...`. A file where a link stands replaces it when its priority number is lower, is passed over when it is higher, and when the two are equal fails the build with upstream's `Unable to build profile. There is a conflict for the following files:`, naming both; a file where a directory of the tree's own stands fails with `collision between non-directory ... and directory ...`. Names starting with `.` are skipped, as are `propagated-build-inputs`, `nix-support`, `perllocal.pod`, `log`, `manifest.nix` and `manifest.json` wherever they are and `dir` inside an `info` directory, an entry whose link leads nowhere, with upstream's `skipping dangling symlink` warning, and a package that is not a directory, with `not including ... in the user environment because it's not a directory`. The `derivations` attribute is read as upstream reads it: whitespace-separated tokens, empty ones dropped, in groups of an activity, a priority, an output count and that many paths, where only `false` makes an element inactive and an inactive element's paths are never read. A priority is read as `stoi` reads one, so a float priority, which `buildenv.nix` writes as `5.500000`, reads as 5. Each link names its package as the store spells it on disk: `/nix/store/...` under the default store on Linux and macOS, which are upstream's bytes, `C:\nix\store\...` on Windows, and the store directory `--store` names otherwise. Three things differ from upstream. A directory is read sorted where upstream reads it in `readdir` order, which does not change the tree but can change which pair a failure names when several entries conflict. Every package path, including those a `propagated-user-env-packages` file names, and the manifest must be a store path, in the canonical spelling or the store's own, where upstream's builder reads whatever path it is given; a sandboxed upstream build can read nothing outside its closure either, and nova-nix runs the builtin in its own process, outside any sandbox. And an attribute that ends inside an element, or a priority or count that `stoi` or `stoul` cannot read, fails with a message of nova-nix's own, where upstream reads past the last token or fails with no more than the function's name. On Windows each link is a symlink, which needs Developer Mode or an elevated shell, as a build's `result` link does. (#696)- **On macOS, `sandbox = true` runs a build under a profile of macOS's sandbox, as upstream's does: the build reads its inputs and the paths `sandbox-paths` names, writes only its outputs and its build directory, and reaches the network only when it is fixed-output.** `sandbox` stays off by default on macOS, as upstream's does (the `sandbox` setting in local-settings.hh at 2.36.0). The `nova-nix-sandbox` helper, now built and shipped for macOS too, applies the profile with `sandbox_init_with_parameters` in the builder's own process just before its exec, as upstream 2.36.0 applies its profile in the child it forks for the builder (`DarwinDerivationBuilder::setUser`), and passes upstream's parameters: `_NIX_BUILD_TOP`, the build directory; `_GLOBAL_TMP_DIR`, which is the build directory too (see below); and `_ALLOW_LOCAL_NETWORKING` for a derivation that sets `__darwinAllowLocalNetworking`. The profile is nova-nix's own text, written to the rules of upstream's `sandbox-defaults.sb` and `sandbox-network.sb`: everything is refused unless allowed; the build may write `/tmp` itself and its build directory, start processes and signal its own, read the system's version, time zones and locales, use POSIX semaphores and the standard devices, and it may make no file setuid or setgid; a fixed-output build also reaches the network, resolves names and checks certificates; any other reaches no network, or the loopback alone under `__darwinAllowLocalNetworking`. The build sees its build directory and its outputs where they are on disk, and is told upstream's `HOME`, `/homeless-shelter`. The profile names the store directory and the build directory as the kernel resolves them, since macOS's sandbox matches a file by its resolved path, so a store reached through a link, such as one beneath `/var`, still matches; upstream names its store and build directory as given. Each path is escaped in the profile's strings, as upstream escapes it (`sbplQuote`), and the store paths are grouped by the first character of their hash, each group under a guard of its own, as upstream groups them: macOS compiles the path filters of one operation into one table of at most 64 KiB, however many forms hold them, so a closure of some thousands of paths needs the groups. Where upstream lets a build write its inputs and the paths `sandbox-paths` names, under build users who own none of them, a nova-nix builder that runs as the invoking user owns the store and any file a `sandbox-paths` entry may name, so the build may only read and run them, as the Linux sandbox binds every host path read-only. `sandbox-paths` defaults on macOS to upstream's `/System/Library/Frameworks`, `/System/Library/PrivateFrameworks`, `/bin/sh`, `/bin/bash` and `/usr/lib` (the macOS defaults in globals.cc), and an entry there must name one path on both sides of its `=`, as upstream's must. A derivation's `__impureHostDeps` may each name a path at or beneath an entry of the new `allowed-impure-host-deps`, whose macOS default is upstream's `/System/Library`, `/usr/lib`, `/dev` and `/bin/sh`, and its `__sandboxProfile` ends the profile under `relaxed`, where `sandbox = true` refuses it in upstream's words (`makeDerivationBuilder` in unix-derivation-builder.cc). A `__sandboxProfile` that is not a string, or an `__impureHostDeps` that is not a list of strings, in structured attributes is refused in upstream 2.36.0's words, its JSON type error after `while parsing derivation '...': while parsing attribute "...": `. The new `darwin-log-sandbox-violations` sends what a profile refuses to the system log. A path a build may not do without that is missing fails the build in upstream's words, `getting attributes of required path '`, whose quote upstream's format never closes. A profile macOS refuses fails the build as `while setting up the build environment: failed to configure sandbox`, with upstream's line and macOS's reason in the build log, where upstream reports the end of the builder's pipe while it waits for the build environment, that line among the messages before it. A `sandbox-paths` target that is not absolute is refused, where upstream loops forever. The builder leads a session of its own; an interrupt, the end of nova-nix, or the builder's own end kills every process left in its group before the builder is reaped, as upstream kills the group before it waits. The helper checks once per process that macOS takes a profile from it; where it does not, as for a process already in a sandbox, or where the helper is missing, a sandboxed build fails whatever `sandbox-fallback` says, as upstream reads `sandbox-fallback` on Linux alone (`makeDerivationBuilder`) and fails a macOS build whose sandbox cannot be made, in its words, `while setting up the build environment: failed to configure sandbox`. As root a sandboxed build runs as a member of `build-users-group`, as on Linux. An unsandboxed build on macOS runs under no profile: upstream holds one to a profile that refuses setuid and setgid files (`sandbox-minimal.sb`), and it picks a universal builder's architecture from the derivation's system (`DarwinDerivationBuilder::execBuilder`), neither of which nova-nix does yet. (#725)- **A macOS build reaches none of the invoking user's own files, sockets, terminals or shared memory, and none of its processes outlives it, where upstream's profile assumes a build user of its own.** Upstream runs a macOS build as a build user, who owns nothing beyond the build, and its profile grants what is harmless for that user; nova-nix runs the builder as the invoking user unless it runs as root, so the profile leaves out each grant that would reach that user's own resources, for a build as a build user too. Upstream's `_GLOBAL_TMP_DIR` is the temporary directory Nix runs with, `TMPDIR` or `/tmp`, which the build may write and connect a Unix socket in; nova-nix's is the build's own directory, which the builder's `TMPDIR` names already, so a build reaches none of the user's live sockets and files in the temporary directory; a build as a build user is given upstream's. Upstream's default `sandbox-paths` on macOS also name `/private/tmp` and `/private/var/tmp`; nova-nix's leave them out for the same reason. Upstream allows pseudo-terminals and the terminal devices; nova-nix refuses them and `/dev/console` after every other rule, so `/dev` among a derivation's `__impureHostDeps` reaches none either, since a build that opened one of the user's terminals would read what is typed there and write to it. A build that needs a pseudo-terminal of its own cannot have one. Upstream allows POSIX and System V shared memory and semaphores; nova-nix allows POSIX semaphores alone, which Python's `multiprocessing` takes, since the others would attach the user's own, a PostgreSQL server's System V segment among them. A build that uses System V IPC, PostgreSQL's own tests among them, fails. Upstream ends a build by killing every process of its build user (`UnixDerivationBuilderImpl::killSandbox`, which calls `killUser` in processes.cc); nova-nix's helper, which cannot do that as the invoking user, ends every process that carries the build's mark: a Mach service name, random and made by the helper for that build alone, which the build's profile allows as its last rule, beside a second it refuses. Under `sandbox = true` no other process's sandbox answers the same and the build cannot change the answer; under `relaxed` a derivation's own profile can redefine the forms that state the mark, as `relaxed` already lets a derivation build with no sandbox at all. The helper asks a process about the refused name first, so one that applies a sandbox of its own between the two questions is not taken for the build's. Each time it lists the user's processes it stops every process of the build it finds, those it stopped before included, since one of them may continue another; once a listing finds none new, it kills them, waits for each to end, and lists again, and it reports the build as it ended only when a listing taken after that finds none of the build's left, nor any process that ended before it could be asked. Its listings are bounded, and a build whose processes are still found when they run out, or whose killed processes cannot be watched or do not end in time, fails. It does so after the builder ends and on every way the helper ends: the end of nova-nix, an interrupt, or any terminating signal it can catch, `SIGUSR1` among them. The builder writes its output to a pipe the helper copies into the build log, so the log, and nova-nix's wait for it, ends when the helper does, even when a process of a failed build still holds that pipe; and the helper never blocks on the log, so interrupting a build whose builder writes without pause ends it at once, while a slow or paused reader of the log, such as a pager, never fails a build. So a process of the build that leaves the builder's process group by a session of its own cannot outlive the build and change its output once it is registered, and nova-nix's helper is gone only once the build's processes are, unless it is killed with `SIGKILL`, which no process can catch. A signal the helper inherits ignored, as `SIGHUP` under `nohup`, does not end the build, since the helper runs in nova-nix's process group and upstream's builder, in a session of its own, never sees one sent there. Two exposures remain while the builder runs as the invoking user: a build may create System V shared memory segments and semaphores, which no profile rule refuses, though it can neither use nor remove one, so each outlives the build, counts against the system's limit (`kern.sysv.shmmni` segments) and may hold a key one of the user's programs wants; and a build may read the command lines of the user's other processes (`KERN_PROCARGS2`), which neither `sysctl-read` nor `process-info*` rules reach, where the kernel refuses a build user another user's. A build as a build user cannot read another user's command lines, and the System V objects it leaves are not removed, where upstream removes its build user's. (#725)- **`--keep-failed`, or `-K`, and the `keep-failed` setting keep the directory of a build that fails and name it, and keep the rebuild of an output that `build --check` finds different as `PATH.check`, as upstream's do.** Without them a failed build's directory and a differing rebuild are removed, as before, so neither what made a build fail nor what a check found different could be read. The flags are `nix-build`'s, and `--keep-failed` is also `nix build`'s; nova-nix takes both on every command that builds (`eval`, `build`, `develop`, `print-dev-env` and `profile add`), and like `--fallback` a flag only turns the setting on. A build that does not succeed, one that stops short of registering its outputs, is interrupted, or is a check that finds an output different, keeps its directory under the store's `.nova-nix/builds` and prints upstream's `note: keeping build directory "DIR"` on stderr before its failure is reported. `DIR` is the directory the builder worked in: for a build in the Linux sandbox, the `build` directory inside the build directory, which the builder saw at `sandbox-build-dir`, as upstream names it. The sandbox's chroot is removed whatever the setting says, as upstream's is. A build whose builder is a builtin keeps nothing, as upstream's does, since a builtin's directory may hold privileged files. A build the sandbox refuses is now refused before its directory is made, as upstream refuses one before it makes one. A check that finds an output different moves that output's rebuild, as it was compared, its scratch hashes rewritten and its metadata canonical, to the output's path with `.check` after it, replacing whatever was there, registers nothing, and fails with upstream's `derivation '<drv>' may not be deterministic: output "<path>" differs from "<path>.check"`; only the first output that differs is kept, since the check stops there, as upstream's does. A collection removes a `.check`, which no row registers, even beside a live path, as upstream's removes one unless its path is in use at the time; a kept build directory is under the state directory, which a collection never reads, as upstream's build directories are outside its store. Without `keep-failed` the check's message is upstream's `output "<path>" differs`, its path now in double quotes as upstream quotes it, where nova-nix used single quotes. Three things differ from upstream. A kept directory keeps mode 0700, where upstream opens it with 0755 because its builder ran as a build user whose files the user who asked could not otherwise read; here the builder ran as that user, or as a build user for root, who can read anything. A kept directory stays until the derivation is next built, which removes it as it removes whatever an earlier build left at the name, where upstream's stays until it is removed by hand, since no later build takes its name: the name is the derivation's first output's, so that a rebuild sees the paths the first build saw, and keeping a directory must not move the next check of that derivation somewhere else. And on Windows a failed build's directory is kept too, where upstream's Windows builds remove theirs whatever the setting says. (#733)- **On macOS the sandbox helper reports at most one failure, so a build whose setup step fails names that step even when the helper also lost its watch on the build log, where it was refused as a status that cannot be read.** The builder's process reported a failed setup step on the helper's status channel itself, and the helper, after it reaped that process, wrote a second record when it could no longer watch the log; nova-nix refuses a status of two records as one it cannot read, losing the step that failed. The builder's process now reports on a pipe of its own, which its exec closes, and the helper relays what it says, reporting the lost log only when the builder's process reported nothing. Upstream's builder reports a failed step through the one pipe it reads the builder's setup from. (#739)- **On Linux and macOS a build's `PATH`, unless its derivation sets one, is upstream's `/path-not-set`, so a builder finds no program its derivation does not name, where nova-nix gave it the builder's own directory, that directory's sibling `usr/bin`, `/usr/bin`, `/bin` and `/usr/local/bin`.** Upstream's `initEnv` (unix-derivation-builder.cc at 2.36.0, the same in 2.24.9 and 2.34.9) sets `PATH` to `/path-not-set` before the derivation's own variables, a value naming no directory, so that a shell does not fall back to a search path of its own as it would were `PATH` unset; a derivation reaches a program on the host only by naming it, and nova-nix's builds reached the host's tools unasked, so a derivation that built here could fail upstream. Windows keeps the builder's directory, its sibling `usr\bin` and the system's directories, which `cmd.exe` and a job's environment need; upstream's Windows builder passes on the `PATH` it was started with. (#737)- **On Windows a builder named relative to the working directory, such as `./tools/bash` or `tools/bash`, puts none of its directories on the build's `PATH`, as a bare name or `./bash` already put none.** The build's working directory is its build directory, so `./tools` on `PATH` would let a file the build writes there resolve ahead of every tool; only a builder whose directory is absolute, or rooted on the working directory's drive, adds its directory and that directory's sibling `usr\bin`. (#737)- **`nova-nix-sandbox` builds on Windows, with a backend that runs a builder as the build slot's account whose token it is handed: on the window station of that token's logon, with its image opened as the slot, attached to a pseudoconsole the helper owns, in a job that caps each process's memory and lets none of them break away, and with every process of the slot's account ended before the build and after it. Windows builds do not run through it yet, and run as before.** Upstream's builds run as `nixbld` users, and upstream ends every process of its build user before and after each build. On Windows a build account's token is held by the service that logs each slot on and starts the helper, which hands it one slot's token as a handle the plan names, with the slot's SID, and the helper refuses a token that is not a primary token of that account. The builder starts with no window station named, which puts it on the station Windows makes for the slot's logon, since a service running as a virtual account cannot make one and its own is not the slot's to open. CreateProcessAsUserW opens a builder's image with its caller's access, so the helper starts the builder impersonating the slot, and refuses a builder the slot may not read. A process started with a console of its own, as libiberty starts gcc's subprograms when gcc has none, fails to start under a build account's token, where one sharing its parent's console starts, so the builder is attached to a pseudoconsole the helper owns and drains; the build log stays the builder's standard output and error, and its standard input is NUL. The builder starts suspended and joins the build's job before it runs; the job kills its processes when the helper's handle to it closes, however the helper ends, ends a process at an unhandled exception at once, and nests in the process library's job. A process a build has WMI start runs outside the job and outlives it, holding what it copied from the build, the build log among them, so the helper ends every process running as the slot's account before the builder starts and once the job holds no process, listing them again until a listing finds none; a sweep that fails before the build is reported on the status channel, and one that fails after it is said in the build log and fails the build. The helper exits with the builder's exit code once the job holds no process and the sweep is done, ends the job when its lifeline closes, says in the build log which process the memory cap stopped, and reports a step that fails before the builder starts on its status channel, with the Win32 error of the call that failed. Its probe checks that it can enable `SeAssignPrimaryTokenPrivilege` and `SeIncreaseQuotaPrivilege`, which starting a process as another account takes. (#743)- **builtin:unpack closes an archive once it has read it, where an unpack stopped partway through, by its budget or a refused entry, left the archive open until a garbage collection.** The archive was read lazily, so its handle stayed open until the rest of it was read, which an unpack that stops never does, or until a collection finalized it; on Windows an open file cannot be deleted, so the archive's store path could not be removed in the meantime by the process that unpacked it. The archive is now read whole and its file closed before it is decompressed and decoded. (#771)- **As root on Linux and macOS, a build runs as a member of `build-users-group`, `nixbld` by default, as upstream's does, so a builder can change neither the store nor another build, and no process it leaves outlives it.** A sandboxed build as root, which nova-nix refused for want of build users, now runs as one; it is refused only with `build-users-group` empty, under which an unsandboxed build runs as root. Each build takes the first member, in the group's order, whose lock file in upstream's user pool, `/nix/var/nix/userpool` or `$NIX_STATE_DIR/userpool`, is free, locked with `flock` as upstream's are, so a build of nova-nix's and one of an upstream daemon's on the same machine never share a user. While every member is taken the build waits, saying `waiting for a free build user ID for '<drv>'` once, and looks again every five seconds, upstream's default `poll-interval`. A group that is missing or has no members, a member that names no user, and a member that is the user nova-nix runs as fail the build in upstream's words. Every process of the member is killed before the build and once its builder ends, before any output is read. The store directory is made root's and the group's with mode 1775, as upstream's store open makes it; the directory the builder works in and the files nova-nix writes there are the member's; and a build is refused when the directory holding build directories, or one above it, is one every user may write, with upstream's `is world-writable or a symlink`. In the Linux sandbox the namespace's uid 1000 and gid 100 map to the member and the group, and the chroot's root and store directory are the group's, as upstream's are. Outside the sandbox, and in macOS's, the builder takes the member's uid, the group and, on Linux, the member's other groups, as upstream keeps them for a group such as `kvm`, set between the fork and the exec by a small C shim, since the process library can drop to another user only by looking it up in the forked child of a threaded process; the groups are looked up beforehand instead. A macOS build as a member is given upstream's temporary directory, `TMPDIR` or `/tmp`, in its profile, where a build as the invoking user keeps its own. An output whose root is not the member's is refused with upstream's `suspicious ownership or permission`, and one holding a node another user owns with `invalid ownership on file`, before it is made canonical; a passing output is made root's and read-only. A builtin builder still runs in nova-nix's own process, as root, where upstream runs it in the build's child as the member. The System V IPC objects upstream removes for a macOS build user are not removed, and `auto-allocate-uids` is not read. (#770)- **A Windows builder's process that meets an unhandled exception ends at once with the exception's code, and Windows Error Reporting no longer starts WerFault.exe from inside the build.** A configure test that divides by zero, as gettext's check for SIGFPE does, had the reporter start, a program from outside the store that can wait on a dialog. The job each unsandboxed builder runs in now has `JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION`, as the sandbox helper's job has, the counterpart of upstream having a crashing builder dump no core. The limit is the job's, so it holds for a process that sets its own error mode, as busybox-w32 does. The `process` floor rises to 1.6.8, the first release whose process handle holds the process and its job alone, the job the limit is set through. (#777)- **`builtin:fetchurl` with `unpack` reads a NAR body only to the archive's end, as upstream does, so bytes a server sends after the archive are left unread rather than failing the fetch.** Upstream's builtin restores the download through `parseDump` (fetchurl.cc and archive.cc at 2.36.0), which stops at the root node's close and never reads what follows, so the output is the archive and its hash the archive's. nova-nix parsed the body as an archive that must end with it, and failed a body with any byte after the root node as a malformed NAR. (#761)- **On Linux and macOS an unsandboxed builder that runs as the user nova-nix runs as starts and ends as upstream's child does: in a session of its own, with `/dev/null` open to read and write as its standard input, every other descriptor closed, upstream's core limit and its program's base name as its first argument, and with every process left in its process group sent SIGKILL once its log ends, or when the build is interrupted.** It started through the process library, which left it nova-nix's controlling terminal, its core limit and its descriptors, and an interrupt sent SIGTERM to the builder alone, so what the builder had started ran on after the build. Upstream's child makes a session of its own, reroutes standard input to `/dev/null`, and sets a soft core limit of 0 with no hard limit, a call a process that is not root is refused where its hard limit is finite, which keeps its soft limit; upstream takes the builder's status by killing its process group, so a builder that closes its log but keeps running now fails on signal 9, as upstream's does, and a build user's builder ends the same way. The builder is executed by its path, with no search of `PATH`; one that cannot be executed fails with exit code 1, with why as the build log's last line, as upstream's child writes it. A failed kill of the group is logged and the builder's own status kept, as upstream's is. (#778)- **`builtin:unpack` leaves out the archive members its derivation's `omit` names, each by its path from the archive's root.** stage0-pe32's tree is unpacked before any tool exists, so the builtin is what removes the file there. A path that no archive in `srcs` holds fails the build, as does one that leaves the archive or names its root. (#762)### Substitution- **A build no longer substitutes the outputs of a derivation whose `allowSubstitutes` attribute is false: it builds them, as upstream does, unless `always-allow-substitutes` is on in nix.conf or `NIX_CONFIG`.** nova-nix did not read the attribute, so such a derivation came from a cache whenever one held its outputs. nixpkgs sets it on the builds that cost less to run than to download, `runCommandLocal` and `writeTextFile` among them. Upstream reads the attribute in `ParsedDerivation::substitutesAllowed` (parsed-derivations.cc at 2.24.9) and starts no substitution for a derivation that forbids it (`DerivationGoal::haveDerivation`), going on to its inputs, which are substituted or built as any other derivation's are. A derivation without the attribute may be substituted. In a derivation's environment only `1` allows it, which is how evaluation writes `true`; with structured attributes it is a JSON Boolean, and any other value there stops the build with upstream's message, `attribute 'allowSubstitutes' of derivation '<hash>-<name>.drv' must be a Boolean`. The rule covers what a derivation's own goal does: a path that another substituted output references still comes from the cache, since upstream's `PathSubstitutionGoal` never reads the attribute. `always-allow-substitutes` lets every derivation be substituted and leaves the attribute unread, as upstream's setting does. Structured attributes that are not JSON now stop the build before the derivation's outputs are looked at, with `cannot process __json attribute of '<hash>-<name>.drv'`, as upstream's `ParsedDerivation` constructor stops it; nova-nix raised that only when it came to build the derivation, and named it by its `name`. Upstream also derives the flags `--always-allow-substitutes` and `--no-always-allow-substitutes` from the setting, which nova-nix does not. (#421)- **A build realises each input for the outputs its dependent's `.drv` names, so a dependency on one output of a derivation fetches that output and its closure, and an output nothing asks for no longer makes the derivation build.** The dependency graph kept each input's `.drv` path and dropped the output names, and each derivation was checked and substituted for every output it has, so a dependency on `openssl.drv!dev` needed every output of openssl, and one of them missing from every cache rebuilt openssl and what it is built from. Upstream's goal for an input wants the outputs the dependent's `.drv` names (`DerivationGoal::gaveUpOnSubstitution`, derivation-goal.cc at 2.24.9), is valid once those are (`checkPathValidity`) and substitutes those alone (`haveDerivation`); a build makes every output. nova-nix now does the same. A derivation asked later for an output it has not realised, as when one dependent wants its `dev` and another its `out`, is realised again for that output, from a cache or by a build, as upstream's worker drops a goal once it is done (`Goal::amDone`, goal.cc, and `Worker::removeGoal`, worker.cc) and starts a new one for the next request (`Worker::makeDerivationGoalCommon`, worker.cc at 2.24.9). An input asked for an output it does not have, which `builtins.appendContext` can name, fails the build with upstream's `derivation '<drv>' does not have wanted outputs '<name>'` (`DerivationGoal::checkPathValidity` in derivation-goal.cc) before anything is fetched for it, where the build of its dependent refused it after the input was realised. The derivation a build is given is realised for the one output the expression selects, as `nix-build` asks for it (`main_nix_build` in nix-build.cc). Under the output locks a build still adopts a derivation another process finished only when every output is valid, where upstream adopts it once the wanted ones are (`DerivationGoal::tryToBuild` in derivation-goal.cc at 2.24.9). (#503)- **A build asks each cache for a path's narinfo once, and takes the path's NAR from the cache whose narinfo gave the references it realised first, as upstream does.** A substitution read each path's narinfo to learn its references, then read it again before fetching the NAR, so a closure of N paths cost 2N narinfo requests, and a path no cache holds was asked about again each time a derivation that references it was tried, after its inputs as well as before. The second read could also reach another cache: when the first stopped serving the narinfo or no longer held the NAR, the NAR came from the next cache with that cache's references, which nothing had realised, the store refused the registration, and the build stopped or fell back to building. Upstream's substitution goal queries one substituter's path info, realises the references it declares, and copies the path from that same substituter, and the store's path-info cache answers every later query for the path, one for a path the substituter lacks included (`PathSubstitutionGoal::init` and `tryToRun` in substitution-goal.cc, `Store::queryPathInfo` in store-api.cc at 2.24.9). nova-nix now fetches a path with the narinfo its references came from and remembers what each cache said about each path for the rest of the build, so each narinfo is requested once; a query that failed is not remembered, as upstream caches no failure. A path whose NAR a cache fails to deliver, or no longer holds, goes to the caches after it, as upstream's goal goes to its next substituter: the next cache that serves the path has the references it declares realised first, and the path comes from it. Each output a build wants of a derivation runs its own course, as each of upstream's goals does: once one has no cache left, the others are still fetched from the caches that offer them, registering nothing, and the substitution has failed only when an output ran out of caches after one failed to deliver it, which is when upstream stops the derivation (`DerivationGoal::outputsSubstitutionTried`, derivation-goal.cc at 2.24.9, `DerivationGoal::haveDerivation` at 2.36.0); otherwise the derivation builds. When the outputs wanted of one derivation arrive together and one of them comes from a later cache, the others are fetched again, since none was registered, where upstream registers each output as it arrives. Upstream's cache also expires an entry, after an hour for a path a substituter lacks and a month for one it holds (`narinfo-cache-negative-ttl`, `narinfo-cache-positive-ttl`), and keeps it on disk across runs; nova-nix remembers for one build, or one substitution of a `nova-nix trust` input, and writes nothing to disk. (#518)- **A substitute whose NAR file is larger than its narinfo's FileSize is downloaded, as upstream downloads it, where the substituter stopped with `NAR body exceeds its download ceiling`.** The download cap was the smaller of a ceiling derived from the signed NarSize and the narinfo's FileSize, which no signature covers. cache.nixos.org names its zstd NARs by their NarHash, so every store path with the same NAR shares one file, and an upload that compresses that NAR again replaces the file whose FileSize and FileHash an earlier narinfo records. In the closure of the x86_64-linux stdenv of nixpkgs 26.05, `/nix/store/s52vdyj97g3adv6qb431v8m2kccs0bzz-linux-headers-6.18.7` declares a FileSize of 1891795 bytes, while the file its URL serves is 1891934 bytes and decompresses to the NAR its signed NarHash and NarSize name, so a build that substituted that stdenv failed. Upstream reads FileSize only for progress and download statistics (`build/substitution-goal.cc` and `misc.cc` at 2.35.4, `build/substitution-goal.cc` and `store-api.cc` at 2.24.9), never compares a download with FileHash, and checks a substituted NAR against NarHash and NarSize alone (`local-store.cc`). The cap is now the ceiling of the signed NarSize, which is NarSize plus the larger of 64 KiB and a 64th of NarSize, so a narinfo whose signature verifies still cannot buy a larger download, and a body past that ceiling still fails at once, without a retry. FileSize is still parsed and validated as before. (#693)- **A substituted path whose narinfo states a content address is held to it, as upstream holds one: once its NAR's hash and size are checked, the tree is hashed as the address's method reads it, modulo the path's hash part, and a tree that hashes otherwise is removed and refused with upstream's `ca hash mismatch importing path '...'`, both hashes after it.** nova-nix checked a substitute against its narinfo's NarHash and NarSize alone. Upstream's `LocalStore::addToStore` (local-store.cc, the same at 2.24.9, 2.34.9 and 2.36.0) also checks a narinfo's `CA`: a `fixed:r:` address is of the tree's NAR, and a `fixed:` or `text:` address of the bytes of the one file it names, each hashed under the address's algorithm with every occurrence of the path's hash part counted as zeros and the offset of each appended, so a tree that refers to itself does not hash as one with zeros in its place. A narinfo that states no address is still held to its NarHash alone, as upstream's is, so a fixed output a cache supplies without one is not held to its recipe's hash, and `trust`'s reference now says so. (#738)- **A narinfo whose StorePath has the requested path's hash and another name is passed over, as upstream passes one over, where nova-nix took it for the requested path.** Upstream's `Store::queryPathInfo` (store-api.cc, the same at 2.24.9, 2.34.9 and 2.36.0) holds the path a narinfo names to the requested one by `goodStorePath`, which compares the name as well as the hash, and moves on to the next substituter when they differ; nova-nix compared the hash alone. (#739)- **A `file://` URL in `substituters` or `--substituter` names a binary cache in a directory, and a build substitutes from it as upstream substitutes from its local binary cache store, so a cache `push` writes to a drive can be carried to another machine and read there with no web server (`file:///D:/cache` on Windows).** The substituter read only HTTP: it handed every URL to its HTTP client, so a `file://` one failed every query. A directory cache's narinfos and NARs now go through the steps an HTTP cache's do: a narinfo must name the path and be signed by a trusted key, unless its content address makes its path or `require-sigs` is off, the NAR is decompressed by the narinfo's `Compression` and held to its `NarHash`, `NarSize` and content address, and caches are asked in priority order. A narinfo the directory lacks is a miss and a NAR it lacks is a substitute gone, as a 404 is for an HTTP cache; a file that cannot be read fails, and is not retried, since upstream retries downloads alone. A narinfo `URL` that is empty, absolute or holds a `.` or `..` segment is refused in upstream's words (`local binary cache path '../x.nar' must not contain '..' or '.' segments`), so a narinfo cannot name a file outside the cache. The first query of a run opens each `file://` cache as upstream's store opens one: it makes the `nar`, `build-trace-v2` and `log` directories, writes a `nix-cache-info` holding `StoreDir: /nix/store` where there is none, and reads the one there. A cache whose `StoreDir` is another store directory is passed over for the run after upstream's warning, `binary cache 'file:///D:/cache' is for Nix stores with prefix '/gnu/store', not '/nix/store'`, as upstream drops a substituter it cannot open, and so is one whose URL `push` would refuse or whose directory cannot be made or read. The cache is asked at the `Priority` its `nix-cache-info` states, or at upstream's default of 0 when it states none, as a `push` writes it, so such a cache comes before the HTTP caches, which nova-nix asks at 50. A `Priority` that is not a 32-bit integer fails the query whatever `fallback` says, as it fails upstream's command, in nova-nix's words, since upstream's are the C++ library's. `WantMassQuery` is not read: it governs only queries about many paths at once, which nova-nix does not make. The URL is read as `push` reads one: an empty host and an absolute path, with no query, fragment or percent-escape, where upstream would read a query such as `?priority=10` as the store's settings. An HTTP cache's `nix-cache-info` is still not read, so its priority is the configured one and its `StoreDir` is not checked: with `substituters = https://cache.nixos.org file:///D:/cache` and `Priority: 45` in the directory's `nix-cache-info`, nova-nix asks the directory first, where upstream asks cache.nixos.org, whose file states 40. A substitution makes only the directories the newest upstream release makes, so it opens a cache that release wrote, which lacks `realisations`, from a drive it cannot write to; a push makes `realisations` as well, for a reader of an older release. Each `file://` cache is opened once a run, where upstream opens it once a process, so `trust`, which makes a run for each fixed-output input, warns of a cache it passes over once for each. (#745)- **`push` names a cache on Windows as upstream does, `file:///D:/cache`, in its refusal of a `nix-cache-info` for another store directory, names the cache when its directory cannot be made or read, and refuses a `nix-cache-info` whose `Priority` is not a 32-bit integer.** The refusal joined `file://` to the directory, which gave `file://D:/cache`. A push opens the directory as a substitution does, and upstream's `nix copy --to file://` fails on such a `Priority` as its substitution does. (#745)- **A substituter listed twice, in `substituters`, `extra-substituters` or again with `--substituter`, is asked once, at its first listing, as upstream drops a substituter it already has.** Every listing was kept, so a cache listed twice was asked again for a path whose NAR it had failed to deliver or no longer held, and a narinfo it served that was passed over was reported twice. Two listings are one when they are spelled alike. Upstream compares them once parsed, so spellings that differ only in percent-escapes, the order of a query's parameters, a fragment or a port's leading zeros are one substituter there and two here, while a spelling with a trailing slash and one without are two in both. The library's `containers` floor rises to 0.6.0.1, the first with `nubOrd`. (#766)- **A substitution reads a cache's NAR only to the archive's end, as upstream does, so a NAR followed by bytes the archive does not hold substitutes as the archive, held to the narinfo's NarHash and NarSize over the archive's bytes alone.** Upstream substitutes a path by importing the NAR it reads from the cache through `restorePath` (`LocalStore::addToStore` in local-store.cc at 2.36.0), whose `parseDump` stops at the root node's close and never reads what follows, and it checks the NarHash and NarSize against the bytes read to there. nova-nix parsed the download as an archive that must end with it, so such a NAR failed as malformed and the attempt was retried. (#763)- **A substituted NAR whose hash or size is not its narinfo's is refused as upstream refuses it, the hash checked before the size and each in upstream's words: `hash mismatch importing path '<path>';` with the specified and got hashes in SRI form on the lines after, or `size mismatch importing path '<path>';` with the two sizes.** nova-nix checked the size first and worded both its own way, as `NAR size mismatch: narinfo declares <n> bytes but the stream carried <m>` and `NAR hash mismatch: narinfo declares <hash> but downloaded bytes hash to <hash>`. Upstream's `LocalStore::addToStore` (local-store.cc at 2.36.0) checks the hash of the bytes it restored, then their count, and words both so. The streamed and the whole-NAR substitution and the daemon's import of a NAR now share the one check. (#768)- **nix.conf's `require-sigs` and `secret-key-files` decide what a substituted path must be signed by, as upstream's do, and a narinfo whose content address makes its path is substituted unsigned.** nova-nix read neither setting and asked every narinfo for a signature by a key in `trusted-public-keys`. Now `require-sigs = false` takes a narinfo unsigned, and the public key of the secret key in each file `secret-key-files` names is trusted beside `trusted-public-keys`: a file that cannot be read is passed over, as upstream passes over one a user of a multi-user installation cannot read, and one that holds no secret key, like a `trusted-public-keys` entry that does not read, ends the substitution in upstream's words ("key is corrupt", "secret key is not valid") whatever `fallback` says, as upstream decides trust outside the try that makes a failed query its cache's, so a later cache is not asked and nothing is built from source. Of keys that share a name only the first is trusted, as upstream keeps one key a name. A narinfo whose content address and references make its path needs no signature, as upstream's store counts such a path as signed, and its tree is held to that address once it is fetched. One whose address makes another path is warned of at upstream's error level, "warning: path '...' claims to be content-addressed but isn't", and needs a signature. Once a signature, or `require-sigs = false`, has it fetched, it is refused where upstream refuses to register it, with "cannot add path '...' to the Nix store because it claims to be content-addressed but isn't", and nothing is registered. One whose address makes no path, a fixed address other than a NAR's SHA-256 stated with references, ends the substitution in the same way, in upstream's words. A narinfo no trusted key signed is passed over with upstream's warning, "ignoring substitute for '...' from '...', as it's not signed by any of the keys in 'trusted-public-keys'", where nova-nix logged a line of its own. Upstream also signs each path it builds with the keys in `secret-key-files`, and nova-nix does not. (#800)### Windows packages- **The Mes C library compiles with a PE-targeting TinyCC against TinyCC's own `stddef.h` and `stdarg.h`, as `tinycc-boot-mes` compiles it.** Its `wchar_t` is the compiler's `__WCHAR_TYPE__` where the compiler names one, `unsigned short` for a TinyCC that writes PE, where Mes defined `int` whatever the compiler, and a PE TinyCC refused the second, incompatible definition. Its `vfprintf` and `vsnprintf` read a double with `va_arg` when compiled against a `stdarg.h` without Mes's `va_arg8`, where they stopped at `va_arg8`; nixpkgs replaces `va_arg8` with `va_arg` outright, which Mes's own `stdarg.h` defines as reading a long. MesCC names no `__WCHAR_TYPE__` and reads Mes's own `stdarg.h`, so it compiles the same declarations as before. (#401)- **`pkgs/windows` builds TinyCC's first round on the Mes rung: `tinycc.boot-mes.compiler`, janneke's bootstrappable TinyCC compiled by MesCC into a tcc that writes PE32, and `tinycc.boot-mes.libs`, the Mes C library and TinyCC's runtime compiled by that tcc.** They are nixpkgs' `minimal-bootstrap/tinycc` `tinycc-boot-mes` derivations, each an `i686-windows` `kaem.runCommand` script, from janneke's fork at ea3900f, the commit nixpkgs pins. Four things differ from nixpkgs. tcc is built with `TCC_TARGET_PE`, so it writes PE32 from this round on: it is the one tcc in the chain MesCC links, so a tcc that wrote ELF here would leave every later round with nothing Windows runs. tcc has no include directory built in, and every derivation that runs it names the headers in `C_INCLUDE_PATH`, which tcc reads at startup, where nixpkgs writes them into tcc as a C string: the builder spells a store path `C:\nix\store/...`, and the backslash would start an escape. The library holds `crt1.o` alone of the startup files, since lib/windows has `crt1.c` alone. And nixpkgs' three edits to `x86_64-gen.c` and its PLT relocation in `tccelf.c`, which do not reach an i386 tcc, are not made. `mes.libc` now carries nixpkgs' `CFLAGS`, `-std=c11`, and `mes.baseAddress` is exported, the ImageBase MesCC links tcc at. CI builds it from the seed on x64 and ARM64 Windows, runs the tcc with `-version`, and runs a program it compiled and linked with no import table, checking what it prints and the status it exits with. (#401)- **`pkgs/windows` builds TinyCC's bootstrappable rounds on the Mes rung: `tinycc.boot0` to `tinycc.boot3` and `tinycc.bootstrappable`, each tcc compiled by the round before it and each compiling the Mes C library the next links with.** They are nixpkgs' `minimal-bootstrap/tinycc` rounds with the options janneke's `boot.sh` gives each, the last repeating boot3's so that its floating point is compiled by a tcc that has it. Four things differ from nixpkgs besides the first round's changes for PE. tcc.c is compiled with `_WIN32` undefined and `__windows__` defined: a PE tcc predefines `_WIN32`, which tcc.c reads as a host with the Win32 API and answers by including `windows.h`, where these tccs run on Mes libc as `tinycc-boot-mes` does, and `__windows__` tells Mes's `fcntl.h` the system in its place. Each round names `crt1.o`, libc and libtcc1 when it links, since a PE tcc adds no startup file or C library of its own and links msvcrt and kernel32 unless told `-nostdlib`. Each round's `tcc.exe` is marked executable by its script, since tcc's PE writer marks nothing. And each round compiles without nixpkgs' `-g`: tcc's debugging information names the directory tcc ran in and each file by the path it opened, a source or header from the store by the store's physical path, so a `tcc.exe` that carried it would differ with the store's drive and with the user whose temporary directory the build ran in, where nixpkgs' builds see one store path and, sandboxed, one build directory. CI builds every round from the seed on x64 and ARM64, runs the last with `-version`, and runs a hello and a program printing the two words of a double it computes, both compiled and linked by the last, checking what each prints and the status it exits with, and checks that no round's `tcc.exe` names the store directory or its own build directory. `printf`'s `%f` is no check at these rounds: Mes's `dtoab` casts the double to `long`, which this tcc compiles as a call to `__fixdfdi`, and Mes's `libtcc1.c`, which nixpkgs copies over TinyCC's for the rounds, stubs it to 0. (#401)- **`pkgs/windows` builds TinyCC's own source on the Mes rung: `tinycc-mes.prev`, TinyCC at cb41cbfe compiled by `tinycc.bootstrappable`, and `tinycc-mes`, the same source compiled by that, each with the Mes C library and TinyCC's runtime its tcc compiles.** They are nixpkgs' `minimal-bootstrap/tinycc` `tinycc-mes-boot` and `tinycc-mes` derivations, each an `i686-windows` `kaem.runCommand` script, with two of nixpkgs' three edits to the source and its `tccdefs`, tcc's predefined macros compiled into it from `include/tccdefs.h` by `conftest.c`. The archive is TinyCC's GitHub mirror's of that commit, the tree nixpkgs takes from repo.or.cz, whose snapshot does not reach every client as the same gzip stream. Three things differ from nixpkgs besides the changes the rounds before share. nixpkgs' third edit sets `static_link` in every compile, so that an ELF link writes a static executable; a PE tcc reads the flag only where it resolves `-l`, which it then keeps from finding a `.def` import library, so the edit is left out. `tcc.h` keys `PATHSEP`, which splits `C_INCLUDE_PATH`, `-I` and `-L`, on `_WIN32`, the host's macro, where janneke's keys it on `TCC_TARGET_PE`; every round compiles `tcc.c` with `_WIN32` undefined, so a third edit makes it `;`, since an unedited tcc would split a store path at its drive's colon. And `c2str`, which writes `tccdefs_.h`, is linked as every program of a PE round is, with `-nostdlib`, `crt1.o`, libc and libtcc1, where nixpkgs' bare link would pull in msvcrt and kernel32. Each round now carries the `C_INCLUDE_PATH` a script that runs its tcc sets, and a script sets that of the tcc it runs: `tinycc-mes.prev`'s tcc is compiled with janneke's headers and its library with TinyCC's. CI builds both rounds from the seed on x64 and ARM64, runs the last with `-version`, and runs a hello, the double's two words, and a double printed through `printf`'s `%f`, whose cast to `long` this round's libtcc1 has where Mes's stubs it, each compiled and linked by the last, checking what each prints and the status it exits with. (#403)- **`pkgs/windows` builds TinyCC as a native Windows compiler: `tinycc-native.prev`, TinyCC's own source compiled by `tinycc-mes` with `_WIN32` defined, against TinyCC's `win32/` headers, and `tinycc-native`, the same source compiled by that, each linked against msvcrt.dll and kernel32.dll through the import tables tcc writes from TinyCC's `.def` files.** It is compiled with upstream's `win32/build-tcc.bat` defines, `-DTCC_TARGET_PE -DTCC_TARGET_I386`, as one executable, and each round compiles the thirteen objects `build-tcc.bat` archives as `libtcc1.a` and copies its five import libraries for the next; nothing it builds links Mes. `build-tcc.bat`'s `runmain.o`, `bcheck.o` and `bt-*.o` are not built, so `-run`, `-b` and `-bt` are not available. Where upstream's `tcc.exe` finds `include` and `lib` beside itself, `tinycc-native` reads its headers from `C_INCLUDE_PATH` and its runtime from `-B`, as the rounds before it do, since a store path, spelled with a backslash, cannot be a C string. It predefines `__MINGW32__`, as MinGW's GCC does and TinyCC does nowhere, through `CONFIG_TCC_SWITCHES`, which upstream's `configure --tcc-switches` sets, since Windows sources such as busybox-w32 choose their Windows code by it. A tcc compiled with `_WIN32` adds the Windows system directory to its library paths, so the import libraries it links by default, msvcrt's and kernel32's among them, are read from the DLLs there when the directory a script names lacks their `.def` files; an edit to the TinyCC source removes that call, and such a link fails. `-lkernel32`, `-lws2_32` and the like find their `.def` files in the `-B` directory, as upstream's do, since the source leaves out nixpkgs' edit that makes every link static, which would keep `-l` from finding them. It is built without `-g`, as `build-tcc.bat` builds it, since the debug information names the build directory. CI builds both on x64 and ARM64, checks that `tinycc-native`'s `tcc.exe` is the same bytes as the one `tinycc-mes` compiled, that it searches the `-B` directory alone and predefines `__MINGW32__`, and runs a hello, the double's two words, a double printed through `printf`'s `%f`, and a program linked with `-lws2_32` that calls ws2_32.dll's `htons`, each linked against msvcrt and ending its lines in a carriage return, as msvcrt's text-mode stdout writes them. (#404)- **`pkgs/windows` builds GNU make 4.4.1 with `tinycc-native`, from make's Windows sources as its `build_w32.bat` compiles them with tcc, in one `i686-windows` `kaem.runCommand` script with no configure and no shell.** It follows nixpkgs' `minimal-bootstrap/gnumake`, which also builds make with tinycc and without configure. make's Windows configuration reads `__MINGW32__` as MinGW's headers being present and turns on headers TinyCC's do not have, so make compiles against TinyCC's own headers, as `build_w32.bat`'s tcc mode does, with `tinycc-native`'s predefined `__MINGW32__` undefined. As in nixpkgs, the directories make searches for an included makefile and for `-l` drop `/usr/gnu/include`, `/usr/local/include`, `/usr/include`, `/lib` and `/usr/lib`, which on Windows resolve against the current drive's root. The link takes `-luser32` and a one-name advapi32 import library, since TinyCC ships no advapi32 `.def`. A make compiled by tcc runs each recipe that needs a shell from a batch file, through `cmd.exe` unless an `sh.exe` is on `PATH`. CI builds it on x64 and ARM64, checks `make --version`, and has make build a target through a pattern rule whose recipe runs mescc-tools-extra's `cp` by its path, which make starts itself, without a shell. (#407)- **`pkgs/windows` builds busybox-w32 FRP-6354-g5f09fb446 with `tinycc-native`, as upstream's `mingw32_defconfig` build, in one `i686-windows` `kaem.runCommand` script with no shell: the shell and tools the native rungs run configure under.** Upstream compiles busybox-w32 against MinGW-w64's headers and links MinGW-w64's runtime; this compiles it against TinyCC's own headers, with a compatibility layer of the MinGW-w64 declarations busybox-w32 reads and TinyCC's headers lack, and links five mingw-w64-crt v14.0.0 sources for the functions msvcrt.dll lacks. The headers upstream's build generates are written as it writes them: kconfig's `conf`, `applet_tables` and `usage` are compiled and run, and the shell scripts `scripts/gen_build_files.sh` and `applets/usage_compressed` are C programs in the package. Three settings differ from `mingw32_defconfig`, each for something this toolchain lacks: usage text is stored unpacked, since packing it takes bzip2 at build time; the executable carries no version information, manifest or icon, which take a resource compiler; and busybox does not expand wildcards in its own arguments, which MinGW-w64's startup code does and TinyCC's does not, so `busybox --help` reports noglob. Seven edits to the source, as well as those to the configuration, are each checked against the edited file's SHA-256, since `replace` leaves a file unchanged when its match is missing. Three are for what TinyCC does not compile as GCC does: a string literal in parentheses as an array initializer, `bswapl`, which TinyCC's assembler knows as `bswap`, and a call, in code no configuration without Unicode reaches, to a function such a configuration does not define, which TinyCC compiles where GCC drops it. Three supply what upstream's toolchain would: `dirname`, which busybox-w32 carries for newer MinGW-w64 runtimes; `ffs`, a GCC builtin; and the binary file mode MinGW-w64's startup code sets. The seventh keeps `printf`'s exit status 0 for an argument of 128 bytes or more: busybox-w32 formats each directive through msvcrt.dll's `_vsnprintf`, which sets `errno` to `ERANGE` when the output fills or overflows the 128-byte buffer libbb's `vasprintf` tries first, and `printf` takes the `errno` its directives leave for a conversion error, so it wrote such an argument whole and exited 1. GMP 6.2.1's `configure`, whose last command writes a summary that long, failed for it once it had configured. `time_t` is 32 bits, as TinyCC's headers define it for i386; the stack reserve is upstream's 2 MiB; and `busybox.exe` needs the msvcrt.dll of Windows Vista or later, where upstream's i686 build takes `_chsize_s`, `_set_fmode`, `getenv_s` and `strnlen` from MinGW-w64's runtime on older ones. CI builds it on x64 and ARM64, checks `busybox --version`, and has busybox's sh run a script through `sh`, `sed`, `grep`, `awk`, `expr`, `tr`, `cat`, `mkdir`, `rm`, `cp`, `mv`, `test` and `printf`, one of a 200-byte argument among them, checking each line it writes. (#409)- **`pkgs/windows` has `seedStdenv`, a stdenv made only of tools built from stage0-pe32's seed, with busybox-w32's sh as the builder and its applets as the coreutils, sed, grep and awk, `gnumake` as make, and `tinycc-native`, on msvcrt.dll, as the C compiler and linker, so no MSYS2 or MinGW-w64 package is in the closure of anything it builds.** Its `mkDerivation` takes the attributes the MSYS2 stdenv took and runs the same phases from a `setup.sh` written for POSIX sh, and `pkgs/windows`' GNU Hello package builds with it unchanged. busybox-w32's applets are commands of their own through a launcher beside a copy of `busybox.exe`, as w64devkit installs them, since GNU make runs a recipe line with no shell syntax itself and `busybox --install`'s hard links would each be a copy in a NAR. Every path the stdenv passes on is respelled with forward slashes, since the builder spells the store `C:\nix\store` and a backslash is an escape in the sed scripts and C strings configure writes. The environment gives configure the two things it cannot detect about `PATH`, where every configure reads them whatever site file it is given, GCC's top level among them, which runs the configure of each directory it builds for the build machine, and of each target library, with `CONFIG_SITE=no-such-file`: `PATH_SEPARATOR=';'`, since busybox's sh runs its own `sh` applet whatever `PATH` holds, and `ac_executable_extensions=.exe`, since busybox's `test -x` does not add the suffix. configure is told `--build=i686-pc-mingw32`, since `config.guess` cannot read busybox's `uname`; `LD` is tcc, as nixpkgs' minimal-bootstrap sets it, since the iconv and gettext checks fail with no `ld`; and `BB_OVERRIDE_APPLETS=make` keeps busybox's own make from shadowing GNU make. TinyCC's headers gain MinGW-w64's `sdkddkver.h`, without which gnulib calls Vista's `GetFinalPathNameByHandle`, which they do not declare. The MSYS2 stdenv's fixup phase, which copied each DLL an output imports from a build input beside it, is left out, since nothing built from the seed reads a PE import table. A package that sets `enableParallelBuilding` gets `make -j$NIX_BUILD_CORES` in the build phase and, unless it sets `enableParallelInstalling` to false, in the install phase, with `NIX_BUILD_CORES` read as nixpkgs' `setup.sh` reads it: 1 when unset, and what `nproc` counts for 0. The ladder's rungs build with it, and the package set's `stdenv` runs this `setup.sh` with the ladder's native toolchain. CI builds Hello with the seed stdenv on x64 and ARM64 Windows, runs it and checks that it names neither the store directory nor its own build directory, and a test reads its closure: its leaves are the seed and the sources the ladder fetches. (#411)- **Every package in `pkgs/windows` states the sources it fetches in `srcs`, and `pkgs/windows/sources.nix` lists them all.** A package names its sources inside its build script, where a walk over attributes such as nixpkgs' `find-tarballs.nix` does not find them, so nothing could fetch a package's sources without building it. CI realises the list from the public cache before each job builds, and a push to main publishes it there, so a source is fetched from its upstream host when the change that brings it is tested and merged, and not on every run. A job fails if the cache cannot be asked, where falling back would send its downloads to the upstream hosts. The test suite checks the list against the fetches in the closure of every derivation in the set. (#417)- **`pkgs/windows` builds GNU binutils 2.41 for `i686-w64-mingw32` with the seed stdenv, compiled by `tinycc-native`: the assembler, linker, archiver and object tools, running on i686 Windows and writing i686 PE and COFF.** It follows nixpkgs' `minimal-bootstrap/binutils`, which builds the same release with tinycc. The target is the triple MinGW-w64's own build guide configures binutils for and the one under which GCC 4.6.4 takes MinGW-w64's feature set, where any other vendor is mingw.org's; the stdenv's `i686-pc-mingw32` stays the build and the host, so the tools install as `bin/i686-w64-mingw32-<name>.exe` and again under their plain names in `i686-w64-mingw32/bin`. nixpkgs' later `fix-tinycc-attribute.patch` is applied unchanged: `include/ansidecl.h` defines `__attribute__` away for a compiler that is not GCC, and TinyCC's headers spell `__stdcall` as an attribute, so without it a source that reads `ansidecl.h` before `windows.h` calls every Windows API function as cdecl and pops arguments the function has already popped, in bfd on each file it opens. A second patch, of its own, opens in binary mode the temporary file that `ar` and `ranlib`, and `objcopy` and `strip` rewriting a file in place, write their output to and copy into place: without `mkstemp`, which msvcrt.dll lacks, `make_tempname` opens it with no `O_BINARY`, msvcrt treats it as text, and the copy ends at the first 0x1A byte, so an archive of libgcc's objects comes out cut short. MinGW-w64's runtime supplies a `mkstemp` that opens in binary, so its own builds of binutils never reach that open. nixpkgs' `deterministic.patch` is not applied, since the flag it sets is read by the archive and XCOFF writers and not by the PE writer, which stamps an image with the time unless ld is run with `--no-insert-timestamp`. The build leaves out what TinyCC's headers and msvcrt.dll cannot carry: the bundled libintl, whose declaration of `alloca` tcc rejects, plugin support, which reads a directory with `opendir`, and libctf, which includes `sys/param.h`. libbfd is installed, as in nixpkgs' native build, since libtool otherwise unpacks libsframe into libbfd member by member and `tcc -ar` keeps 15 characters of a member's name, which libsframe's three objects share. ld has no built-in search path, as in nixpkgs, and here also because its `genscripts.sh` splits the path at a drive letter's colon. Two compatibility headers add what MinGW-w64's headers have and TinyCC's lack: `alloca` as a macro, and `rpcdce.h` for the `UuidCreate` call behind `--build-id=uuid`. The seed stdenv gains what the build needs of it: a patch phase, nixpkgs' `patches`; `srcs` on what `mkDerivation` returns, as the MSYS2 stdenv stated it; and three `config.site` settings without which libtool takes tcc and its linker for Microsoft's, archives with `lib`, names a static library `.lib` and passes each source through `cygpath`. Since those settings have configure take tcc for GCC, which it gives `-g -O2` where CFLAGS is unset, `config.site` also gives CFLAGS an empty default that a package's own still overrides: tcc's debugging information names the directory tcc ran in and each file by the path it opened, a header from the store by the store's physical path, so a program built with it would differ with the store's drive and with the user whose temporary directory the build ran in, and tcc's `-O` only defines `__OPTIMIZE__`. make runs `$NIX_BUILD_CORES` jobs in one run, where nixpkgs' `minimal-bootstrap/binutils` builds ld on its own for a race between jobs over `ld/.deps/ldwrite.Po`, a file dependency tracking writes and `--disable-dependency-tracking` keeps the compile rule from writing. CI builds binutils on x64 and ARM64 Windows, checks `ld --version`, and has `as` assemble a function, `ar` archive it and `ld` link it into a program that runs and exits with the function's value, and has `ar` archive and extract a file holding a 0x1A byte and a CR LF unchanged. (#423)- **`pkgs/windows` builds MinGW-w64's headers and GCC 4.6.4's C compiler and libgcc for `i686-w64-mingw32` with the seed stdenv, the compiler compiled by `tinycc-native` and libgcc by that compiler: the driver, `cc1`, `cpp`, `collect2`, GCC's own headers and libgcc, with the binutils rung's assembler and linker.** It follows nixpkgs' `minimal-bootstrap/gcc/4.6.nix`, which builds the same release with tinycc, and builds what MinGW-w64's own build guide builds from one GCC build directory, with `make all-gcc` and `make all-target-libgcc`. The guide builds libgcc once MinGW-w64's runtime is installed, since its shared libgcc links against the runtime; libgcc here is static, as nixpkgs' is, links nothing and needs only the headers, so it is built in the same make, and the runtime, which this compiler compiles, is the next rung. libgcc is compiled without debugging information, which would name the build directory and the store paths the compiler read: `CFLAGS_FOR_TARGET=-O2` replaces the `-g` GCC's top-level configure adds to the target libraries' flags, and `LIBGCC2_DEBUG_CFLAGS=-g0` the `-g` GCC's Makefile adds to every libgcc compile. Its thread model is win32, on the Windows API alone, and its exceptions SJLJ, a 32-bit MinGW target's defaults. make runs `$NIX_BUILD_CORES` jobs, as `minimal-bootstrap/gcc/4.6.nix`'s does. `mingw-w64-headers` installs release v8.0.3, the newest whose runtime calls none of three builtins GCC 4.6.4 lacks, from the project's signed release archive. GCC is given them with `--with-headers`, which copies them into its own output as `i686-w64-mingw32/sys-include`, the directory a cross GCC searches for its target's headers, and its `limits.h` goes on to MinGW-w64's from there. GCC's manual prefers `--with-sysroot`, but GCC's top level hands each option to the configure of every library it builds, and mpc's libtool takes a sysroot for absolute only if it begins with `/`, which a store path on Windows does not; `--with-headers` is read by the top level and by `gcc` alone. The stdenv's `i686-pc-mingw32` stays the build and the host, so GCC is configured as the cross compiler it is: tcc compiles it against TinyCC's headers and msvcrt.dll, and its target has MinGW-w64's. Its programs install as `bin/i686-w64-mingw32-<name>.exe`, and `--with-as` and `--with-ld` compile in the paths of binutils' assembler and linker, which a cross GCC otherwise looks for in its own prefix. gmp, mpfr and mpc are built in the tree, as in nixpkgs. The edit of binutils' `fix-tinycc-attribute.patch` is made to GCC's copy of `include/ansidecl.h`: without it 25 calls in libiberty's `pex-win32.c` and `lrealpath.c` and in `gcc/config/i386/host-mingw32.c` reach the Windows API as cdecl, and pop arguments the function has already popped, on every program the driver starts. Three more settings are for TinyCC. `CFLAGS=-Dalloca=alloca`, since libiberty, gmp and mpfr each declare `alloca` in a way tcc rejects unless it is a macro. `LDFLAGS=-luser32`, since libiberty calls `CharLowerBuff`, and tcc links msvcrt and kernel32 alone where GCC's own MinGW links user32 into every program. And a new package, `mingw-w64-dirent`, MinGW-w64's own `dirent.c` compiled by tcc beside the `dirent.h` it is written for: libcpp reads a directory of precompiled headers with `opendir`, msvcrt.dll has none, and TinyCC's `dirent.h` declares an older `struct dirent`, against which that file compiles without a warning and then copies each name through a pointer nothing sets. The seed stdenv gains what the rung needs of it: `preConfigure`, nixpkgs' hook, which moves `mingw-w64-headers` to the directory its configure is in and unpacks GCC's three libraries where its configure looks for them; `configureScript`, nixpkgs' too, with which GCC configures from a build directory beside its source, as its installation guide recommends, since in the source GCC names the build machine's `fixincl` by two paths that differ and, with the program called `fixincl.exe`, make links `fixincl.o` alone; `configureFlags` joins the variables whose store paths are respelled with forward slashes, since GCC's configure writes the headers' and the two tools' paths into Makefiles and C strings; `config.site` answers that `atoll` exists, since TinyCC's `stdlib.h` defines it inline and `msvcrt.dll` exports none, so a link test finds none and GCC's `read-rtl.c` then defines a second. `tinycc-native`'s runtime gains an empty `libm.a`, as MinGW-w64's runtime has one: TinyCC finds a library only by a file, `msvcrt.dll` holds the math functions, and GCC links its `genautomata` with `-lm`; CI links a program with `-lm` and runs its `sqrt`. `fetchurl` takes nixpkgs' `mirror://sourceforge`. CI builds the three packages on x64 and ARM64 Windows, checks the driver's version line, and has the compiler compile a source to assembly, read `windows.h`, and compile a function that `ld` links and that runs. The assembly is compared with what GCC 4.6.4 built by another compiler writes for the same source, which holds constants `cc1` folds in its 64-bit arithmetic, in its floating point and through MPFR, so a `cc1` that tcc compiled wrongly shows. (#426)- **`pkgs/windows` builds MinGW-w64's runtime with GCC 4.6.4, and `gcc46`, that compiler with libgcc and the runtime in one prefix, so the ladder now has a compiler that turns a C source into a Windows program that runs.** `mingw-w64-crt` compiles release v8.0.3's runtime, from the archive `mingw-w64-headers` already fetches, with `gcc-core` and binutils' `as`, `ar`, `ranlib` and `dlltool`, for i686 against msvcrt.dll: `crt2.o` and the other start files, `libmingw32.a`, `libmingwex.a`, `libmoldname.a`, `libm.a` and an import library for each DLL. It configures the runtime's own directory from a build directory beside it, as MinGW-w64's build guide does, with `--host=i686-w64-mingw32` so that configure looks the tools up under the target's name, and with the stdenv's `CC`, `AR` and `C_INCLUDE_PATH` unset: configure takes the compiler and archiver the environment names, which in the seed stdenv are tcc's, and GCC reads `C_INCLUDE_PATH` too, which names TinyCC's headers and comes before GCC's own and MinGW-w64's in its search. `--enable-lib32` and `--disable-lib64` are nixpkgs' flags for an i686 host: left to itself, configure decides each by compiling a test, and a compiler that fails the test for another reason would leave a runtime with no libraries and a build that passes. `CFLAGS=-O2` is configure's default for GCC without the `-g` whose debugging information would name the build directory and the store paths the compiler read, and make builds with `$NIX_BUILD_CORES` jobs, as nixpkgs' does, and installs with one, since two of the runtime's install rules write `lib32/libntoskrnl.a`. `gcc46` compiles nothing: it copies `gcc-core`'s output and puts the runtime's in its `i686-w64-mingw32` directory, where the guide installs the runtime in the GCC core's prefix and where GCC's own build looks for its target's libraries. GCC's driver takes its directories relative to the one it runs from when that is not the one it was configured for, so the copy's driver finds `crt2.o`, libgcc and the libraries every link names with no flag, and GCC is not compiled a second time. CI builds both on x64 and ARM64 Windows. One check pins every file the runtime installs and the symbols of `crt2.o`, which defines `__CTOR_LIST__` itself when configure's one link test fails, so that a test failing on Windows for another reason shows instead of changing the runtime quietly. The other has `gcc46` compile and link a program with no flag naming a directory and run it: it prints through msvcrt.dll's `puts` and `printf`, divides 64-bit integers through libgcc's `__divdi3` and `__moddi3`, and imports from msvcrt.dll and kernel32.dll alone. (#439)- **`pkgs/windows`' Mes is GNU Mes 0.28, with the Windows port merged onto upstream's master.** 0.28 replaces Mes's tree-walking interpreter with a bytecode compiler and interpreter. Mes and MesCC run in the arena and stack MesCC's own script sets, 20,000,000 cells and 60,000 entries: 0.28 asserts that the stack stays under 131,072 entries, where `pkgs/windows` set 6,000,000, and reads no `MES_MAX_ARENA`. A collection copies the cells it keeps into the arena's free third and stops Mes with an out-of-memory error when they do not fit, where 0.27.1 copied them past the arena's end without checking. Upstream fixes `strpbrk` itself, so the fork carries nixpkgs' other i686 C library fixes alone. (#445)- **`pkgs/windows`' stage0-pe32 links every compiled program against M2libc's Windows runtime, and M2libc's `fseek` returns 0 on success.** The startup, system calls, C library glue and PE-end shim a compiled program links against now live in M2libc's `x86/windows/`, beside its C, as M2libc carries its Linux runtime, so a merge of upstream M2libc shows where the two runtimes need the same change. stage0-pe32 keeps its own copies of the PE header and the ntdll plumbing for the hand-written M0 and cc_x86, as stage0-posix keeps its own ELF header, and one generator writes both. The moved files are byte for byte the ones stage0-pe32 held, and comments that contradicted the code are corrected in both repositories. M2libc's `main` also carries the two fixes it offers upstream: `fseek` returned the new position where ISO C 7.21.9.2 requires 0, and armv7l's `close`, `unlink` and `chroot` passed the kernel their argument's address. No program in the chain reads `fseek`'s result, but hex2-new and kaem link the `stdio.c` that holds it, so their bytes change; every other link is unchanged. (#450)- **`pkgs/windows` builds `gcc46-cxx`, GCC 4.6.4 with C and C++ for `i686-w64-mingw32`, compiled by `gcc46` in the seed stdenv, with libgcc and libstdc++ compiled by the compiler the same make links, so the ladder has a C++ compiler for the GCC after it.** GCC is written in C++ from 4.8 on, and nixpkgs' `minimal-bootstrap` builds its GCC 10 with the same rung, `gcc/4.6.cxx.nix`, which this follows: gcc-core's sources with GCC's g++ archive unpacked over them, and nixpkgs' flags, `-O1` for the compiler and `-O0` for the target libraries, and `install-strip`. nixpkgs gives its native compiler musl's headers and libraries; here GCC is a cross compiler, as gcc-core is, and is given MinGW-w64's headers and runtime with `--with-headers` and `--with-libs`, the pair GCC's installation guide names for a C library built outside its tree. The top-level configure copies both into GCC's own output, where gcc46 has them and where the build points the compiler it links when it compiles and links libstdc++, whose configure links its tests for a MinGW target and so needs the runtime first. libstdc++ installs beside the runtime, so `i686-w64-mingw32-g++` links a C++ program with no flag naming a directory. The build runs gcc46's driver and binutils' archiver, linker and strip under the target's names, the only names they have on `PATH`, since configure looks the host's tools up under bare names and the seed stdenv's `CC`, `AR` and `LD` are tcc's. `--disable-win32-registry` is not nixpkgs': linked against MinGW-w64's `libadvapi32.a`, a GCC for Windows looks its directories up in the registry under `HKEY_LOCAL_MACHINE\SOFTWARE\Free Software Foundation`, so a machine with a GCC installed there would change where this one looks. `--disable-shared`, as in nixpkgs, keeps libgcc and libstdc++ static, and exceptions are SJLJ, a 32-bit MinGW target's default. No program the rung installs carries the time it was built, so two builds of it at the output's own path are the same bytes. binutils' `ld` writes the time of the link into a PE image's header unless it is given `--no-insert-timestamp`, which GCC 4.6.4's link spec for MinGW never passes and the seed stdenv has no compiler wrapper to add, so `LDFLAGS` passes it to every link `gcc46` makes, of the host's programs and the build machine's. `strip`, which `install-strip` runs on each program, then writes the time over the zero `ld` wrote unless it is run with `-p`, as nixpkgs' strip hook runs it, so the install phase gives make a `STRIP` with `-p`, on make's command line since the stdenv splits `configureFlags` and `makeFlags` at spaces. `nova-nix build --check` of the rung still finds seven programs differ, the five drivers, `cc1` and `cc1plus`: the check builds at a scratch path and rewrites its hash in what the builder wrote, and each of the seven names the output and carries a sum of its own bytes that no rewrite reaches, the PE checksum `ld` and `strip` write and, in `cc1` and `cc1plus`, the MD5 GCC takes of the objects they link, two of which compile the prefix in. CI builds the rung on x64 and ARM64 Windows and has its `g++` compile and link a C++ program that prints through iostream, calls virtual functions through a base pointer, instantiates a template, uses `new` and `delete`, constructs a global and a function-local static, and throws and catches two exceptions, one after unwinding through four frames whose destructors run; the check compares what it prints and its exit status with what the C++ standard defines, and pins that it imports msvcrt.dll and kernel32.dll alone and links libsupc++'s and libgcc's SJLJ exception functions. A second check reads the time stamp in the header of every program and DLL the rung installs and compares the list with one in which each is zero. (#455)- **`pkgs/windows` builds `gcc10`, GCC 10.4.0 with C and C++ for `i686-w64-mingw32`, compiled by `gcc46-cxx` in the seed stdenv, with GMP, MPFR and MPC built in its tree and libgcc and libstdc++ compiled by the compiler the same make links, the compiler nixpkgs' `minimal-bootstrap` builds its current GCC with.** GCC 10 is the last GCC a C++98 compiler builds, and nixpkgs' `minimal-bootstrap` goes from GCC 4.6.4 to it with `gcc/10.nix`, which this follows: its release, 10.4.0, since 10.5.0 does not build with GCC 4.6; its GMP 6.2.1, MPFR 4.2.2 and MPC 1.4.1, unpacked into GCC's tree, where GCC's configure builds them; and its flags, `-O1` for the compiler, `-O0` for the C++ target libraries, and `install-strip`. The C target libraries are `-O2`, configure's default for them, where nixpkgs gives `-O0`: libgcc takes the top level's flags after its own, and at `-O0` its 64-bit division functions, compiled with `-fexceptions -fnon-call-exceptions`, call the SJLJ unwinder, which every C program then took in through MinGW-w64's printf after the libraries the unwinder needs, so none linked. libcpp carries GCC 11's change that has its configure look the archiver up, since GCC builds libcpp for the build machine too and its Makefile named `ar`, which here is busybox's applet. nixpkgs gives its native compiler musl's headers and libraries; here GCC is a cross compiler, as `gcc46-cxx` is, given MinGW-w64's v8.0.3 headers and the runtime `gcc-core` compiled with `--with-headers` and `--with-libs`, as nixpkgs' GCC 10 links the musl its GCC 4.6.4 compiled. The build runs `gcc46-cxx`'s `gcc` and `g++` and binutils' archiver, linker and strip under the target's names; `CXX` is new, since GCC 10 is written in C++ and configure looks a C++ compiler up under bare names, of which `PATH` has none. As in `gcc46-cxx`, `--disable-win32-registry` is not nixpkgs', `--disable-shared` keeps libgcc and libstdc++ static, exceptions are SJLJ, and no program the rung installs carries the time it was built. libgcc carries no debugging information either. GCC 10 compiles libgcc with `-g` from libgcc's own Makefile, which no variable the top level passes reaches, and the information names the build directory, which is named for the output's hash, in every program that links the objects it describes, so the install strips it from the three files libgcc compiles with it, as `install-strip` strips libstdc++'s archives. CI builds the rung on x64 and ARM64 Windows in a stage of its own, GCC 10 (Windows), which starts from the store GCC 4.6.4 C++ (Windows) hands it. Its `gcc` compiles and links a C program that prints the compiler's version and default standard and runs the three builtins GCC 4.6.4 lacks and newer MinGW-w64 runtimes call, and its `g++` a C++14 program that runs the C++ checks `gcc46-cxx`'s does with `std::unique_ptr`, lambdas, variadic templates, `constexpr`, `std::map` and `std::to_string`. Each check compares what its program prints and its exit status with what the C and C++ standards define, and pins the DLLs the program imports, the libgcc and libsupc++ functions it links and that it has no debugging section. A third check reads the time stamp in the header of every program the rung installs and compares the list with one in which each is zero. (#504)- **`pkgs/windows` builds MinGW-w64 v14.0.0, the project's newest release and the one nixpkgs packages, with `gcc10`: `mingw-w64-headers-latest` installs its headers and `mingw-w64-crt-latest` compiles its runtime for `i686-w64-mingw32`, the runtime the compilers after `gcc10` are given.** The ladder's first runtime, v8.0.3, is the newest GCC 4.6.4 compiles, since later releases call `__atomic_load_n` (`misc/gettimeofday.c`), `__builtin_mul_overflow` (`misc/_recalloc.c`) and `__builtin_bswap16` (`misc/winbs_ushort.c`), which that compiler lacks and GCC 10 has. Both packages follow nixpkgs' `mingw_w64_headers` and `mingw_w64` and the ladder's v8.0.3 rungs: the headers install from the archive's own directory with no compiler, and the runtime configures its own directory from a build directory beside it with `--host=i686-w64-mingw32`, the stdenv's `CC`, `AR` and `C_INCLUDE_PATH` unset, the headers' output as its sysroot, `--enable-lib32 --disable-lib64` and `CFLAGS=-O2`. `--with-default-msvcrt=msvcrt` is nixpkgs' flag for this target and the runtime the ladder links; at this release it names msvcrt.dll's version 0x600 in `_mingw.h`, where v8.0.3 names 0x700, and makes `libmsvcrt.a` a copy of `libmsvcrt-os.a`, msvcrt.dll's import library with the functions it lacks compiled in. `_WIN32_WINNT` is the release's default, 0xa00, Windows 10, as in nixpkgs. Each file of this release's runtime has one install rule, so it installs with `$NIX_BUILD_CORES` jobs, where v8.0.3's installs with one. `gcc10` keeps v8.0.3's runtime in its own prefix: the new runtime's compiles read the new headers first, and the runtime links no program. CI builds both in the GCC 10 (Windows) stage on x64 and ARM64 Windows. One check pins every file the runtime installs, which is what the release's Makefile installs for this configuration, each a file Homebrew's mingw-w64 14.0.0 installs for i686 too, and the global symbols of `crt2.o`, which are those of the `crt2.o` GCC 16.2.0 compiled for that package, so that configure's test of whether `ld` defines `__ImageBase`, which changes the objects and not the build's exit status, shows if it fails on Windows. The other has `gcc10` link a program against the new runtime, given its directories with `-B` and `-isystem` as GCC's build gives a compiler its target's runtime: it prints the release and msvcrt.dll version the headers name, and calls `gettimeofday`, `_recalloc`, including a size whose product overflows, and `_byteswap_ushort`, each linked from the runtime's libraries. (#535)- **`pkgs/windows` builds `gcc-latest`, GCC 16.2.0 with C and C++ for `i686-w64-mingw32`, compiled by `gcc10` in the seed stdenv against MinGW-w64 v14.0.0, with GMP, MPFR and MPC built in its tree and libgcc and libstdc++ compiled by the compiler the same make links: the GCC nixpkgs' `minimal-bootstrap` builds after GCC 10.** It takes nixpkgs' release, 16.2.0, which needs a C++14 compiler to build, and nixpkgs' GMP 6.3.0, MPFR 4.2.2 and MPC 1.3.1, the releases GCC's own `contrib/download_prerequisites` fetches for an in-tree build of 16.2.0. nixpkgs builds this GCC in pieces, GMP, MPFR, MPC, libiberty, libbacktrace, the compiler, libgcc and libstdc++ each a derivation of its own, and joins them with a wrapper that points the compiler at musl, libgcc and libstdc++. Here, as in `gcc10`, the compiler is one build, a cross compiler given the current MinGW-w64's headers and runtime with `--with-headers` and `--with-libs`, which GCC copies into its own prefix and hands the compiler it links when it builds libgcc and libstdc++, so the driver finds the runtime and both libraries with no flag and no wrapper, and neither of nixpkgs' two patches, which serve its separate builds, applies. nixpkgs' choices carry over where they mean the same here: `-O1` for the compiler and `-O0` for libstdc++, `--disable-gcov`, `--enable-linker-build-id`, which has every link this compiler makes write a CodeView build ID, the deletion of the configure arguments from the top-level Makefile, which keeps the store paths they name out of `gcc -v`, and the removal after the install of the `install-tools` directories, libstdc++'s Python pretty-printers and the manual and info pages. The install removes libstdc++'s gdb script too, which loads those printers, and the `share` directories the removals leave empty. `--enable-default-pie` is left out: GCC compiles 32-bit Windows code without PIC whatever it is told, so the flag would only pass `-pie` to every link, for which binutils' `ld` writes an empty export table into a program that is relocatable without it. The build names binutils' `windres` by the target's name, as it names the compilers: GCC 16 built for Windows embeds a manifest that runs its driver and compilers with the UTF-8 code page, compiled by `windres`, which configure looks up under its bare name, and `PATH` has none. libgcc is `-O2`, for the reason `gcc10`'s is, and its debugging information is stripped after the install, as nixpkgs strips it. The thread model is win32, this target's default, under which libstdc++ has `std::thread` because MinGW-w64 v14.0.0's headers name Windows 10. As in `gcc10`, `--disable-win32-registry` is not nixpkgs', `--disable-shared` keeps libgcc and libstdc++ static, exceptions are SJLJ, and no program the rung installs carries the time it was built. CI builds the rung on x64 and ARM64 Windows in a stage of its own, GCC 16 (Windows), which starts from the store GCC 10 (Windows) hands it. Its `gcc` compiles and links a C23 program, its default, that uses `constexpr`, `typeof`, `nullptr`, `bool` and `_BitInt(128)`, and its `g++` a C++20 program, its default, that uses `std::format`, concepts, ranges, `std::span`, a three-way comparison and four `std::jthread` threads synchronized with a `std::mutex` and a `std::condition_variable`. Each program prints the compiler's version and default standard and the runtime's release, and each check compares what it prints and its exit status with what the C and C++ standards define, and pins the DLLs it imports, the libgcc, libsupc++ and libstdc++ functions it links, that it carries one build ID and that it has no debugging section. A third check reads the time stamp in the header of every program the rung installs and compares the list with one in which each is zero. (#548)- **`pkgs/windows` builds `binutils-x86_64`, GNU binutils 2.46 for `x86_64-w64-mingw32`, compiled by `gcc-latest` in the seed stdenv: the first rung of the ladder's x86_64 toolchain, which the package set's 64-bit packages need.** The ladder reaches x86_64 the way MinGW-w64's own build guide and nixpkgs' `pkgsCross.mingwW64` do, through a cross toolchain: these tools, then a GCC core that compiles the runtime, the runtime, and GCC with its libraries, each running on i686 Windows. binutils is a rung of its own rather than the i686 rung rebuilt with `--enable-targets`: GCC for `x86_64-w64-mingw32` and MinGW-w64's runtime look their tools up under the target's name, which only a binutils configured for that target installs, and the i686 rung is compiled by tcc with patches and flags for tcc and msvcrt.dll. The x86_64 target's own formats include i386 PE, so these tools read and write both. The release is nixpkgs' 2.46, from the archive nixpkgs fetches; GCC 16.2.0 does not need it, since its configure tests the assembler for each feature it would use and does without what 2.41 lacks, such as `.base64`. nixpkgs' flags carry over where they mean the same here; those for ELF, Linux or MIPS are left out, the zlib of binutils' tree is linked in place of a system one, the libraries are static, so the programs import no DLL of binutils', and NLS is off, since the ladder has no gettext. None of nixpkgs' patches applies: `deterministic.patch` sets a flag the PE writer does not read, and the others serve ELF, nixpkgs' split outputs, configure scripts it regenerates on Darwin alone, AVR, or a `windres` run by a path. Every link is told to write no time stamp, which `ld` otherwise writes into a PE image. CI builds the rung on x64 and ARM64 Windows in a new stage, x86_64, which starts from the store GCC 16 now hands on. One check has `as` assemble a function, `ar` archive it and `ld` link it into an x86_64 program and an i386 one that run and exit with its value, and compares what `nm`, `ar` and `objdump` read back, and the machine and optional header magic read from each program's PE header, PE32+ for x86_64, with what the formats define; the other reads the time stamp in the header of every program the rung installs and compares the list with one in which each is zero. (#550)- **`pkgs/windows` builds `gcc-core-x86_64`, GCC 16.2.0's C compiler and libgcc for `x86_64-w64-mingw32`, compiled by `gcc-latest` in the seed stdenv: the GCC core that compiles the x86_64 runtime.** It is MinGW-w64's build guide's GCC core and nixpkgs' `gccWithoutTargetLibc`, the compiler a cross toolchain builds before its target's C library exists, and the second rung of the ladder's x86_64 toolchain. Its sources and configuration are `gcc-latest`'s, GCC 16.2.0 with GMP, MPFR and MPC built in its tree, for the other target: the compiler runs on i686 Windows, writes x86_64 code through `binutils-x86_64`'s assembler and linker, and reads the current MinGW-w64's headers, the same files for either target. make builds and installs the compiler and libgcc alone, as the 4.6.4 `gcc-core` does, which is what compiling the runtime needs; libgcc is static and single-threaded, as nixpkgs has it for this compiler, and links nothing, so it needs only the headers. nixpkgs' flags carry over where they mean the same; those naming target libraries the build never configures, and three read by no configure of 16.2.0's tree, have nothing to do. The compiler and libgcc are `-O2`, configure's own optimization, without the `-g` nixpkgs strips after its install, libgcc's own `-g` is stripped here too, and no installed program carries the time it was built. CI builds the rung in the x86_64 stage on x64 and ARM64 Windows. One check has the compiler read `windows.h` and compile a function that divides two 128-bit integers, which `ld` links with libgcc and no runtime into a program that runs and exits with the quotient, and compares the target, version and thread model the driver reports, the object's symbols, and the machine and optional header magic read from the program's PE header with what the configuration and the formats define; the other compares the time stamps of the installed programs with a list in which each is zero. (#550)- **`pkgs/windows` builds `mingw-w64-crt-x86_64`, MinGW-w64 v14.0.0's runtime for `x86_64-w64-mingw32`, compiled by `gcc-core-x86_64` in the seed stdenv: the runtime the x86_64 GCC is given.** It is `mingw-w64-crt-latest`'s build for the other target, as nixpkgs' `mingw_w64` builds it for an x86_64 host: `--host=x86_64-w64-mingw32`, `--disable-lib32 --enable-lib64`, nixpkgs' flags for that host, and msvcrt.dll, the runtime the ladder links, compiled against `mingw-w64-headers-latest`, whose files serve either target. The 64-bit libraries install in `lib`, the directory the runtime's configure names for an x86_64 host. `gcc-core-x86_64` has no runtime yet, so configure's link to learn the suffix of executables fails, as the runtime's configure lets it, and its link with `-nostdlib`, which asks whether `ld` defines `__ImageBase`, is one that needs none. CI builds the rung in the x86_64 stage on x64 and ARM64 Windows. One check pins every file the runtime installs, each one Homebrew's mingw-w64 14.0.0 installs for x86_64 too, and the global symbols of `crt2.o`, which are those of the `crt2.o` in that package, so that the `__ImageBase` test, which changes the objects and not the build's exit status, shows if it fails on Windows. The other has `gcc-core-x86_64` link a program against the runtime, given its directories with `-B` and `-isystem` as GCC's build gives a compiler its target's runtime, that prints the release and msvcrt.dll version the headers name and calls `gettimeofday`, `_recalloc` and `_byteswap_ushort`, each linked from the runtime's libraries, and reads the program's PE header, which names an x86_64 PE32+ image. (#550)- **`pkgs/windows` builds `gcc-x86_64`, GCC 16.2.0 with C and C++ for `x86_64-w64-mingw32`, compiled by `gcc-latest` in the seed stdenv against MinGW-w64 v14.0.0's headers and the x86_64 runtime: the ladder's first compiler that writes 64-bit programs.** It finishes the cross toolchain MinGW-w64's build guide builds, as nixpkgs' `pkgsCross.mingwW64` builds its GCC. The build is `gcc-latest`'s, one cross compiler build given its target's headers and runtime with `--with-headers` and `--with-libs`, so libgcc and libstdc++ are built against them by the same make and the installed driver finds all of them with no flag. The flags are those of nixpkgs' cross compiler, where `gcc-latest`'s are `minimal-bootstrap`'s: the compiler and its target libraries are `-O2`, configure's own optimization, without the `-g` nixpkgs strips after its install, and the build ID, gcov, the analyzer and libstdc++'s visibility and ABI are configure's defaults. nixpkgs gives libstdc++ the mcf thread model from mcfgthreads, which the ladder does not build; the model here is win32, the target's own on the Windows API alone and nixpkgs' choice for a MinGW target with no thread library, under which libstdc++ has `std::thread` because the headers name Windows 10. Exceptions are SEH, the x86_64 target's. Where nixpkgs' choices need what the ladder does not have, `gcc-latest`'s are kept: GMP, MPFR and MPC in the tree and no ISL, the tree's zlib, no NLS, static libgcc and libstdc++, so a program imports no DLL of GCC's, no LTO or plugins, and the target libraries other than libgcc and libstdc++ off. nixpkgs' patch for a Windows target serves a libstdc++ built without its C library, and this one is hosted. CI builds the rung on x64 and ARM64 Windows in a stage of its own, GCC 16 x86_64, which starts from the store x86_64 now hands on. Its `gcc` compiles and links a C23 program that prints the x86_64 Windows sizes of a pointer, a long, a long long and a long double, divides 128-bit integers through libgcc and multiplies `_BitInt(256)` values through it, and its `g++` the C++20 program `gcc-latest`'s check links, threads and exceptions included, which here unwind through SEH. Each check compares what its program prints and its exit status with what the standards and the ABI define, and pins the DLLs it imports, the libgcc, libsupc++ and libstdc++ functions it links, that it has no build ID and no debugging section, and the machine and optional header magic of its PE header, an x86_64 PE32+ image. A third check reads the time stamp in the header of every program the rung installs and compares the list with one in which each is zero. (#550)- **`pkgs/windows` builds `binutils-native-x86_64` and `gcc-native-x86_64`, binutils 2.46 and GCC 16.2.0 with C and C++ that run on x86_64 Windows and write `x86_64-w64-mingw32`, compiled by `gcc-x86_64` in the seed stdenv: the ladder's first tools that run as `gcc`, `g++`, `as` and `ld`, as the MSYS2 stdenv's toolchain did.** Every rung before them runs on i686, and the x86_64 cross toolchain is named for its target. Each is a Canadian cross, as nixpkgs builds a toolchain whose host is its target: the stdenv's i686 triple is the build and `x86_64-w64-mingw32` the host and the target, so the programs take no prefix, the host's programs and GCC's target libraries are compiled by `gcc-x86_64`, a cross compiler of the same release as nixpkgs requires, and the programs the build runs itself by `gcc-latest`. The binutils flags are `binutils-x86_64`'s, and the GCC flags `gcc-x86_64`'s, but for what a compiler whose host is its target needs: GCC refuses `--with-headers` and `--with-libs` for it, so the build reads MinGW-w64's headers through `--with-build-sysroot` and `--with-native-system-header-dir`, as nixpkgs does, which also lets GCC's `limits.h` include MinGW-w64's, and the install copies the headers and the x86_64 runtime into the compiler's tool directory, where the installed driver finds them with no flag; `--with-as` and `--with-ld` name the native binutils. As nixpkgs' compilers do, it leaves `/usr/local/include` out of its search for headers, which a GCC whose host is its target otherwise searches ahead of the target's own, so a directory of that name on the build's drive cannot shadow MinGW-w64's. The thread model is win32 and libgcc and libstdc++ are static. MSYS2's GCC has the posix model and shared runtime DLLs that import winpthreads, which the MSYS2 stdenv carried by putting its toolchain on `PATH` and copying DLLs beside each output, but its packages used neither: they are C, and GNU Hello built with it imports no DLL of GCC's or winpthreads. nixpkgs gives a thread model only to a GCC whose host is not its target, so its native MinGW-w64 GCC takes win32, the target's default, which needs no thread library the ladder does not build and under which libstdc++ has `std::thread`; static libraries leave a program importing no DLL of GCC's, which the seed stdenv, having no fixup phase, could not carry. CI builds both rungs on x64 and ARM64 Windows in a new stage, Native x86_64, which starts from the store GCC 16 x86_64 now hands on. One check has the tools assemble, archive and link an x86_64 program and an i386 one that run; two have `gcc` and `g++` link the C23 and C++20 programs `gcc-x86_64`'s checks link, threads and SEH exceptions included, and compare their output, imports and symbols with what the standards and the ABI define. Each also reads the PE headers of the rung's own `as.exe` and `ld.exe`, or `gcc.exe`, `g++.exe`, `cc1.exe` and `cc1plus.exe`, which are x86_64 PE32+ images, and finds that none imports a DLL of GCC's runtime, winpthreads or mcfgthreads; and a check per rung reads the time stamp in the header of every program it installs and compares the list with one in which each is zero. (#618)- **`pkgs/windows` has a stdenv on the seed ladder's native toolchain, to replace the MSYS2 one: the seed stdenv's builder and tools, busybox-w32's sh and applets and `gnumake`, with the ladder's `binutils-native-x86_64` and `gcc-native-x86_64`, as `x86_64-windows`, and `pkgs/windows`' GNU Hello package builds with it unchanged.** Its builds reach the compilers and the linker through its `cc`, as nixpkgs' reach theirs through `stdenv.cc`: `gcc`, `cc`, `g++`, `c++` and `ld`, scripts that give every build what the MSYS2 stdenv's wrapper gave its builds. The C drivers compile at `-std=gnu17` ahead of a package's own options, since GCC 16 defaults to C23, under which an empty parameter list declares a function that takes no arguments and the K&R declarations older gnulib copies carry conflict with the C library's; the C++ drivers keep the compiler's default. Every link a driver makes gets `--no-insert-timestamp` from a specs file appended to GCC's link spec, which the driver applies only when it links: the MSYS2 wrapper's `-Wl,--no-insert-timestamp`, added to each command with no compile-only option, was an input file to the driver, so with it `gcc -v` went on to link. `ld` gets the flag directly. Each driver runs with none of the variables GCC 16 searches directories from: `CPATH`, `C_INCLUDE_PATH`, `CPLUS_INCLUDE_PATH`, `COMPILER_PATH`, `LIBRARY_PATH`, `LPATH` and `GCC_EXEC_PREFIX`, the last three of which the MSYS2 wrapper left set; the Objective-C variables it also unsets serve a language `gcc-native-x86_64` does not compile. The wrappers are scripts with no extension, which busybox's sh and GNU make run through the `sh` their first line names, and neither toolchain's `bin` directory is on `PATH`, since GNU make looks for a command with `.exe` in every directory of `PATH` before it looks for one without, and would run `gcc.exe` past the wrapper. `AR` names binutils' archiver by its path, since busybox's sh runs its own `ar` applet for the name. configure is told `--build=x86_64-w64-mingw32`, since `config.guess` cannot read busybox's `uname`, and the stdenv's `config.site` makes `-O2` the default `CFLAGS` and `CXXFLAGS` in place of configure's `-g -O2`, whose debugging information would name the build directory, which nova-nix makes in the store directory. CI's ladder gains a Stdenv stage after Native x86_64 on x64 and ARM64 Windows, which builds Hello with the stdenv, runs it and checks that it names neither the store directory nor its build directory, and builds a check whose programs, compiled and linked by each wrapper by name, by `gcc` with a package's own `-std` and from a make recipe, and by `ld`, report the standard they were compiled at and carry a zero time stamp, and in which none of those variables reaches the compiler, though each reaches `gcc-native-x86_64`'s own drivers. A test reads the closures: the leaves the stdenv and the packages built with it add to the native toolchain's are the archives of Hello, sed and zlib, and its builds have the applets, `gnumake` and the wrappers alone on `PATH`. (#654)- **The stdenv on the seed ladder's native toolchain bundles each DLL an output's programs and libraries import from a build input beside them, as the MSYS2 stdenv did, and builds the six packages the MSYS2 stdenv built: GNU Hello, GNU sed, zlib as a DLL, libgreet, and zdemo and greeter, which link zlib and libgreet.** Windows has no RPATH, so a program finds a DLL in its own directory before the system's and PATH's, and a program that links a DLL from another package runs only with that DLL beside it. It now runs its own setup script, which runs the seed stdenv's unchanged for every phase from unpack to install and then that fixup phase, reading each PE file's imports with binutils' `objdump` to a fixpoint and failing the build on a DLL that is neither a system one nor in a declared input; the seed ladder's rungs are untouched. `OBJDUMP` and `STRIP` name binutils' programs by their paths, as nixpkgs' bintools wrapper names them, since the stdenv keeps its toolchain off `PATH`, and `WINDRES` names a `windres` wrapper beside the compiler wrappers: windres preprocesses through `cmd.exe`, which cannot run the stdenv's `gcc`, a script, so the wrapper gives windres the native `gcc.exe` as its preprocessor, under the environment the `gcc` wrapper gives it. zlib's build passes `WINDRES` and `STRIP` to its makefile, which names them otherwise, and GNU sed's configure takes `WINDRES` from the environment for its tests' resource files. (#714)- **`pkgs/windows`' `stdenv` is the stdenv on the seed ladder's native toolchain, so GNU Hello and the set's other packages build with the toolchain the seed ladder builds from its hex seed, and with no prebuilt compiler or shell.** It builds every package the MSYS2-based stage-1 one built, its DLLs bundled beside them. A first build substitutes the toolchain from the public cache, where the seed ladder's runs on main publish it; built from the seed, it takes hours. (#723)- **Nothing in `pkgs/windows` downloads a prebuilt compiler or shell: `stage1Stdenv`, the stdenv on MSYS2's bash and MinGW-w64's GCC, is removed with the 39 MSYS2 and MinGW-w64 binary packages it was made of, and the set's `stdenv` takes its shell, tools and toolchain from the seed ladder, which builds them from stage0-pe32's seed.** The set's `stdenv` builds every package the stage-1 one built, so nothing in the set used the stage-1 one. The packages were pinned by SHA-256 to repo.msys2.org, which drops old versions, and `pkgs/windows/sources.nix`, from which CI publishes every source the set fetches to the public cache, no longer lists them. `builtin:unpack` no longer extracts `.tar.zst` archives or skips the files at an archive's root whose names begin with a dot, pacman's `.PKGINFO` and `.MTREE` among them, which only those packages needed: a `.tar.zst` source fails with `unsupported archive format`, and a dot file at an archive's root is extracted like any other. It still extracts `.tar.gz` and plain `.tar` archives, and stage0-pe32's chain reads GitHub's `.tar.gz` archives through it. (#726)- **The Windows stdenv's `windres`, and the GCC 16 rungs' builds, run windres' preprocessor without `cmd.exe`.** windres reads the output of the preprocessor it runs on a resource script through `popen`, which starts the command through `cmd.exe`, a program from outside the store; `--use-temp-file` has windres start the preprocessor itself and read its output from a file. The stdenv's `windres` wrapper passes it, as do `gcc-latest`, `gcc-core-x86_64`, `gcc-x86_64` and `gcc-native-x86_64`, which compile GCC's UTF-8 manifest with windres. Their `WINDRES` is in the derivation's environment rather than in `configureFlags`, which the seed stdenv splits at spaces, and configure takes a tool that is already set. (#753)- **`gcc-core` and `gcc46-cxx` build gmp's table of digits per bit from fixed digits, so `gcc46-cxx` builds to the same bytes on x64 and ARM64 Windows.** gmp writes the table at build time with a program it compiles and runs on the build machine, which computed each base's value with that machine's `log` and `printf`. Under ARM64 Windows' x86 emulator, which carries out x87 arithmetic in double precision, `gcc46-cxx`'s program wrote other last digits for 13 of the 255 bases, so the rung's `cc1` and `cc1plus` differed between the two legs of the ladder. A patch to gmp's generator has it write fixed digits instead, those an x86 processor gives, which are the table both rungs wrote on x64 before: each base's value is 0.69314718055994530942 divided by `log(base)` in double precision, the log and the quotient each rounded to the nearest double, written to sixteen places from its first seventeen significant digits. The later gmp that GCC 10 and GCC 16 build computes its table in integers, and needs no patch. (#752)- **`pkgs/windows/unused-prebuilt.json` lists each prebuilt file in a source archive the stdenv's closure unpacks, with why no build uses it, and every build that unpacks one of those archives removes its listed files first.** GNU's GCC and binutils releases carry zlib's MASM objects, libgo's test data and binutils' test-suite inputs, and stage0-pe32's tree carries the original hex0, whose DOS header its development generators copy. GNU publishes no release archive without them and stage0-pe32's tree stays as it is, so what can hold is that no build reaches them. The seed stdenv's unpack phase, which the package set's stdenv runs too, removes the files a derivation's `unusedPrebuilt` names, and both stdenvs' `mkDerivation` set it from the list for `src`. A listed file the archive does not hold fails the build, so the list cannot go stale unnoticed. The Stdenv ladder job runs `nova-nix trust --json` over GNU Hello and fails on any input a build runs that is not the seed or a reproduction of it, any prebuilt file the list does not name, and any file the list names that the report does not find. Every rung's store path changes. (#762)- **`pkgs/windows` builds GNU Bash 5.3 with GNU's twenty official patches, as `bash`, with the package set's stdenv, for x86_64 Windows on msvcrt alone, with no Cygwin or MSYS2 runtime, and CI's new Bash stage, after Stdenv on its handoff, checks it on x64 and ARM64.** nixpkgs' generic stdenv runs `setup.sh` under bash and setup.sh needs bash 5, so a from-source Windows stdenv for nixpkgs needs a bash built on the ladder. Windows has no fork, and bash forks for every child, so the port, in `pkgs/windows/by-name/ba/bash`, starts a program as a new process where bash would fork and exec one: the shell makes the program's redirections its own while it starts it, with CreateProcess, giving it exactly the descriptors a forked child would keep, close-on-exec and append mode included, through the table msvcrt passes a child and a list of the handles it inherits, then undoes them. A `#!` script runs its interpreter, which bash starts itself, as Windows reads no `#!` line (configure's check passes only because busybox-w32's `sh` reads it, so bash is told the system does not), a script with no `#!` line runs in a new bash, and `exec` and `bash -c` stand in for the program they would exec by waiting for it and exiting with its status. Subshells, command substitution, pipelines and background jobs, which need a copy of the shell, fail with `fork: Function not implemented` for now. A script's `PATH` keeps what it writes; the command search and a program's environment split it at `;` and at a `:` that does not end a drive letter, as busybox-w32 does, so a `PATH` of `C:\...` directories joined with `:` works, and a program finds it joined with `;`; in each directory the search takes `NAME.exe` where `NAME` is no program. `/dev/null`, `/dev/tty` and `/dev/fd/N` open as Windows names them, and a program's exit status reads back as POSIX's, an access violation as SIGSEGV. bash's malloc casts pointers to `long`, which is 32 bits on Windows, and now casts them to `intptr_t`; `builtins/psize.c` stops counting at a failed write where no SIGPIPE comes; and four of bash's files that assumed `st_blocks`, `TIOCGWINSZ`, networking or a header another one includes now build without them. GNU publishes the patches as context diffs, which busybox's `patch` does not read, so each is rewritten as the unified diff it is before it applies; the result is the tree GNU's `patch -p0` makes of them. The checks have bash run, as a build's builder, a script of functions, indexed and associative arrays, `local -n` and `shopt -s inherit_errexit`, and a program and two `#!` scripts, one whose interpreter is bash and one whose interpreter is another program, found on such a `PATH`, with their arguments, redirections and exit statuses. (#769)### Dependencies- **A tree on disk that cannot be read is still reported as `error: ` and the failure, now that nova-cache raises a walk's failure as `NarWalkError`.** nova-cache from 0.13 raises a walk's failure to read an entry as `NarWalkError`, which names the access and the entry, where 0.12 raised the bare `IOException`, so the command line's report of an I/O failure no command handled, and the checks that read an unreadable tree as a mismatch or as nothing there, would have let it through to GHC's uncaught-exception report. The command line reports it as it reports an I/O failure, naming the access that failed (`/d/tree/sub: listing directory: permission denied (Permission denied)`), a failed push names it the same way, and both checks catch it. `NarWalkError` arrived in nova-cache 0.13; the floor is 0.14, for the change below. (#561)- **nova-nix builds against nova-cache 0.14, and a NAR it reads, a cache's included, is refused as upstream refuses it when it holds a keyword over 32 bytes, an entry name over 255, a symlink target over 4095, a symlink target that is empty or holds NUL, or a node 64 directories deep, and a tree it archives is refused with `path '<path>' exceeds maximum NAR directory depth of 64` when it holds an entry that deep.** nova-cache 0.14 holds its parser to the limits upstream's `parseDump` applies at 2.36.0, refusing a string past its limit from its length prefix, before the bytes it declares are read, and holds its walk to the depth at which upstream's `dumpPath` refuses an entry, before the entry's status is read. The parser accepted structural strings of up to 64 KiB in a streamed NAR, of any length in one held whole, and checked neither targets nor depth, so a substitution could unpack an archive upstream's restore refuses, and a source path, a build output or a pushed path nested that deep was archived where upstream refuses to dump it. A walk still archives a name or a target past its limit, as upstream's dump does, which a Windows name of up to 255 UTF-16 units can reach, and that archive does not parse, as upstream's does not. The floor on nova-cache rises to 0.14, whose `NarStep` carries the result `NarDone` finishes with. (#759)## 0.10.0.0 - 2026-11-04On Windows, CI builds the start of a toolchain from source as derivations on x64 and ARM64: stage0-pe32's chain from a 1,623-byte seed up to kaem, mescc-tools-extra's programs, and GNU Mes 0.27.1. A build tries a derivation's outputs before its inputs, as upstream does, so a package a cache holds no longer pulls in what it was built from, and a cache that fails stops the build unless `--fallback` is given.### Library APIBreaking changes for code that uses nova-nix as a library:- **`Nix.Eval.Types.MonadEval` has a new method with no default, `qualifyPath`, and `Nix.Store.Path.storeTextToFilePath` puts a rooted path with no drive on the store's drive.** Every instance defined outside this package needs the method; one with no filesystem answers `pure`, as `PureEval` does. The new `Nix.Store.Path.qualifyPathText` gives a rooted path with no drive, other than one under `/nix/store`, the store directory's drive, and leaves every other path, and every path when the store directory has no drive, as it is. `Nix.Eval.Policy.uriAccess` takes the `StoreDir` first, `Nix.Eval.Policy` exports `fileUrlPrefix`, and `Nix.Eval` exports `localFileUrl` and `gitRemote`. (#363)- **`Nix.Parser.parseNix` and `parseNixWithScope` take a `SourceOrigin` and the source's bytes, where they took its name and its decoded `Text`:** `parseNix :: FilePath -> SourceOrigin -> ByteString -> Either SourceError Expr`. They read a UTF-8 or UTF-16 byte order mark themselves, so a caller passes what `Data.ByteString.readFile` returns, and `Nix.Parser.readFileAutoEncoding` is removed. `SourceOrigin` (`SourceFile` or `SourceText`) and `sourceName` are new in `Nix.Expr.Types`, and `Nix.Parser` re-exports the type. `Nix.Parser.Lexer.tokenize` takes a `ByteString`, and the new `positionAfter` gives the line and column `tokenize` reaches at the end of a source. `Nix.Parser.Internal.ParseState` holds `psOrigin` where it held `psFile`, `currentPos` is new, and `pMany` is removed. (#361, #368, #372)- **The AST records where each binding was written, and its string pieces are bytes.** `Nix.Expr.Types.NamedBinding` and `Inherit` carry the new `SrcPos` they were parsed at, and `InheritFrom` holds `InheritedName`s, each with its own. `StrLit` and `StrEsc`, and the lexer's `TokStringLit` and `TokStringEsc`, hold a `ByteString` where they held `Text`, and `EPathStr` holds its head piece as `Text` ahead of its other parts. (#361, #368)- **Attribute positions reach the bytecode and the C attribute set.** `Nix.Eval.Compile`'s `BcNamed`, `BcInherit` and `BcInheritedName` carry a `PosIdx`, `Nix.Eval.CAttrSet.cattrsetInsert` takes the entry's `PosIdx`, and `cattrsetGetPos` reads it back. The new module `Nix.Eval.SourcePos` records positions (`PosIdx`, `noPos`, `PosRecorder`, `newPosRecorder`, `recordPos`) and reads them back (`RecordedPos`, `lookupPos`), and `Nix.Eval.Types` exports `AttrEntry`, `attrSetLookupEntry` and `attrSetFromEntries`. (#361)- **`Nix.Eval.Types.NixValue`'s `VBuiltin` holds `[BuiltinArg]` where it held `[NixValue]`, and `Nix.Eval.BuiltinDef` gives a builtin's argument modes where it gave its arity.** `BuiltinArg` is `ArgForced` or `ArgDeferred`. `bdArgs :: NonEmpty ArgMode` (`ForceOnApply` or `ForceOnUse`) replaces `bdArity`, and `bdApply` takes `[BuiltinArg]`. `Nix.Eval` exports both types, and `Nix.Eval.Types` exports `BuiltinArg`. (#351)- **`Nix.Hash`'s `makeStorePath`, `makeTextPath`, `makeFixedOutputPath` and `makeOutputPath` return `Either BadStorePath StorePath`, where they returned `Either StorePathNameError StorePath`.** The new `Nix.Store.Path.BadStorePath` holds the hash part the path would have had (`bspHashPart`) and why its name is refused (`bspNameError`), and `badStorePathText` renders upstream's message. `Nix.Eval.Types.storePathOrThrow` takes no context argument. (#345)- **`Nix.Builder.buildDerivation` takes the derivation's `.drv` path after the derivation, and `BuildConfig` has two new strict fields, `bcFallback :: Fallback` and `bcBuildLog :: Handle`.** `defaultBuildConfig` sets them to `NoFallback` and stderr; code that builds a `BuildConfig` with the constructor needs both. A builder that exits unsuccessfully gives `BuildFailure "builder failed" code`, its output written to `bcBuildLog` rather than into the message. (#346, #349, #353)- **`Nix.Config.NixConfig` has two new strict fields, `ncFallback` and `ncTraceVerbose`, and `Nix.Eval.Policy.EvalPolicy` one, `epTraceVerbose`.** `defaultNixConfig` and `unrestrictedPolicy` leave them off, as upstream's defaults are; code that builds either record with the constructor needs them. (#346, #348)- **The new module `Nix.Realise` decides, root first, what a build substitutes and what it builds.** `substituteClosure` runs over the effects in `SubstEffects`, whose `seReferences` answers an `Offer` and `seFetch` a `FetchOutcome`, and returns a `ClosureOutcome`. `realise` takes a `Fallback` and the effects in `RealiseEffects`, whose `reBuild` takes the `.drv` path after the derivation, and returns `Either RealiseFailure ()`, which `realiseFailureMessage` renders. `Nix.Builder` exports `substitutePaths`, which returns a `FetchOutcome`, and `Nix.Substituter` exports `queryReferencesWith`, which takes a `Fallback` and returns an `Offer`. `Nix.Substituter.narInfoPreflight` is removed, and `NarInfoAnswer` and `judgeNarInfo` are added. `Fallback` (`NoFallback` or `BuildFromSource`), which `BuildConfig`'s `bcFallback` holds, and `Realised` (`AlreadyValid`, `Substituted` or `Built`), which `reReport` receives, are also new in `Nix.Realise`. (#331, #346)- **`Nix.Store.scanTempReferences` is removed, and `rewriteStoreHashes` and `rewriteBytes` are added.** `scanReferences` also scans entry names. (#328)- **The new module `Nix.Builder.Log` holds the build log's line discipline (`PendingLine`, `emptyPendingLine`, `feedBuildLog`, `endBuildLog`), its terminal filter (`EscapeFilter`, `filterLogLine`) and the streaming around them (`openLogPipe`, `streamBuildLog`).** (#349)- **`Nix.Builder` exports `AttrsDelivery` and `attrsDelivery`, how a derivation's attributes reach its builder; `closureUnder`, the closure of a list of roots under a references lookup in any monad; and `orderByReferences` with `ReferenceCycle`, the ordering of outputs by the siblings they reference.** (#333, #343, #353)### CLI- **An I/O failure no command handles prints `error:` and its message and exits 1, as upstream's commands do, where it printed GHC's `Uncaught exception` report with a backtrace.** The store's refusal of an unregistered reference, for one, printed `nova-nix: Uncaught exception ghc-internal:GHC.Internal.IO.Exception.IOException:`, its message inside `user error (...)`, and a `HasCallStack backtrace`. Upstream's `handleExceptions` (libmain/shared.cc at 2.24.9) logs an error after `error:` and exits with its status, 1 unless the error sets another, and the CLI now does the same for an `IOException`, which sets none: a `userError` prints its message, and any other also names the operation and the file that failed. A failed build still prints behind nova-nix's own prefixes (#397). (#395)### Evaluation- **`builtins.nixVersion` is `"2.24.9"`, where it was `"2.24.0"`.** Upstream reports the version of the Nix evaluating the expression (`nixVersion` in `globals.cc` at 2.24.9), and 2.24.9 is the release whose source nova-nix's parity work cites, so an expression that branches on the value takes the branch it takes there. `nova-nix --version` still names nova-nix's own release. (#344)- **Ten builtins force an argument at the point upstream's primop forces it, so `map (throw "a") [ ]` is `[ ]`, and when two arguments throw, the error is the one upstream reports.** A builtin's arguments were forced as they were applied, left to right, so `map`, `filter`, `sort`, `mapAttrs` and `elem` failed on an empty collection whose function or needle throws, where upstream succeeds, and with both arguments throwing the first one's error was reported where upstream reports the second's. Upstream's `prim_map`, `prim_filter` and `prim_sort` force the list and return an empty one before they force the function; `prim_mapAttrs` never forces the function itself, so `mapAttrs (throw "a") { x = 1; }` has the attribute `x`; `prim_elem` forces the needle only to compare it with an element; `prim_elemAt` and `prim_genList` force their second argument first; `prim_foldlStrict` hands its initial accumulator to the first step unforced and forces it itself only for an empty list; and `prim_filterSource` and `scopedImport` coerce the path before they force the filter or the scope (primops.cc at 2.24.9). Each of these builtins now takes that argument unforced and forces it at the same point, in a partial application too, so `builtins.typeOf (map (throw "a"))` is `"lambda"`. A function argument forced there is checked as upstream's `forceFunction` checks it, so `builtins.length (map 1 [ 1 ])` fails with `expected a function but found an integer: 1`, where it returned 1. Their other arguments are still forced as they are applied, where upstream forces nothing before a primop has all its arguments, so a partial application such as `builtins.foldl' (throw "a")` still fails when forced. (#351)- **`builtins.traceVerbose` returns its second argument without forcing or printing its first, unless `trace-verbose` is on, set by `--trace-verbose` on `eval` and `build`, or by `trace-verbose` in nix.conf or `NIX_CONFIG`.** It was `builtins.trace` under another name, so every call forced its first argument and printed it to stderr, and `builtins.traceVerbose (throw "a") 1` failed where upstream gives `1`. Upstream binds the name to `prim_second` by default and to `prim_trace` under the setting (`primops.cc` at 2.24.9), and both are matched: without the setting `traceVerbose` never forces its first argument, applied directly, through a partial application or by a higher-order builtin, and with it `traceVerbose` forces and prints its first argument as `builtins.trace` does before it forces its second. Like `--restrict-eval` and `--pure-eval`, the flag only turns the setting on; upstream also derives a `--no-trace-verbose` from the setting, which nova-nix does not have. (#348)- **A store path refused for its name is refused in upstream's words, naming the path it would have had.** `builtins.toFile "a b" "x"` fails with `path 'dm85kbl5cy82j2dzvy1874s14y3salv3-a b' is not a valid store path: name 'a b' contains illegal character ' '`, as on Nix 2.24.9. It failed with a message of nova-nix's own behind a `builtins.toFile:` prefix. Upstream refuses the name where it builds the path, once the hash exists (the `StorePath` constructor in `path.cc` at 2.24.9), and names the builtin only in its trace. nova-nix's path constructors now refuse it the same way, so the same text comes from `builtins.path`, `builtins.filterSource`, a path copied to the store by interpolation, and a derivation whose name fits but whose `.drv` name or `<name>-<output>` name does not. A source copy hashes its tree before refusing its name, as upstream's does, since the hash part is the tree's. A `builtins.path` with `sha256` is refused under the pinned hash before the tree is read, as upstream's `addPath` builds the pinned path first. Of two outputs past the length cap, the one refused is the first by name, as upstream builds the paths over its sorted output set. (#345)- **On Windows a path with a root but no drive, such as `/probe/f.txt`, names that path on the store's drive, whatever drive is current.** It resolved against the current drive, so with `C:\probe\f.txt` in place `builtins.pathExists "/probe/f.txt"` was `true` from `C:\` and `false` from `D:\`, and one value named different files depending on where the evaluator ran. The drive is now fixed by configuration: `C:` for the default `C:\nix\store`, or the drive of the directory `--store` names. The value keeps its spelling, so `toString /probe/f.txt` is still `"/probe/f.txt"`, and a `/nix/store` path resolves through the store directory as before, not through the store drive's `\nix\store`. The rule holds at every place a path reaches the filesystem: `readFile`, `pathExists`, `readDir`, `readFileType`, `hashFile`, `import`, `scopedImport`, search path lookups, copies into the store, and the local paths `fetchurl`, `fetchTarball` and `fetchGit` hand to curl and git, which receive the drive as `file://C:/...` or `C:/...`. Under `--restrict-eval` and `--pure-eval` the check uses the same drive as the read, so a search path root given without a drive admits the drive-qualified spelling of the same files, and the reverse. A path that names a drive, and every path on macOS and Linux, behaves as before. Upstream still resolves such a path against the current drive; NixOS/nix issue 16412 is open on that design. (#363)- **`builtins.unsafeGetAttrPos` gives the position an attribute was defined at, `{ column; file; line; }` for one defined in a file, where it gave `null` for every attribute.** Upstream answers with `EvalState::mkPos` of the attribute's position (`prim_unsafeGetAttrPos`, primops.cc at 2.24.9), and its positions are matched: a binding is at the first token of its attribute path, every level of a dotted `a.b.c = v;` at the path's, and an inherited name at the name, as upstream's parser records them (parser.y, parser-state.hh); a binding merged into an earlier path keeps its own position and the path its first; `//`, `removeAttrs` and `intersectAttrs` keep the positions of the attributes they copy, `listToAttrs` gives each attribute the position of its element's `value` attribute, and every other set a builtin makes, `mapAttrs`'s included, has none. A missing attribute, one with no position and one defined in an `--expr` argument give `null`, as upstream's do for text with no file behind it. The name is checked before the set is forced, as upstream's `forceStringNoCtx` of it runs first. nixpkgs reads the position for `meta.position`. A derivation's own attributes report the lines of the `derivation` wrapper in `/derivation-internal.nix`, which differ from upstream's. Columns count characters where upstream's count bytes, so they differ on a line with non-ASCII text before the attribute; they follow the lexer, whose parse errors count the same way. The `file` of a file outside the store is the path the import read, with every symlink on the way to it resolved, where upstream keeps the path as written and follows only a symlink at its end (`resolveExprPath`, eval.cc), so the two differ for a file reached through a symlinked directory. `builtins.functionArgs` gives its attributes no position, where upstream gives each formal's. (#361)- **A string literal in a file evaluates to the bytes written in it, so bytes that are not UTF-8 reach the eval string as they are, where they became U+FFFD.** A source was decoded to text before lexing, and what was not UTF-8 was replaced. Upstream reads a file's bytes (`SourcePath::readFile` at 2.24.9) and its flex scanner lexes them (lexer.l), so a literal's value is its source bytes with escapes resolved, and the lexer here now reads bytes too. Upstream drops a double-quoted literal's bytes from a NUL to its next interpolation or its closing quote (`unescapeStr` stops at the NUL, lexer.l), where nova-nix keeps them. The lexer's token classes are upstream's, all ASCII: a letter outside ASCII, such as U+00E9, starts no identifier and continues none, so a name holding one is a syntax error, as it is upstream; a byte outside ASCII ends a path, a search path or a URI; and whitespace is space, tab, carriage return and newline, so a vertical tab, a form feed or a space outside ASCII such as U+00A0 is a syntax error. A comment may hold bytes that are not UTF-8. Columns still count characters where upstream's count bytes, a byte that continues a UTF-8 sequence taking its character's column, and a newline escaped in an indented string (`''\` before it) now ends a line for the positions after it. A string used as an attribute name (`{ "x" = 1; }`, `inherit "x";`) must be UTF-8, since attribute names are text here: one that is not is a syntax error at its string, where upstream makes a symbol of any bytes (the `attrpath` and `attrs` rules, parser.y). A key after a dot in an attribute path that fails to parse is reported at the key, where the error blamed the dot. An `--expr` argument is still decoded as text before it is lexed, which #370 tracks. (#368)- **A source opening with a UTF-16 byte order mark is transcoded to UTF-8 before it is lexed, and malformed UTF-16 is a syntax error at the bad code unit, rather than being replaced.** An unpaired surrogate or an odd final byte has no UTF-8 spelling, and replacing it changed the source. Upstream reads no byte order mark (`EvalState::parseExprFromFile`, eval.cc at 2.24.9): no rule of its scanner but the catch-all takes a mark's first byte, and the grammar refuses the token that rule returns, so a file marked UTF-16 or UTF-8 fails to parse there. nova-nix reads a UTF-16 mark in either byte order, for the Windows tools that write one, and drops a UTF-8 mark as before. (#368)- **A carriage return ends a line, as in upstream: a `#` comment ends at the first CR or LF, and an LF, a CRLF and a bare CR each end one line in every position the lexer reports.** A comment ran to the next LF, so in a file with bare CR line endings it swallowed the code after it, and positions ended a line at a bare CR only where a double-quoted string reads it as an LF, so parse errors put what followed any other bare CR on the wrong line. Upstream's line comment is `\#[^\r\n]*` (lexer.l at 2.24.9) and its position table splits a source at an LF, a CRLF or a bare CR (`Pos::LinesIterator`, position.cc), and both now hold here for whitespace, comments, both kinds of string, their escapes, and the position of a malformed UTF-16 source's error. A string's value is unchanged: a double-quoted string still reads a raw CR or CRLF as an LF, and an indented string keeps its CRs. A syntax error at the end of input after a trailing line comment stands past the comment, at the end of input as upstream reports it (`yyerror`, parser.y), where it stood at the `#`. (#372)- **`derivation` is a lambda written for nova-nix, and `NOTICE` lists the material nova-nix carries from other projects.** `derivation` evaluated upstream's `src/libexpr/primops/derivation.nix` expression (LGPL-2.1). The replacement gives the same result as upstream's for every argument wherever nova-nix's evaluator agrees with upstream's: the same attributes and values, `derivationStrict` reached only through `drvPath` and `outPath`, the same step failing first for each malformed `outputs`, and the arguments' own values in the result, which `==` shows for a function argument. The parity job probes it against upstream's `nix-instantiate` over a corpus of arguments in `test/data/derivation-probes.txt`, with the rows where the evaluator is known to differ from upstream listed in `test/data/derivation-divergences.txt`, and the test suite pins what the probes read. `NOTICE` names what nova-nix carries from nixpkgs, with its license: `pkgs/windows/mirrors.nix`, copied from it, and the Mes package's `package.nix`, `libc.nix` and `nyacc.nix`, adapted from its minimal-bootstrap. The new wrapper's identifiers are interned at startup in place of upstream's, as upstream interns its own wrapper's, so an error that names attributes in interning order can name a different attribute from upstream's: a call with the unexpected arguments `zzz` and `x`, written in that order in a file, named `x`, as upstream does, and now names `zzz` (#378). (#373, #393)### Store- **A registration that references a path the store has not registered is refused with upstream's message, `path '/nix/store/...' is not valid`, naming the path under `/nix/store` wherever the store is kept.** The refusal read `registerPaths: <referrer> references unregistered path <reference>`, with both paths spelled under the store's own directory, so on Windows or under `--store` it named `C:\nix\store\...` or the relocated directory. Upstream refuses the reference in `registerValidPaths` through `queryValidPathId` (local-store.cc at 2.24.9, and the same at 2.34.9 and 2.35.4), which names it with `printStorePath`. That spells a path under the logical store directory, which stays `/nix/store` for a store whose files live elsewhere (`realStoreDir`, local-fs-store.hh). Of several unregistered references the one named is the one upstream names, as the batch and each path's references are walked in path order. A build meets the refusal when a derivation or a `builtins.toFile` text carries string context naming a store path this store has not registered, as `builtins.appendContext` and `builtins.storePath` can give it. A cache that declares references looping between paths meets it too, and there it fails the substitution as any failed substitute does, so the build stops unless `--fallback` is given. Upstream's evaluation refuses such a context earlier, when `ensurePath` cannot substitute the path; among its own commands, `nix-store --register-validity` and `nix-store --import` reach it. (#388)### Builder- **An output that records an already-valid sibling now builds, with the sibling's real path in its bytes.** A rebuild of a partly valid derivation writes the valid output to a scratch path, and an output that recorded that path used to fail the build, because the scratch tree is discarded. Upstream rewrites the scratch hash to the final one in the output (`rewriteOutput` at 2.24.9) and the build succeeds. The hash is now rewritten across file contents, symlink targets and entry names, so the output names its sibling and records the reference. Upstream scans and then rewrites; nova-nix rewrites and then scans, which finds the same references with no translation. Upstream's rewrite runs over a serialized NAR, so a rename that changes a directory's sort order fails there, depending on the hash values, and succeeds here. Reference scanning also now covers entry names, as upstream's scan of the NAR does, so a hash held only in a file name records its reference. (#328)- **A build records a reference to any path in its inputs' closure that an output embeds, not only to its direct inputs.** Reference scanning looked for the input sources, the input derivations' outputs and their `.drv` files, so an output embedding a path an input only references, such as a library the input propagates, registered without that reference. A garbage collection could then delete a path a live output still used, and a pushed closure could lack it. Upstream scans for its `inputPaths`, the closures of the requested input outputs and of the input sources under their registered references (`derivation-goal.cc` at 2.24.9), plus the derivation's own outputs (`referenceablePaths` in `local-derivation-goal.cc`), and the scan now uses that set. An input derivation's `.drv` is not in it, so an output that embeds one no longer records it, as upstream's does not; a `.drv` an input source's closure reaches, as one a `drvPath`'s context brings in, is still recorded. (#333)- **An attribute named in `passAsFile` reaches the builder as a file in the build directory, named by `<name>Path`, rather than as a variable, as upstream passes it.** The builder put every attribute in the environment, so a builder that reads only the file failed: the minimal bootstrap's `writeTextFile` in nixpkgs runs `cp ${textPath} ${target}` with no fallback. Builders that fall back to the variable, as stdenv's `genericBuild` and `writeTextFile` do, got the value through the environment, subject to the size limit `passAsFile` exists to avoid, and an attribute holding bytes that are not UTF-8 failed the build although it never needed to be text. Upstream (`initTmpDir`, local-derivation-goal.cc at 2.24.9) splits `passAsFile` at spaces, tabs, newlines and carriage returns, writes each attribute it names to `.attr-` followed by the Nix base-32 SHA-256 of the attribute's name, sets `<name>Path` to that file and leaves the attribute itself out of the environment. A name with no attribute is ignored, an attribute literally called `<name>Path` keeps its own value, and a structured-attributes derivation ignores `passAsFile`. nova-nix now does each of these, and its file name for `foo` is the one upstream's own test pins. The file holds the bytes the variable would have held, store paths and placeholders rewritten and every other byte as the derivation has it, and an output passed this way holds the path the build writes it to. On Windows the variable joins the build directory and the file name with a backslash, as `NIX_BUILD_TOP` is spelled, where upstream writes `/`. (#343)- **A builder's standard output reaches the build log with its standard error, in the order the builder wrote them, and `build` prints each line on stderr as it completes.** Standard output was discarded, and standard error was held until the builder exited and then shown only inside a failure message. Upstream hands the builder one channel for both, its standard output a copy of its standard error (`commonChildInit`, child.cc at 2.24.9), and its default logger prints every build-log line to stderr as it arrives (`SimpleLogger`, logging.cc). `nix-build` keeps that logger, so it shows the whole log while the build runs and adds no `log-lines` tail to the failure (derivation-goal.cc). A failed builder's `BuildFailure` message is now `builder failed`, with its output in the log rather than the message. Lines follow upstream's discipline (`DerivationGoal::handleChildOutput`): a carriage return returns to the start of the line, so a Windows program's CRLF ends a line without its CR and a progress counter redrawn after CRs leaves its last state, and an unterminated last line is flushed when the output ends. Upstream's channel is a pseudoterminal and this one is a pipe, which `System.Process` offers on Windows as well as POSIX, so a program that line-buffers or colours its output only on a terminal block-buffers and stays plain here. On POSIX both ends of the pipe are close-on-exec, so the builder holds it only as its standard output and standard error, as upstream's child does after `closeMostFDs`, and a daemon that closes those lets the build finish. Each line is filtered as upstream's logger filters it (`filterANSIEscapes`, terminal.cc): a tab becomes spaces to the next multiple of eight columns, a bell is dropped, and an escape sequence is dropped, except that colour (an SGR sequence) is kept on a terminal whose `TERM` is set and not `dumb` with neither `NO_COLOR` nor `NOCOLOR` set (`isTTY`), so a builder cannot move the cursor, clear the screen or set the title of the terminal running the build. A line that cannot be written to stderr is dropped and the build goes on, as upstream's `writeToStderr` ignores a failing write, so a closed reader of stderr does not fail the build. Upstream reads a line beginning `@nix ` as a JSON log message and does not print one that parses (`handleJSONLogMessage`); here every line is printed, and since nova-nix sets no `NIX_LOG_FD`, where upstream sets it to 2, nixpkgs' stdenv writes no such lines, and its `nixErrorLog` family writes nothing. Upstream also keeps the log in a file that `nix log` reads back (`keep-build-log`); nova-nix keeps none. (#349)- **A build whose outputs reference each other in a cycle fails with upstream's message, `cycle detected in build of '/nix/store/...-foo.drv' in the references of output 'dev' from output 'out'`, and registers none of them.** Both outputs used to register, each naming the other, which left a reference cycle that upstream's own registration refuses (`registerValidPaths`, local-store.cc at 2.24.9) and a pair of paths neither of which could be deleted alone, since each had a referrer. Upstream scans every output first, orders the outputs so that each follows the siblings it references, and fails the build on a cycle before any output is registered (`registerOutputs`, local-derivation-goal.cc, and `topoSort`, topo-sort.hh). The ordering here is upstream's depth-first walk, so the outputs are placed in upstream's order and a cycle is reported through the same two outputs upstream names. A self-reference and a one-way reference between outputs still build. An output registered before the build, as in a partial rebuild, counts as referencing nothing, as upstream counts it, so a rebuilt output may reference it whatever its discarded copy references. The CLI prints the message after its own `build failed (exit 1): building <name> failed: exit 1: ` prefix, where upstream prints `error: ` (#397). (#353)- **`builtin:unpack` reads `.tar.gz` archives, a format GitHub serves a commit's tree in.** It read `.tar.zst` and plain `.tar`, which covers MSYS2's packages, and GitHub's archive endpoint offers only gzip and zip, so a repository pinned at a commit could not be unpacked before a tool to unpack it existed. The decompressor is still chosen by the archive's name. A corrupt or truncated stream fails the build with the decoder's message, as a corrupt zstd frame does. The pax global header `git archive` writes first, which carries the commit id, is skipped like any other. (#347)### Substitution- **`build` with a substituter tries a derivation's outputs before its inputs, and a substituted path arrives with its runtime closure.** Dependencies used to be walked leaves first, so every build-time input was fetched or built before the root's own outputs were tried: `pkgsCross.mingwW64.hello`, one 0.19 MB path on cache.nixos.org, was still fetching at its 270th path after 90 seconds, and now takes one substitution and no builds. Upstream tries outputs first (`DerivationGoal::haveDerivation` at 2.24.9) and only then falls back to inputs, so a derivation the cache holds no longer realises its inputs. A narinfo's references are realised before the path that names them, as upstream's `PathSubstitutionGoal` does, after the narinfo passes the same identity and signature checks as a substitution, so the store stays closed under references. A reference no cache holds leaves that substitution incomplete, so the inputs are realised and the substitution is retried once, matching upstream's `retrySubstitution`; if the hole remains, the derivation builds. (#331)- **A cache that fails now stops the build, as upstream's does, and `--fallback` or the `fallback` setting builds from source instead.** A failed substitution was treated like a path the cache lacks, so a 503 that outlived its retries, a NAR that did not verify, a compression nova-nix cannot decode or a narinfo that would not parse sent the build on from source, and with outputs tried before inputs one transient failure on a root started its whole input tree. Upstream tells the two apart (`substitution-goal.cc` and `derivation-goal.cc` at 2.24.9). A NAR a cache offers and fails to deliver, once every cache has been tried, fails the derivation with upstream's message, `some substitutes for the outputs of derivation '...' failed (usually happens due to networking issues); try '--fallback' to build derivation from source`, and exit status 1; the CLI prints it after its own `build failed (exit 1): ` prefix (#397). The `.drv` is named under `/nix/store` wherever the store's files live, on Windows and under `--store` too, as upstream's `printStorePath` prints a relocated store's logical directory. A narinfo query that fails stops the build with that failure before a later cache is asked, as upstream rethrows it. Under `--fallback`, or `fallback = true` (alias `build-fallback`) in nix.conf, a failed query is reported and the next cache asked, and a failed substitute is reported and the derivation builds. A cache without the narinfo, a narinfo for another path or one no trusted key signed, and a NAR the cache answers with 401, 403, 404, 407 or 410, the statuses upstream reads as the file being absent, are passed over as before, so what no cache holds still builds with no flag. Upstream also disables a failing cache for 60 seconds under `fallback`; here each path asks it again. (#346, #355)- **A substitution takes its output locks in the same order as a build, so the two cannot deadlock.** A multi-output substitution locked its outputs in the derivation's order and held each until the batch registered, while a build locks them in store path order. Two processes working on the same derivation could each hold the lock the other was waiting for, and the blocking lock has no timeout, so both would hang. Both now take their locks through one ordering. (#323)### Windows packages- **`pkgs/windows` builds stage0-pe32's chain as derivations, from a 1,623-byte seed to hex0, hex1, hex2, catm, M0, cc_x86, M2-Planet, M1, hex2-new and kaem.** The Windows stdenv starts from prebuilt MSYS2 and MinGW-w64 packages, and this is the first part of a path that starts from source instead. Each derivation is one command of stage0-pe32's `x86/mescc-tools-mini.cmd`, its builder the link that command runs and its output the one file the command writes, the shape nixpkgs gives stage0-posix's chain in `minimal-bootstrap/stage0-posix/mescc-tools-boot.nix`. Each link is `stage0-pe32.<name>`, with M2-Planet as `M2` and kaem as `kaem-unwrapped`. The links are 32-bit PE, so each step is an `i686-windows` derivation, which x64 Windows runs through WoW64 and ARM64 Windows through its x86 emulator. Nothing in the chain runs `cmd.exe` or a shell, and nothing comes from the MSYS2 seed: its only inputs are the seed, fetched on its own, and stage0-pe32 at ff1c2ad with the M2-Planet, M2libc and mescc-tools commits it pins, each repository fetched as GitHub's archive with `builtin:fetchurl` and unpacked with `builtin:unpack`. hex0 is fixed-output to the seed's own hash, as nixpkgs' is, so a seed that does not reproduce itself fails the build. CI builds the chain on x64 and ARM64 Windows, with the x64 nova-nix on both, and checks each link against the SHA-256 stage0-pe32's own CI prints for the same commit. (#347, #354)- **`pkgs/windows` builds mescc-tools-extra's thirteen programs from stage0-pe32's links, as `stage0-pe32.mescc-tools-extra.<name>`: sha256sum, match, mkdir, untar, ungz, unbz2, unxz, catm, cp, chmod, rm, replace and wrap.** nixpkgs builds them with M2-Mesoplanet in `minimal-bootstrap/stage0-posix/mescc-tools-extra/build.kaem`, and M2-Mesoplanet has no Windows target. Here one function in the stage0-pe32 package set turns a program's name, sources and C library files into the five steps stage0-pe32's `x86/mescc-tools-mini.cmd` gives kaem: M2-Planet with `-D __windows__=1`, catm, M0, catm and the hand-written hex2, each its own `i686-windows` derivation. M2-Planet skips every `#include` line unless given `--expand-includes`, which the .cmd does not pass, so each program's M2libc files are what its `#include` lines reach on the M2libc fork's `x86/windows` target, listed in the package. hex2-new and `kaem-unwrapped` are built by the same function. The sources are upstream's mescc-tools-extra at d1d8146, the commit stage0-pe32 pins. CI builds all thirteen on x64 and ARM64 Windows and runs each, checking its output against committed fixtures or bytes the job writes. On Windows, untar stops at a symlink unless given `--non-strict`, because M2libc's Windows `symlink` always fails; chmod sets only the executable bit; `mkdir -p` and cp's copy into a directory split paths on `/` only; replace needs `--output`, because its default `/dev/stdout` does not exist; and wrap stops at its first mount, which M2libc's Windows `mount` always refuses. (#350, #354, #365)- **`pkgs/windows`' stage0-pe32 installs kaem, mescc-tools and mescc-tools-extra as bin directories, and gives kaem nixpkgs' `runCommand`, with `writeText` beside it.** nixpkgs builds Mes and the stages after it up to bash 2.05b as scripts run by kaem's `runCommand` (`minimal-bootstrap/stage0-posix/kaem/default.nix`), which call their tools by name, and each link of stage0-pe32's chain is a single `.exe` file with no `bin/`. `stage0-pe32.kaem`, `mescc-tools` and `mescc-tools-extra` hold kaem, M2-Planet (the `M2` link), M1, hex2 (from `hex2-new`) and mescc-tools-extra's thirteen programs at `bin/<name>.exe`, and keep each program as an attribute, so `stage0-pe32.mescc-tools-extra.<name>` names the program itself; the single-file kaem is `stage0-pe32.kaem-unwrapped`, as nixpkgs names it. kaem lays each directory out itself with mescc-tools-extra's mkdir, cp and chmod, as nixpkgs installs its kaem, so nothing runs but the chain's own programs. `kaem.runCommand name env buildCommand` runs the script with `kaem --verbose --strict`, so the first command that fails fails the build. Its PATH is the three bin directories joined with `;`, which kaem splits PATH on under Windows, and kaem tries each bare name as given and then with `.exe`. `writeText name text` passes the text through `passAsFile`, as nixpkgs' does, since kaem refuses an environment entry of 4,096 bytes or more. Two things in `runCommand` differ from nixpkgs'. A store path in a script is spelled from `${NIX_STORE}`, because the builder spells the store `C:\nix\store` and kaem reads a backslash in a script as an escape, so `C:\nix` would reach a command as `C:`, a newline and `ix`, while kaem substitutes a variable's value as it stands. And `env` reaches the derivation as it stands, without nixpkgs' handling of `nativeBuildInputs`, `meta` and `passthru`, which nothing here passes. mescc-tools-extra's Windows limits apply to these scripts: cp is given the file it writes, not a directory, since it takes a destination that does not begin with `/` as relative; `mkdir -p` makes only the parents a path names before a `/`, and exits 0 even when it fails, as rm does. CI builds the bin directories on x64 and ARM64 Windows, checks each file against the program it was copied from, runs a script that calls mkdir, cp and catm by bare name, and checks that a script whose command fails fails its build. (#359)- **On Windows a file that a program built on `pkgs/windows`' stage0 tools marks executable with `chmod` is executable in its NAR, as on Linux, and the bin directories of those tools mark their programs.** nova-nix keeps a regular file's executable bit on Windows as an NTFS alternate data stream, `<file>:nova.exec`, and only `builtin:unpack`, NAR restores, store copies and `builtins.fetchGit` ever wrote one, so nothing a builder made was executable: a program built on Windows had a NAR hash different from the same output's built elsewhere, and a copy substituted from a Windows build was not executable. `pkgs/windows`' stage0-pe32 builds on its M2libc fork at 13e57eb, whose Windows `chmod` creates the stream when the owner execute bit is set and removes it when that bit is clear, the bit upstream's NAR serialisation reads (`S_IXUSR`), so a builder marks a program as it would on POSIX, and hex2-new's own `chmod(output_file, 0750)` marks what it links. The same M2libc's Windows `malloc` rounds each block's start and size to 8 bytes, the alignment Windows' own gives on x86, since Windows fails a file call whose name's buffer is at an odd address, and an unaligned heap left `chmod` failing silently in any program whose data ends at an odd byte, mescc-tools-extra's `chmod` among them. `stage0-pe32.kaem`, `mescc-tools` and `mescc-tools-extra` follow each `cp` with `chmod 555`, as nixpkgs' kaem and mescc-tools do. The single-file links stay unmarked: the seed writes hex0, hex0 writes hex1 and hex1 writes hex2, and hex0 has to stay byte-identical to the seed; the hand-written hex2 links the rest, and none of them calls chmod. A file a builder creates with M2libc's `open` and an execute mode is still not marked, since that `open` ignores its mode (#383), and neither is one marked with MSYS2's `chmod`, which writes no stream; MSYS2 is to be replaced by the source bootstrap (#26). CI checks on x64 and ARM64 Windows that every program in the bin directories carries the stream, and builds a fixed-output script whose declared hash is its tree's NAR hash on POSIX, with the file `chmod 555` marked executable and the one `chmod 755` and then `chmod 644` left plain. (#365)- **On Windows a program built on `pkgs/windows`' stage0 tools can open a file to read while another holds it open to write, as on POSIX.** Every program from M0 up, mescc-tools-extra's included, carries one routine that opens a file, the `open_file` in stage0-pe32's `x86/ntdll-i386.hex2`, and M2libc's `open` and `fopen` reach it. Windows refuses an open whose sharing does not admit the access an earlier open already holds, where POSIX does not refuse an open because another process has the file open to read or write, so at ff1c2ad, the commit `pkgs/windows` pins, the routine shares a file for reading, writing and deletion. GNU Mes keeps each file it writes open until it exits, and MesCC runs M1 on the assembly it has just written, which M1 could not open if the routine shared for reading alone. hex0, hex1, hex2 and catm carry their own copies, which share a file for reading alone. (#374)- **`pkgs/windows` builds GNU Mes 0.27.1 on the Windows stage0 tools: `mes.srcPost` (with mes-m2.exe), `mes.libs` (the Mes C library compiled by MesCC), `mes.compiler` (mes.exe compiled by MesCC) and `mes.libc` (the library's sources for TinyCC).** They are nixpkgs' `minimal-bootstrap/mes` derivations, each an `i686-windows` `kaem.runCommand` script on stage0-pe32's bin directories, built from the Novavero-AI/mes fork at d9ab4ea, which ports Mes 0.27.1 to Windows and carries nixpkgs' i686 C library fixes as commits. NYACC is nixpkgs' 1.09.1, fetched from the `mirror://savannah` sites in the mirror list copied from nixpkgs. Five things differ from nixpkgs. The paths Mes reads from the environment, `MES_PREFIX`, `GUILE_LOAD_PATH` and MesCC's `M1` and `HEX2`, stay there, set by every derivation that runs Mes and given to callers as `mes.env`, where nixpkgs writes them into Mes's C and Scheme source: the builder spells a store path `C:\nix\store/...`, and the backslash would start an escape in a string of either language. Mes's arena is 20,000,000 cells, set in the environment as well, since nixpkgs' 100,000,000 with its stack is more than the 1 GiB the Windows port reserves for all of Mes's memory; the cells Mes keeps across a collection have to fit in the tenth past the arena, and CI measures them while MesCC compiles libc+tcc, the largest library. MesCC is given `--base-address 0x400000`, the ImageBase of the port's PE header, where it links at Linux's 0x1000000 by default, and starts a program from a crt1 assembled from the port's M1 startup, which splits the command line Windows hands a program into argc and argv. `mes.libc` holds `crt1.c` alone of the startup files and has no `include` link: lib/windows has no `crti.c` or `crtn.c`, and nixpkgs makes the link with `ln-boot`, which needs a `symlink` the Windows Mes C library does not have. And `mes.libc` carries no `CFLAGS`, where nixpkgs' passes `-std=c11` through `passthru`. CI builds all of it on x64 and ARM64 Windows from the seed, runs mes-m2 and mes with `--version`, and runs a program MesCC compiled with mes, checking what it prints and the status it exits with. (#371, #385)- **On Windows a file that a program built on Mes libc marks executable, with `chmod` or by creating it with `open` and a mode that has the owner execute bit, is executable in its NAR, as on Linux.** nova-nix keeps a regular file's executable bit on Windows as the `<file>:nova.exec` stream, and Windows has no such bit for a C library to set, so a Mes libc that accepted a mode and ignored it would leave plain whatever a program linked with it marked executable, a compiler's output among them, and that output's NAR hash would differ from the same output's built elsewhere. `pkgs/windows`' Mes builds from the Novavero-AI/mes fork at d9ab4ea, whose Windows `chmod` creates the stream when the mode has the owner execute bit (`S_IXUSR`), the bit upstream's NAR serialisation reads, and removes it when that bit is clear, as the stage0 tools' M2libc `chmod` does. Its `open` marks a file it creates when the mode has that bit, since Linux applies the mode only to a file `open` creates. Mes libc keeps no umask on Windows, so `open` uses the mode as given; upstream runs its builders under umask 022 (`initNix`), which never clears the owner execute bit, so the bit comes out the same. CI on x64 and ARM64 Windows builds a fixed-output derivation in which a program MesCC compiles and links against `mes.libs` creates one file with `open` and mode 0755, one with 0644, and one with 0644 that it then `chmod`s to 0755, and whose declared hash is that tree's NAR hash on POSIX with the first and third executable. (#385)### Distribution- **Every export has Haddock, and no reference in the Hackage documentation is out of scope or ambiguous.** Haddock was built only when a release was uploaded, so five exports had no documentation and 72 references named no identifier or more than one, rendering as plain text or as links to anchors that do not exist. Every module's coverage is 100%; a reference is qualified, given its namespace, or set as code when nothing exports it; and the Linux build runs Haddock on every change and fails on a gap. (#319, #396)- **The README's links resolve on Hackage.** Hackage renders a relative link as `/package/<file>`, so the README's links to LICENSE, NOTICE and CONTRIBUTING.md returned 404 there. They point to the files on GitHub, and the Linux build fails on a relative README link or a README command `--help` does not list. (#392)### Dependencies- **The `nova-cache` bound admits 0.12, at `>= 0.11.1.1 && < 0.13` in the library and the test suite.** 0.12.0.0's major version marks a change to its server, which nova-nix does not use, and no module nova-nix imports changes beyond its comments, so the floor stays. (#322)- **The library depends on `zlib >= 0.7 && < 0.8`, for `builtin:unpack`'s gzip decoder.** 0.7 is the first release whose `Codec.Compression.GZip` exports `DecompressError`, the error a corrupt stream throws. zlib was already in the build through http-client's dependency on streaming-commons. (#347)- **The test suite adds `mtl >= 2.2 && < 2.4` and `zlib >= 0.7 && < 0.8`.** (#331, #347)## 0.9.0.0 - 2026-10-31On nixpkgs 26.05 and unstable, where 0.8.0.0 failed, CI now holds 22 derivations to the store paths upstream computes, on Nix 2.34.9 and 2.35.4 respectively, alongside Nix 2.24.9 with nixpkgs 24.11.### Library APIBreaking changes for code that uses nova-nix as a library:- **`Nix.Expr.Types.Binding`'s `NamedBinding` holds one `AttrKey` where it held an `AttrPath`,** as upstream's `ExprAttrs` holds one name per definition (nixexpr.hh at 2.24.9). The parser already hoisted `a.b.c = v;` into nested sets before evaluation; it now does so as it parses, so no binding carries a path. `Nix.Eval.Compile.BcNamed` holds one `BcAttrKey`, and a named binding's bytecode drops its path-length word. `Nix.Eval.CStatus.CStatusError` includes `CInvariantViolated`, raised through `cInvariantViolated`. In `Nix.Eval.CThunk`, `cthunkNull :: CThunkPtr` and `cthunkBool :: Bool -> CThunkPtr` replace `cthunkNewComputedNull` and `cthunkNewComputedBool`, and the `cthunkSetComputed` setters and `cthunkSetPayload` return `Bool`, whether the thunk took the value, where the setters returned the pending payload. `Nix.Eval.CAttrSet.cattrsetNew` takes the expected entry count as an `Int`, and it, `cattrsetInsert`, `cattrsetUnion`, `cattrsetRemoveKeys` and `Nix.Eval.CList.clistNew` raise `CStatusError` when the C side refuses. (#19)- **`formatXmlFloat` moved to `Nix.Eval.Print` from `Nix.Eval.StringInterp`, which now prints the value its coercion failure names.** `Nix.Eval.Operator.evalBinary` no longer evaluates `OpAdd`, which its caller handles as it handles the short-circuit operators, because `+` looks at its left operand before the right is evaluated and coerces through the evaluator; `Nix.Eval.Operator` exports `addToInteger` and `addToFloat`, the arithmetic once the left operand is a number. `Nix.Eval.Types` exports `thunkUnderEvaluation`, whether a thunk is being forced, and `typeName` returns upstream's `showType` names. (#250)- **`Nix.Hash.compressHash` takes and returns a `ByteString`,** the digest it folds and the bytes it folds it to, where both were `[Word8]`. (#48)- **`Nix.Config` resolves configuration through a file-reading effect, so includes and the file cascade are testable against an in-memory map.** `loadConfig` reads, expands and folds a weakest-first path list plus the `NIX_CONFIG` bytes over a `ReadConfigFile m` (`OsPath -> m (Either ConfigReadFailure ByteString)`, the failure saying whether the file is missing or merely unreadable, which decides how a failed `include` is reported); `expandConfigSource` splices one `ConfigSource`'s includes; `parseConfigLines` replaces `parseConfigText` and yields `ConfigLine`, an assignment or an `IncludeMode` include; and `ConfigLocations` with `configFilePaths` computes upstream's file order from the raw environment and the platform's directories, which the caller supplies so the module carries no platform literal, refusing a relative `NIX_CONF_DIR` as upstream does. `resolveConfig` now folds a flat `[ConfigAssignment]`, failing only on a value a setting cannot take, and `applyConfigText` is gone, since a source's text cannot be applied without the files it includes. (#199)- **`Nix.Config` carries a source as bytes and its paths as `OsPath`.** `ConfigSource` holds an `OsPath` name and `ByteString` text, `ReadConfigFile m` is `OsPath -> m (Either ConfigReadFailure ByteString)`, `loadConfig` takes `[OsPath]` and the `NIX_CONFIG` bytes, and `configFilePaths` returns `[OsPath]`. `ConfigLocations` takes `NIX_CONF_DIR` and `NIX_USER_CONF_FILES` as the bytes `Nix.Environment.lookupEnvBytes` returns and its directories as `OsPath`. `ConfigLine`'s include target and `ConfigAssignment`'s name and value are `ByteString`, `parseConfigLines` takes an `OsPath` and a `ByteString`, `parseUnsignedSetting` takes `ByteString`s, and `nixConfFileName`, `nixConfDirName` and `nixConfigSourceName` are `OsPath`. The new module `Nix.HostPath` spells bytes as a host path (`hostPathFromBytes`), the spelling `Nix.Store.EntryName` now uses too, and shows one in a message (`hostPathText`). The executable's `filepath` and `directory` floors rise to 1.4.100 and 1.3.8, the first with `System.OsPath` and `System.Directory.OsPath`, as the library's did, and it depends on `file-io` >= 0.1.1 to read a file by its `OsPath`, 0.1.1 being the first whose read does not create a missing file on Windows. (#244)- **`Nix.Eval.Types.MonadEval` has a new method with no default, `addErrorTrace`, and `Nix.Eval.IO`'s `NixEvalError` and `NixAbortError` carry an `EvalFailure`, a message with its lines of context, where they carried the message alone.** Every instance defined outside this package needs the method. `runEvalIO` still returns the message; the new `runEvalIOTraced` returns the whole `EvalFailure`, and `renderEvalFailure` writes it as upstream reports an error. (#221)- **`Nix.Eval.Types.NixValue` drops `VDerivation`.** The constructor existed only to carry the build recipe through the derivation value's private `_derivation` attribute, which no longer exists; nothing constructed it any more and no Nix operation could observe one. Exhaustive matches over `NixValue` lose a case. The recipe a build needs is the `.drv` ATerm the evaluator records under its path during evaluation (`Nix.Eval.IO.EvalState`'s `esDrvClosure`, or `lookupSessionDrv` inside the evaluator), which is what the build driver and the test harness now read. (#217) `Nix.Eval` now exports `deferApply`, the shared thunk that applies one value to another when forced; the derivation wrapper's fallback uses it, and library code that built the same synthetic thunk by hand can too. (#230)- **`Nix.Eval.Types.MonadEval`'s `getEnvVar` takes the bytes of a variable's name and returns the bytes of its value,** `ByteString` both ways where it was `Text`, so every instance defined outside this package changes with it. `Nix.Builtins.parseNixPath`, `splitNixPath` and `isNixPathPseudoUrl` take a `ByteString` and `searchPathRoots` returns them, since a `NIX_PATH` entry is bytes. The new module `Nix.Environment` reads one variable as bytes (`lookupEnvBytes`, answering an `EnvLookup`). Outside Windows the read goes through `unix`'s `System.Posix.Env.ByteString`. (#241)- **`Nix.Eval.Print` exports `printAmbiguous`, the `ByteString` `Builder` for what `nova-nix eval` prints,** after upstream's printer of the same name. (#259)- **`Nix.Eval.CList` exports `clistIndex` and `clistDrop`,** a bounds-checked read of one element and the list without its first elements, which shares the source's C array through the C layer's new `nn_list_drop`. (#263)- **`Nix.DependencyGraph.buildDepGraph` reads each `.drv` in the caller's monad,** `(Monad m) => (StorePath -> m (Either Text Derivation)) -> Derivation -> StorePath -> m (Either Text DepGraph)`, where it took a pure reader. The build driver passes a read in `IO`, which replaces the `unsafePerformIO` read the pure signature forced on it; a pure lookup runs under `Data.Functor.Identity`. (#251)- **`Nix.Eval.Types.MonadEval` has a new method with no default, `withCallFrame`, and `Nix.Eval.IO.EvalState` a new strict field, `esCallDepth`.** Every instance defined outside this package needs the method; `newEvalState` fills the field with upstream's default ceiling, and a caller with a configured one replaces it. The new module `Nix.Eval.CallDepth` holds the counter type, the default and the entry rule. `Nix.Eval.CBytecode` exports the `OpApp` flag values `appDirect` and `appDeferred`. `Nix.Config.NixConfig` gains `ncMaxCallDepth`, `Nix.Config.applyAssignment` now returns `Either Text NixConfig` because a scalar setting's value can fail to parse, and `Nix.Config.parseUnsignedSetting` is exported. (#222)- **`Nix.Store.EntryName` decides which NAR entry names and symlink targets a host can hold, replacing `Nix.Store.isSafeNarName`.** `NameRules` (`PosixNames`, `DarwinNames`, `WindowsNames`), `hostNameRules`, and the pure `checkEntryName` and `checkLinkTarget` answer for any platform on any platform; `entryNamePath` and `linkTargetPath` spell an admitted name or target as the running host's `OsPath`, and `shownBytes` renders one in a refusal. `onDiskNameKey` and `caseHackDiskNames` take the `ByteString` names a NAR carries instead of `Text`, `orderLinks` orders `(OsPath, OsPath)` pairs, and `Nix.Store.ExecBit` gains `markExecutableOsPath`. The library's floors rise to directory >= 1.3.8 and filepath >= 1.4.100, the first releases with the `OsPath` APIs it now calls, and the test suite's filepath floor with it. (#84)- **`Nix.Eval.Types.MonadEval` has three new methods with no defaults,** `evalPolicy`, `checkUri` and `resolveSymlinks`, and `doesPathExist` takes a `PathExistence` first argument (`ExistsAsEntry` or `ExistsAsDirectory`, the two questions `builtins.pathExists` asks); every instance defined outside this package needs them. The new module `Nix.Eval.Policy` holds the policy record (`EvalPolicy`, `unrestrictedPolicy`) and the pure decisions behind the modes (`isAllowedPath`, `isAllowedUri`, `uriAccess` and their messages), and `Nix.Eval.Types` re-exports the record. `Nix.Builtins.builtinEnv` and `builtinEnvWithScope` take an `EvalPolicy` first argument, since the impure constants exist by policy; `Nix.Builtins.searchPathRoots` reads the roots back from a search path, and `isNixPathPseudoUrl` says which entries name a download. `Nix.Eval.IO.EvalState` gains `esPolicy` and `esAllowedPaths`, with `allowEvalPath` to seed the allowed roots. `Nix.Eval` exports `FetchGitArgs (..)` and `gitInputUrl`, the URL form a `fetchGit` input is checked and reported in. `Nix.Config.NixConfig` gains `ncAllowedUris`, `ncRestrictEval` and `ncPureEval`. (#75)- **`Nix.Eval.Types.mkSyntheticThunk` takes the bytecode index of the code it runs instead of an `Expr`, and every bytecode store opens with five reserved instructions.** A caller compiles once (`Nix.Eval.Compile.compileExpr`) and passes the index, rather than having the code compiled again for each thunk. `Nix.Eval.CBytecode` exports `reservedApply1` and `reservedApply2`, the deferred applications of an env's slots a store starts with, so a fresh store's `cbcOpCount` is 5 and the first instruction compiled lands at index 5. `Nix.Eval.Compile.BcInheritFrom` carries a `BcInheritedName` per name, its symbol and the bc_idx of the select that reads it, where it carried the symbols alone, and the `inherit (from)` encoding stores that select after each symbol. (#269)- **`Nix.Parser.parseNix` returns `Either SourceError Expr`, and a plain `inherit` is a binding of its own in the AST.** `SourceError` is `SyntaxError ParseError`, the failure it returned before, or `UndefinedVariable Text`, a variable binding found unbound. `parseNix` binds against the root environment's names under the default policy; `parseNixWithScope` binds against the names given, which for evaluation under a policy are `Nix.Builtins.rootScopeNames`, plus a `scopedImport` scope's. `Nix.Expr.Resolve.resolveVars` takes those names and returns `Either Text Expr`; `staticGlobalNames` is now upstream's whole base environment, `impureOnlyGlobalNames` the part `pure-eval` drops, and `undefinedVariableMessage` upstream's wording for the failure. `Nix.Expr.Types.Binding`'s `Inherit (Maybe Expr) [Text]` becomes `Inherit Text Expr`, one per name and holding the variable it copies, and `InheritFrom Expr [Text]`; every match on `Binding` outside this package must cover both. In the bytecode, `Nix.Eval.Compile.BcInherit` carries a symbol and the variable's bc_idx instead of a list of symbols, and `Nix.Eval.CBytecode.bindInheritFrom` is the tag of an `inherit (from)` binding, whose encoding no longer carries a has-from word. (#248)- **`Nix.Store.Store` has a new strict field, `stGcLease`, `openStore` keys the handle by the directory's canonical spelling, and the store modules grow a garbage-collection surface.** Code that builds a `Store` with the constructor needs the field; `openStore` fills it, and `stDir` is now `canonicalStoreDir` of what was passed. `Nix.Store.GC` is new (`collectGarbage`, which returns `Either` with the refusal of a database keyed under another spelling of the directory, `findRoots`, `addOutLinkRoot`, the pure `reachableFrom`, `referencesMap` and `sweepPlan` with its `SweepPlan`, the abstract `LiveSet` with `withLiveSet` and `isLive`, `GcRoot`, `GcResults`, `gcSummaryLine`, `showFreedBytes`, the roots directory names), as are `Nix.Store.Handle` (`Store`, `openStore`, `closeStore`, `canonicalStoreDir`, `withCollectorLock`, `gcLockFilePath`) and `Nix.Store.Symlink` (`WalkNode`, `classifyWalkNode`, `createSymlinkOfKind`); `Nix.Store` re-exports the first two. `Nix.Store.Lock` adds `LockMode`, `acquireLockFileWith`, `withLockFileWith`, `waitingForLockMessage` and `lockedPathOf`; `Nix.Store.Path` adds `parseStorePathPrefix`, upstream's `toStorePath`; `Nix.Store.DB` adds `queryAllReferences` and the batch `unregisterPathRows`. `deleteStorePathRaw` now takes the collector lock and refuses a path reachable from a root before its referrer check, and `deleteStorePathChecked` is the same delete given a `LiveSet` from `withLiveSet`, for a batch under one lock. (#24)- **The new module `Nix.Json` holds the JSON value type (`Json`), its rendering as upstream's serializer writes it (`renderJson`, `renderJsonWith`) and a parser that reads JSON as upstream's does (`parseJson`); `formatJsonFloat` moved there from `Nix.Eval.StringInterp`.** The new module `Nix.Derivation.StructuredAttrs` holds the `__json` entry's key, its encoding and decoding, and what a builder makes of it (`withOutputPlaceholders`, `renderAttrsJson`, `renderAttrsShell`, `stringsAttr`). (#36)- **`Nix.Substituter.httpStatusFailure` is gone, and the transfer layer's retry policy and failure classification live in `Nix.Http`.** `fetchStatusFailure`, which takes the URL and the response's `Status`, replaces it. `Nix.Http` exports `AttemptFailure (..)`, `attemptFailureMessage` and `catchSync`, which `Nix.Substituter` still re-exports; the retry policy (`FetchRetryPolicy (..)`, `defaultFetchRetryPolicy`, `RetryEffects (..)`, `ioRetryEffects`, `retryTransient`, `retryDelayMs`); and the classification (`TransferError (..)` and `statusError`, upstream's verdict on a status, `withTransfer` and `transferBodyReader`, which raise every failure of the connection as an `HttpException`, `transferFailureHandlers`, `fetchStatusFailure`, `fetchExceptionFailure`, which takes an `HttpException` rather than any exception, and `fetchWriteFailure`, for an `IOException` writing a download). `Nix.Substituter.trySubstituteWith` substitutes under a given policy and effects; `trySubstitute` is it at upstream's default, and a build passes its `bcFetchRetry`. (#243)- **`Nix.Substituter` gains `VerifiedNar`, the only input its strict unpack sink accepts, and stops re-exporting `unpackNarEntry`.** `unpackAndVerify` checked the downloaded bytes against the narinfo's signed NarHash and NarSize before deserializing and writing them, but the bytes had the same `ByteString` type on both sides of the check, so only statement order kept unverified bytes away from the disk writes, and the module's re-export of `unpackNarEntry` offered an unpack that skipped the check altogether. `verifyNar` is now the sole way to obtain a `VerifiedNar` (its constructor is not exported), a module-private sink is the only consumer of one, and `unpackAndVerify` is their composition, so the order is a type the compiler enforces. The wrapper carries the decoded declared digest rather than standing as a bare witness: the registration records its canonical spelling and the on-disk recheck compares against it, where the recheck used to parse the narinfo's NarHash a second time, and the strict recheck now compares a digest exactly as the streaming one does. `unpackNarEntry` stays in `Nix.Store`, which is where its eval-side caller (`builtins.path`, unpacking a NAR this process just serialized) imports it from; the substituter reaches it only through that sink. Upstream has no such type: `LocalStore::addToStore` (local-store.cc at 2.24.9) restores the path through a `TeeSource` over a `HashSink` and compares hash and size after the restore, the order the streaming pipeline mirrors with its cleanup contract; the strict path verifies first, and the wrapper makes that first step unskippable. (#226)- **`Nix.Expr.Types.StringPart` has a new constructor, `StrEsc`, and `Nix.Eval.StringInterp.stripIndentedChunks` takes a list of the new `StringChunk` type.** An indented-string escape (`'''`, `''$`, `''\n`) was parsed as a constant interpolation, which made it indistinguishable from `${"..."}` by the time indentation was stripped, and upstream strips the two differently. `StrEsc` carries the resolved text as a part of its own, so exhaustive matches over `StringPart` need the case. `StringChunk` (`ChunkLit`, `ChunkEsc`, `ChunkInterp` with its context) replaces the `(Bool, ByteString, StringContext)` triple so an evaluated part keeps its kind, and `concatChunks` joins chunks without stripping, as a double-quoted string does. (#227)- **The new module `Nix.Eval.Print` exports `printValue`, upstream's value printer, under `PrintInFull` or `PrintForError`.** `Nix.Eval.Operator` exports `evalUpdate`, which takes each operand as an action so the left is checked before the right is evaluated. (#247)- **`unpackNarEntry`, `newNarUnpackSink`, `caseHackDiskNames`, `onDiskNameKey` and `Nix.Substituter.consumeNarStream` take a `CaseSensitivity` first argument, and `Store` has a new strict field,** `stCaseSensitivity :: CaseSensitivity`. The argument is the destination volume's answer: a caller unpacking into a `Store` passes the field, and one unpacking elsewhere says what kind of volume it writes to instead of inheriting the operating system's default. `Nix.Store.CaseSensitive` exports the type, re-exported from `Nix.Store`, and `probeCaseSensitivity`. (#68)- **`Nix.Store.ExecBit.serialiseFromPath`, `withNarSource` and `narHashOfPath` take a `NovaCache.NAR.CaseHack` first argument, and `Nix.Store.CaseSensitive` exports `volumeCaseHack` and `processCaseHack`,** re-exported from `Nix.Store`. A store path is read with `volumeCaseHack (stCaseSensitivity store)`, and a source with `processCaseHack`, nova-cache's per-OS default. (#236)- **`Nix.Store` exports `sinkNarStream` and `NarStreamFailure`, the streaming unpack loop the substituter and the source restore share, and `Nix.Store.ExecBit` exports `withNarSource`.** (#235)- **Further API changes:** `MonadEval` has a new method with no default, `lookupSessionReferences`. `Nix.Parser.parseNixFile` returns `Either SourceError Expr`. The new module `Nix.Eval.SourceError` holds upstream's messages for a failed read of a source path (`SourceAccess`, `sourceErrorMessage`). `Nix.Eval.Operator` stops exporting `checkedAdd`, `checkedSub` and `checkedMul`. `Nix.Derivation.Platform` gains `I686_Linux` and `I686_Windows`, and `Nix.Builder.BuildConfig` gains `bcFetchRetry`.### CLI- **`eval` prints its result as `nix-instantiate --eval` does: a string as its bytes, escaped as upstream escapes it, an attribute name quoted when it is not an identifier, a float to six significant digits, and upstream's markers for an unforced element and a function.** A string is bytes, and the printer decoded it as UTF-8 with replacement before writing it, so `builtins.readFile` of a file holding `a`, the byte 0xFC and `b` printed the three bytes of U+FFFD in the middle, where `nix-instantiate --eval` prints the byte itself and `builtins.stringLength` of the same value is 3. The result now reaches stdout as bytes, with no decode, encoding or newline translation on the way, so on Windows the line ends in LF, as `--aterm` output already did, where it ended in CRLF. The rules are upstream's `printAmbiguous` (print-ambiguous.cc at 2.24.9). A string goes through `printLiteralString` (print.cc): `"` and `\` take a backslash, a newline, carriage return and tab print as `\n`, `\r` and `\t`, and a `$` followed by `{` prints as `\$`, the escape that was missing, so `"\${"` printed as `"${"`, which reads back as an interpolation. An attribute name goes through `printIdentifier`: bare when the lexer reads it back as an identifier and quoted otherwise, so `{ "a b" = 1; "if" = 2; }` prints as written instead of as `{ a b = 1; if = 2; }`. A float is written to a default ostream, so `1.0` prints as `1`, `1.23456789` as `1.23457` and `1234567.0` as `1.23457e+06`, where Haskell's `show` gave `1.0`, `1.23456789` and `1234567.0`. An unforced element prints as `<CODE>` and a function as `<LAMBDA>`, `<PRIMOP>` or `<PRIMOP-APP>`, where nova-nix wrote `<thunk>`, `<lambda>` and `<builtin NAME>`. Every case was compared byte for byte with nix-instantiate 2.33.2. A list or set reached twice under `--strict` still prints in full where upstream writes its `repeated` marker, which needs value identity this printer does not track. (#252)- **An interrupted command reports `error: interrupted by the user` and exits 1.** A SIGINT reached the CLI's main thread as GHC's `UserInterrupt`, which, uncaught, ended the process by the signal (exit 130) with nothing printed. Upstream's `checkInterrupt` throws `Interrupted("interrupted by the user")`, which `handleExceptions` (libmain/shared.cc at 2.24.9) logs as an error and exits 1 with; the CLI now does the same, and every other asynchronous exception still propagates. (#287)- **`push --all` selects every valid output path, and a named derivation is refused with the reason.** A store registers its derivations as valid paths like anything else, so `--all` sent them too, and a binary cache serves build outputs only: nova-cache refuses a narinfo for a `.drv` outright, after the path's NAR has already been uploaded. Derivations are recipes a substituter never asks a cache for, so they stay local, and naming one explicitly is refused before anything is uploaded. (#216)- **`--restrict-eval` and `--pure-eval` on `eval` and `build`, and `restrict-eval`, `pure-eval` and `allowed-uris` in nix.conf and NIX_CONFIG.** Evaluation ran with the process's full ambient authority: any expression could read any file, reach the environment, and fetch from the network. The two flags turn on upstream's modes for one run, and the three settings turn them on for a machine, through the same cascade as `substituters` (a Boolean takes upstream's `true`, `yes`, `1`, `false`, `no`, `0` spellings and any other value is an error; `extra-allowed-uris` appends, and `extra-` on a Boolean names no setting). A flag only turns a mode on, so a machine configured for pure evaluation stays pure whatever the command line says. Under either mode every `--nix-path` and `NIX_PATH` root is allowed, as upstream allows its lookup path, so `--restrict-eval --nix-path nixpkgs=...` evaluates nixpkgs and computes the same `hello.drvPath` as the default mode and as `nix-instantiate --option restrict-eval true`. A root reached through a symlinked directory (macOS's `/tmp` is `/private/tmp`) is allowed under its resolved spelling as well; upstream allows only the given one and refuses the read, a mismatch between its own allow list and its symlink walk rather than a rule. A `channel:`, `flake:` or URL entry names a download this evaluator does not perform and allows nothing; upstream allows such an entry's working-directory spelling only by falling through after a failed download, and a run that cannot fetch should not read more for it. Under `--pure-eval` neither `--nix-path` nor `NIX_PATH` contributes, as upstream drops its lookup path; the bundled `<nix/*>` directory remains, since upstream serves those files from a built-in filesystem and this binary serves them from its data directory, which is why it stays listed in `builtins.nixPath` where upstream shows an empty list. (#75)- **`nova-nix store gc` collects garbage, `build --out-link PATH` (or `-o PATH`) roots a result, and `store delete` refuses a path a root keeps alive.** `store gc` finds the roots, walks their references, removes every other valid path with its tree, sweeps every store directory entry that is not live (a tree no row describes from a build interrupted before registration, junk, a dead path's lock file) and prints upstream's progress lines on stderr and its summary (`N store paths deleted, X MiB freed`, the `%.2f MiB` of 2.24.9) on stdout; `store gc --print-roots` lists `LINK -> PATH` sorted, each link once, and deletes nothing, as `nix-store --gc --print-roots` does, and like it takes no collector lock, so it does not wait behind a running build. `build --out-link PATH` is nix-build's `-o`: the path is made absolute with `.` and `..` collapsed and its parent directories are created, as upstream's `addPermRoot` and `makeSymlink` do, then `PATH` is created as a symlink to the result and registered as a root, refusing a link inside the store (through `..` as well) or an existing `PATH` that is not a store link (a store link is replaced); the store path prints only once the link exists, so a failed link (Windows without Developer Mode) prints nothing a script would take for success. `build` creates no link unless `--out-link` is given, where nix-build and nix build default to `./result`. `store delete` of a path a root reaches is refused with upstream's words, `Cannot delete path '...' since it is still alive`, and the referrer refusal it already had stays. Upstream refuses a path with an unrooted referrer with the same still-alive line unless that referrer is named in the same invocation, in which case it deletes the named set referrer-first; this delete lists the referrers that stand in the way instead and deletes in argument order, so a chain deletes leaf-first. One invocation resolves every argument first, then runs under one collector lock with one live set, printing upstream's roots line once. The hint names `store gc --print-roots` rather than the `nix-store --query` forms this tool does not have. `--store DIR` is keyed by its canonical spelling (absolute, `.` and `..` collapsed, no trailing separator), as upstream's `absPath` keys a store path, so a store built under one spelling and collected under another is the same store; `store gc` and `store delete` refuse a store whose database holds paths under another spelling of its directory rather than sweep them as dead. (#24)- **nix.conf `include` and `!include` directives are honored, and the system file and the full XDG cascade are read, in upstream's order.** An include splices the named file in at its line, resolved against the directory of the file being parsed with `.` and `..` collapsed lexically, so a nested include resolves against the nested file and an include from `NIX_CONFIG` must be absolute; `!include` goes on without a file that cannot be read, and `include` of a missing file fails with upstream's own `file '...' included from '...' not found`. The sources are now, weakest first: `$NIX_CONF_DIR/nix.conf` (default `/etc/nix`, an empty variable counting as unset, a relative one refused with upstream's `not an absolute path`, and `.` and `..` in it collapsed, as upstream's settings constructor canonicalizes it); the user files, which are `$NIX_USER_CONF_FILES` when it is set (first listed strongest, an empty value naming no files, empty entries dropped) and otherwise `nix/nix.conf` under the XDG config home and then under each `XDG_CONFIG_DIRS` entry, applied back to front so the config home wins; then `NIX_CONFIG`; then the flags. Every rule was read from `config.cc` and `globals.cc` at 2.24.9 and checked against the running 2.33.2 binary. Two deliberate differences: an `include` whose file exists but cannot be read is an error here (`file '...' included from '...' cannot be read`) where upstream silently drops it (its own TODO questions the swallow), because the only thing `include` promises over `!include` is to fail when the file is unusable, and an include is where a site narrows the substituter or trusted-key set, so dropping it leaves the wider set in force; and an include cycle is refused with a message naming both files where upstream recurses until it crashes. On Windows, where upstream compiles the same `/etc/nix` and `/etc/xdg` literals in and neither names anything, the system file is `%ProgramData%\nix\nix.conf`, the all-users application data directory being the Windows convention for machine-wide application configuration (chosen the way `%APPDATA%` was for the user file, and where the `directory` package maps the system-wide XDG dirs too), with no system file when `%ProgramData%` is unset; `XDG_CONFIG_DIRS` has no default there, since the one directory that answers to it is already read as the system file; `NIX_CONF_DIR` and `XDG_CONFIG_DIRS` are honored when set on every platform; a UNC `NIX_CONF_DIR` keeps its server through the collapse; and `NIX_USER_CONF_FILES` splits on `;` there, since upstream's `:` cannot carry a drive letter. (#199)- **nix.conf is read as bytes, so an `include` target, `NIX_CONF_DIR` and `NIX_CONFIG` name the files and carry the values upstream's do.** A config file went through a lossy UTF-8 decode and the config variables through base's `lookupEnv` and a conversion to text, so a byte with no UTF-8 reading became U+FFFD, written back as EF BF BD when a file was opened: `include caf\xE9.conf`, a Latin-1 name on Linux, never opened the file it names (a required include failed as not found, an `!include` was dropped), a `NIX_CONF_DIR` holding such a byte named a system file that does not exist, so its settings silently did not apply, and an include beside a user file under such a directory (`NIX_USER_CONF_FILES`, `XDG_CONFIG_HOME`, `XDG_CONFIG_DIRS`) missed in the same way. Upstream keeps each line as bytes and opens the file the target's bytes name (`parseConfigFiles` in `src/libutil/config.cc` at Nix 2.24.9), reading the variables with `getenv`. A source now stays bytes until a setting takes a value from it: the variables are read as bytes, an include target and every config directory reach the open as a host path spelled from those bytes, and a comment or the value of a setting nova-nix does not model is never decoded. A line splits on upstream's separators alone (space, tab, CR, LF): every Unicode space split it before, so `pure-eval = true` followed by a no-break space read as true where upstream refuses the value, and an `allowed-uris` token holding a vertical tab or a form feed became two. A Boolean or integer value is compared as bytes, so such a byte there is upstream's own invalid-value error. Two differences remain. First, a `substituters`, `trusted-public-keys` or `allowed-uris` token with no UTF-8 reading is refused (`setting 'substituters' has invalid value '...': not valid UTF-8`) where upstream keeps the bytes, because each is text everywhere nova-nix uses it (a cache URL, a key matched against a narinfo's signatures, a URI prefix matched against the evaluator's URIs), and the U+FFFD spelling it silently took before names a different cache, key or URI. Second, a message still shows such a byte as U+FFFD where upstream writes the byte itself. On Windows, where a path is UTF-16, a target with no UTF-8 reading names no file, so `include` refuses it and `!include` goes on without it, and a config variable holding an unpaired surrogate is refused, as `NIX_PATH` holding one is. Checked against `nix config show` and `nix-instantiate` 2.33.2, the include case on an HFS+ volume, since APFS refuses such a name. (#244)- **`NIX_PATH` keeps a `channel:` or `flake:` entry whole and splits an unlisted `scheme://` entry, as upstream's parser does.** A colon stayed inside its entry whenever `//` followed it, so `channel:nixos-24.11` broke into `channel` and `nixos-24.11` while `foo://x` was kept as one entry. Upstream's `EvalSettings::parseNixPath` (`src/libexpr/eval-settings.cc` at Nix 2.24.9) decides at an entry's first colon from the text after the entry's last `=`: `channel` and `flake` keep the entry whole whatever follows, `http`, `https`, `file`, `channel`, `git`, `s3` and `ssh` keep it whole when `//` follows, and the entry then extends through exactly one more colon-free run, so `https://example.com:8080/x` still splits after the host and `channel:channel:x` is `channel:channel` then `x`. The split now follows that rule, matched entry by entry against `builtins.nixPath` from `nix-instantiate` 2.33.2, whose parser is unchanged from 2.24.9. An empty entry is dropped, as upstream's `builtins.nixPath` drops it; it was not inert here, since `<name>` resolved against the filesystem root through it (`NIX_PATH=a::b` made `<etc>` resolve to `/etc`). An entry containing a space is kept whole where upstream's settings round trip would split it, since a Windows path may contain one. The Windows drive rule stays: `C:\x` and `nixpkgs=C:/x` are one entry each, where upstream, which has no drive rule, splits a drive path at its letter. Neither a URL nor a channel entry is fetched yet, so for those entries this changes what `builtins.nixPath` reports, not what `<nixpkgs>` resolves to. (#224)### Evaluation- **A derivation with `__structuredAttrs = true` passes its attributes as one JSON object, `__json`, and its drvPath matches upstream's.** Such a derivation was flattened like any other, every attribute coerced to a string, so a nested set or a list of sets failed with `cannot coerce a set to a string`, and nixpkgs packages that set the flag (libxo, sudo, cppitertools, nrr and lutok among them) did not evaluate. Upstream's derivationStrict (the `jsonObject` branch of `derivationStrictInternal`, primops.cc at 2.24.9) converts each attribute with the `printValueAsJSON` behind `builtins.toJSON` and stores the object, rendered by nlohmann's `dump()`, as the single environment entry `__json` beside one entry per output. `args` stays the argument list, `__structuredAttrs` and `__ignoreNulls` stay out of the object, and a null is left out only under `__ignoreNulls`. String context inside the object, a path copied to the store or a derivation's output, becomes the derivation's inputs as it does from the environment. In this mode upstream reads the builder as a string rather than coercing it, reads the system, the output hash fields and each output name as strings without context, and warns that a top-level `allowedReferences`, `allowedRequisites`, `disallowedReferences`, `disallowedRequisites`, `maxSize` or `maxClosureSize` has no effect; nova-nix does the same, with upstream's wording. libxo joins the drvPath parity set, and hand-written derivations covering nested sets, mixed lists, floats, nulls with and without `__ignoreNulls`, a path, a derivation, a placeholder, several outputs and a fixed output match the `.drv` nix-instantiate 2.33.2 writes byte for byte. (#36)- **`builtins.fromJSON` reads JSON as upstream's nlohmann parser does.** It had a parser of its own, separate from the strict one the builder already uses for a derivation's `__json`, and that parser refused the `\b` and `\f` escapes while accepting what nlohmann refuses: an unterminated string, a trailing comma, a leading zero, a raw control character, a `\u` escape short of four hex digits (read as the letter `u`), a lone surrogate (read as U+FFFD), a number past the double range (read as `null`), and whitespace JSON does not define such as a no-break space. Upstream's `parseJSON` (json-to-value.cc at 2.24.9) hands the string to nlohmann's `sax_parse`, so `builtins.fromJSON` now goes through that same strict parser. The messages for refused input are that parser's, not nlohmann's, which name a line, a column and the last token read. (#276)- **`builtins.fromJSON` refuses a positive integer past the Nix integer range.** A number above `9223372036854775807` that still fits an unsigned 64-bit value wrapped to a negative int, as Nix 2.24.9 does. Upstream made this an error at 2.25 (`json-to-value.cc`), `unsigned json number 18446744073709551615 outside of Nix integer range`, and `nova-nix` now matches it, as it already did for the integer overflow errors of the same change. A number past 64 bits stays a float, and the unsigned range is unchanged for a builder reading `__json`. (#311)- **`builtins.stringLength`, `substring`, `unsafeDiscardStringContext`, `unsafeDiscardOutputDependency` and `addDrvOutputDependencies` coerce their string argument as upstream does.** Each refused anything but a string, where upstream calls `coerceToString` at its default arguments (`primops.cc` and `primops/context.cc` at 2.24.9): a path is copied to the store and becomes its store path with context, and a set coerces through `__toString` or `outPath`. A value that cannot be coerced now fails with upstream's `cannot coerce an integer to a string: 1`. 13 of 1,143 sampled top-level attributes on `nixos-unstable` failed on this, nearly all of them .NET packages, and all 13 now produce the store path Hydra built. (#306)- **`derivation` is upstream's wrapper lambda evaluated as the builtin, so its result has upstream's shape: `outputName`, `all` and `drvAttrs` are present, every output attribute is a complete derivation set, and nothing internal leaks.** The builtin hand-built its result as a set with `drvPath`, `outPath`, `type` and one `{ drvPath, outPath, type }` set per output, plus a private `_derivation` attribute carrying the build recipe. nixpkgs reads what upstream's `src/libexpr/primops/derivation.nix` produces: `lib.customisation.extendDerivation` does `inherit (drv.${outputName}) type outputName`, which failed with `attribute 'outputName' not found` for firefox at the top level and for openjdk, gtk3, systemd and emacs one level down, and the leaked attribute reached `nodePackages.typescript` through an attribute enumeration as a value that cannot be coerced to a string. The source of that wrapper, byte for byte at 2.24.9 minus its documentation comment, is now the value of `derivation` in both the root scope and `builtins`, closed over the three names it reads, and `derivationStrict` returns what upstream's primop returns: `drvPath` with its whole-derivation context and one path per output with that output's context. The laziness is the wrapper's: `derivationStrict` is reached only through `outPath` and `drvPath`, so forcing a derivation to weak head normal form still forces none of its inputs. Upstream's three output-list rules in `derivationStrict` come with it: an output named `drvPath`, a repeated output name and an empty list are refused with upstream's messages. `builtins.functionArgs derivation` is now `{ outputs = true; }`, as upstream's lambda reports. `nix-instantiate` 2.33.2 agrees on every attribute of the result for a two-output derivation, on the hello and dependent drvPath parity cases, and on `nodePackages.typescript`, which now evaluates to upstream's drvPath. (#217)- **`build` reads the derivation it realizes from the `.drv` the evaluator recorded, and prints the output the value names as its default.** The driver took the recipe from the derivation value's private `_derivation` attribute, which is gone. Every derivation an evaluation computes is recorded under its `.drv` path as the exact bytes that path hashes, for writing the input closure before a build; the root's own recipe now comes from the same record, so what is built is what was hashed. A `.drv` lists its outputs by name, sorted, with no notion of a default, so the output whose path `build` prints is the value's `outputName`, the first of its `outputs`, which is the output upstream's `nix-build` realizes and prints (`nix-build.cc`, `queryOutputName`), with upstream's message for a set that lacks the attribute. `eval --aterm` prints the recorded bytes rather than a re-serialization; the two are identical, and the recorded bytes are the ones whose hash is the path. (#217)- **A derivation's `name`, `builder` and `system` are read as upstream's `derivationStrict` reads them.** The name is read with `forceStringNoCtx` (primops.cc at 2.24.9): `name = 1` evaluated, coerced to `"1"`, and is now `expected a string but found an integer: 1`, and a name with context is refused with upstream's `the string '...' is not allowed to refer to a store path (such as '...')`, naming the context element upstream lists first; an absent name is `attribute 'name' missing`. A path as the builder or system is copied to the store, as its environment entry already was, so `builder = ./b.sh` puts the store path in the .drv's builder field, where nova-nix wrote the source path and so computed a drvPath upstream does not. An empty builder or system is refused as absent, `required attribute 'builder' missing`, the builder checked first, where nova-nix accepted it. An invalid name reports upstream's `invalid derivation name: name '.' is not valid. Please pass a different 'name'.` and its kin. The same `(such as '...')` now ends the refusal of context in a structured derivation's fields. (#281)- **A failure inside `derivationStrict` names the attribute and the derivation it came from, in upstream's words and layout.** `cannot coerce a set to a string` arrived with no position and no context, so finding which of a closure's thousands of attributes held the set took a bisection by hand. Upstream processes each attribute of a derivation inside a `catch` that adds `while evaluating attribute 'foo' of derivation 'x'` (derivationStrictInternal, primops.cc at 2.24.9), and so does nova-nix now, for the per-attribute coercion, the structured-attributes serialization and the string fields a structured derivation reads, `system`, `builder`, `outputs` and `args`; the name carries upstream's two lines for it, `__structuredAttrs` and `__ignoreNulls` the lines their `forceBool` adds, and a non-Boolean value for either is refused with upstream's `expected a Boolean` message. A failure several derivations deep names each attribute on the way, outermost first. The report is upstream's `showErrorInfo` layout: `error:` alone on the first line, each line of context after an ellipsis and a blank line, the message on an `error:` line of its own, and every line after the first indented to align with it, a multi-line message included; `build` reports an evaluation failure the same way, where it printed `eval error:`. What it cannot print is what upstream prints with a position: nova-nix tracks none, so the `while calling the 'derivationStrict' builtin` and `whose name attribute is located at` lines and the code excerpts under each line are absent, as is `--show-trace`; every line of context is printed. The lines are context only: a message is unchanged, and a throw stays catchable by `builtins.tryEval`. (#221)- **A derivation attribute carrying another derivation's `drvPath` brings that `.drv`'s whole closure into the derivation, as upstream's does.** Upstream's `derivationStrict` takes the closure of the `.drv` (`computeFSClosure`, primops.cc at 2.24.9) and adds every path in it to `inputSrcs` and every `.drv` in it to `inputDrvs` with all its outputs; nova-nix added the one `.drv` to `inputDrvs` and nothing to `inputSrcs`, so `derivation { ...; x = "${dep.drvPath}"; }` had a drvPath upstream does not compute. The closure follows each `.drv`'s inputs and the references a `builtins.toFile` text recorded when this evaluation wrote it. (#294)- **Restricted and pure evaluation gate the filesystem, the environment and the network the way upstream's `restrict-eval` and `pure-eval` do.** Under either mode a read (`readFile`, `import`, `readDir`, `readFileType`, `hashFile`, `builtins.path`, `filterSource`, a path coerced into the store) is refused unless the path lies within an allowed prefix or is an ancestor of one, with upstream's `CanonPath::isAllowed` rule and upstream's message, `access to absolute path '...' is forbidden in restricted mode` (or `in pure evaluation mode (use '--impure' to override)`), which `tryEval` does not catch. The check walks the path through its symlinks prefix by prefix, as 2.24.9's accessor does (`SourceAccessor::resolveSymlinks` through a `FilteringSourceAccessor::maybeLstat` that throws at 2.24.9), so a symlink inside an allowed root that points outside is refused at its target, and the refusal names the first prefix outside the allow list, `/etc` for `/etc/passwd` when nothing under `/etc` is allowed; 2.33.2 names the full path, because its `maybeLstat` answers nothing instead of throwing, and 2.24.9's source is followed. `readFileType` and a symlink read name the path asked for, since upstream checks those without a walk, and refuse a symlink anywhere above the path (`path '...' is a symlink`), as upstream's accessor does beneath its allow list, so the type of a path reached through a symlinked directory is never revealed. An `import` of a directory is checked at the `default.nix` it resolves to as well as at the path named, as upstream's `parseExprFromFile` walks the file it reads after `resolveExprPath` appends the name, so a `default.nix` that is a symlink outside the roots is refused at its target. `pathExists` answers false for a refused path, as upstream turns the refusal into false, and checks a symlink at the final component in place rather than following it, as upstream resolves only the ancestors there, so a link inside the roots exists whatever it points at; a trailing slash demands a directory and follows the link, as it does upstream. The allowed set starts as the search path roots and grows as the evaluation produces store objects, as upstream's `allowPath` grows it: a `toFile` result, a fetched tree, a copied source and a `builtins.path` result are readable afterwards, and the fetchers' scratch directories are the evaluator's own. `getEnv` answers the empty string under either mode (`prim_getEnv`). Under `restrict-eval` a fetch is refused unless `allowed-uris` admits it, with upstream's `isAllowedURI` rule (equal to a prefix, under it at a `/` boundary, or a bare scheme such as `https:`) and message (`access to URI '...' is forbidden in restricted mode`); a path or `file://` URI is checked against the allowed paths instead (`checkURI`). `fetchGit` is checked in the form upstream renders its input, `git+https://host/repo?exportIgnore=1` with the pins in key order, so an `allowed-uris` prefix has to be written for that form, as it does upstream, and a local repository given as a path is `git+file://`. Under `pure-eval` the search path holds only the bundled `<nix/*>` directory and a `<name>` miss says `cannot look up '<name>' in pure evaluation mode (use '--impure' to override)` (still catchable, as the default mode's miss is); `builtins.currentTime` and `builtins.currentSystem` do not exist; `builtins.storePath` is refused (`'builtins.storePath' is not allowed in pure evaluation mode`); `fetchurl` and `fetchTarball` need a `sha256` (`in pure evaluation mode, 'fetchurl' requires a 'sha256' argument`); `fetchGit` needs a `rev` (`in pure evaluation mode, 'fetchGit' will not fetch unlocked input '...'`, 2.24.9's wording where 2.33.2 says `doesn't fetch`, and a rev is what locks a git input at 2.24.9); and `~/x` is refused (`the path '~/x' can not be resolved in pure mode`, upstream's parser message, raised here where the expansion is). Every message was recorded from `nix-instantiate` under `--option restrict-eval true` and `--option pure-eval true` and matched byte for byte on the final error line. Two divergences are deliberate: `builtins.findFile` over an explicit list treats a candidate the policy refuses as absent (2.24.9 probes outside its accessor and hands the path back, an existence oracle; 2.33.2 refuses from there), and the closure of a search path root that is a store path is not allowed with it, since evaluation holds no store database handle. The default is unrestricted, as upstream's is. (#75)- **A string that spells a relative path is refused wherever a path is coerced from a string, and a search path miss carries upstream's hint.** `builtins.readFile "foo"`, `import "foo"`, `pathExists`, `readDir`, `readFileType`, `hashFile`, `filterSource`, `storePath` and `scopedImport` read a relative string against the working directory (and `import` against the importing file's directory); upstream's `coerceToPath` refuses one with `string 'foo' doesn't represent an absolute path`, observed from `nix-instantiate` 2.33.2 in every mode, and so does nova-nix now. An absolute string is canonicalized like a path value, as upstream's `CanonPath` does. The refusal is also what keeps the access policy sound: a relative string would be checked against one location and opened at another. The miss message for `<name>` is now `file 'name' was not found in the Nix search path (add it using $NIX_PATH or -I)`, upstream's text. (#75)- **Function calls nested past `max-call-depth` (10000 by default) are refused with upstream's "stack overflow; max-call-depth exceeded".** nova-nix had no ceiling: the counter recursion `f 100000`, which upstream rejects, evaluated here to 100000, and ten million frames evaluated in 12 s at 1.8 GB. The counter is evaluator state, carried per frame by each evaluator (the pure one enforces it too), and it counts what upstream's `EvalState::callFunction` counts (eval.cc at 2.24.9): every application of a lambda, of a builtin (a partial application included) and of a functor (two frames, its inner call being a `callFunction` of its own), a `__toString` coercion, and the operators upstream's parser desugars into builtin calls, `-`, `*`, `/`, `<`, `<=`, `>`, `>=` and unary `-` (parser.y at 2.24.9). The applications builtins build (`map`, `genList`, `mapAttrs`, `zipAttrsWith`) are upstream's app values: applied where their result is forced, with the frame opening before the function is forced, so a `mapAttrs` or `zipAttrsWith` callback's name application runs a frame below its value application, as upstream's two nested app values do; `builtins.sort` with `builtins.lessThan` itself as the comparator opens no frame per comparison, upstream's `prim_sort` bypass. The check runs on entry against the frames already active, so with the default ceiling 10001 nested lambda calls pass and 10002 fail, and the counter recursion passes at 9999 and fails at 10000, its deepest frame being the `n - 1` forced inside `f 0`; every boundary was confirmed against nix-instantiate 2.33.2. The error is an eval error that `tryEval` does not catch, as upstream's `EvalError` is. The ceiling reads from nix.conf and NIX_CONFIG through the cascade `substituters` uses, a plain assignment replacing and `extra-max-call-depth` being an unknown name since upstream accepts `extra-` on list settings only, with upstream's integer grammar: decimal digits, an optional leading `+`, and an optional `K`, `M`, `G` or `T` binary unit suffix in either case; anything else, or a value past `unsigned int`, is refused as `setting 'max-call-depth' has invalid value '...'`. One divergence: upstream narrows a unit product silently, so `5G` becomes 1073741824 there, while here it is refused like any other value outside the range. (#222)- **A variable that no enclosing scope binds and no enclosing `with` could supply fails the expression before anything is evaluated, with upstream's `undefined variable 'y'`.** It was an error only where evaluation reached it, so `let x = y; in 1` and `if true then 1 else y` evaluated to 1, and `builtins.tryEval (let x = y; in 1)` to `{ success = true; value = 1; }`, three expressions nix-instantiate 2.24.9 and 2.33.2 both reject. Upstream binds every variable when it parses a source (`ExprVar::bindVars`, nixexpr.cc at 2.24.9) and raises `UndefinedVarError` there unless a `with` encloses the name, an error `tryEval` does not catch. Resolution here now does the same, once per source: the expression or file given on the command line, every `import` when it is forced, so a file with an unbound variable on a branch its importer never takes fails at the import, and `scopedImport`, whose scope's names are bound around the file as upstream binds them, so a `with` in that file no longer shadows them. A name under a `with` still waits for evaluation (`with {}; let x = y; in 1` is 1, and `with {}; y` fails when evaluated), `inherit x;` is checked like any other variable, and `inherit (s) x;` checks only `s`, selecting `x` when it is forced. With several unbound variables, upstream reports the first in its own binding order, which follows its symbol table, and nova-nix the first in the source. `__curPos`, which upstream's parser reads as a position rather than a variable, is exempt from the check and still fails only when forced, since nova-nix does not evaluate it yet. nix-instantiate 2.33.2 and nova-nix both bind every one of the 36860 `.nix` files in the nixpkgs 24.11 revision the parity job pins. (#248)- **The root scope binds every name upstream's base environment does: `__typeOf` and the other `__`-prefixed builtins, and `fetchMercurial`.** Upstream installs each primop and constant under the name it registers and under that name less `__` in `builtins` (`addPrimOp` and `addConstant`, eval.cc at 2.24.9), so `__typeOf 1` is `"int"` there and was an undefined variable here, and with binding checked before evaluation `if false then __typeOf 1 else 2` would have been refused where upstream gives 2. The root scope is now built from the 114 names `createBaseEnv` and the default-enabled `RegisterPrimOp`s produce, each holding the value `builtins` holds under its unprefixed name. Under `pure-eval` it drops `__currentTime` and `__currentSystem`, as upstream drops its `impureOnly` constants, so binding rejects them there. `fetchMercurial` is the one name nova-nix does not implement: it is bound, so binding accepts it, and calling it fails with `unknown builtin 'fetchMercurial'`; `builtins` still does not list it. (#248)- **An inherited value is evaluated in the scope around the binding set, not in the set itself.** `rec { ${"q"} = 0; x = 1; y = rec { ${"a"} = 1; inherit x; }; }.y.x` recursed forever, because the inner set looked `x` up by name from its own scope and found the attribute it was defining; upstream gives 1, evaluating an Inherited attribute in the enclosing environment (`ExprAttrs::eval` and `ExprLet::eval`, eval.cc at 2.24.9), and so does nova-nix now. A plain `inherit` carries its variable, bound like any other, so the evaluator has no name lookup of its own for one, and an inherit clause that repeats a name is refused when parsed with `attribute 'x' already defined`, as upstream's per-name check refuses it. (#248)- **Indented strings strip exactly what upstream strips: whitespace-only lines, the opener's own line, and spaces but never tabs.** The stripping was approximate in four ways. A string with no measured line (blank lines and spaces only) kept every space, because the minimum indent started at zero when nothing contributed; upstream starts it at a sentinel, so such a string loses every leading space, and `''` followed by a blank line and an indented closer is `"\n"`, not the eight spaces of the closer. A tab counted as indentation and was stripped; upstream measures only spaces, so a tab fixes the minimum at its column and survives into the value. The closing `''`'s own indentation survived as a trailing line of spaces; upstream removes a final line of spaces from the last part after stripping. And the opener's trailing spaces survived as a line of their own, because only a bare newline after `''` was dropped; upstream's lexer consumes `''`, any spaces and one newline as the opener, so content starts on the next line. The same transcription corrects how escapes meet stripping: upstream's scan skips an escape (it ends a line's leading whitespace without being measured) while its strip runs over escapes as over any literal, so the spaces after an escaped newline are stripped but never measured, and `''  a''\n  b''` is `"a\nb"` where it was `"a\n  b"`. Every rule is `ParserState::stripIndentation` and the `IND_STRING_OPEN` lexer rule at Nix 2.24.9, unchanged through 2.33.2, and every case was checked against nix-instantiate 2.33.2. nixpkgs concatenates `+ ''`, a blank line, `''` into shell hooks constantly, and clang's drvPath differed from upstream's for that reason alone. (#220)- **A builtin that takes a path coerces its argument as upstream's `coerceToPath` does.** `readFile`, `readDir`, `pathExists`, `hashFile`, `readFileType`, `import`, `scopedImport`, `builtins.path`, `filterSource`, `toPath` and `storePath` each refused anything but a path or a string in a message of nova-nix's own; upstream runs the argument through `coerceToPath` (eval.cc at 2.24.9), which takes a path as itself, follows a set's `__toString`, and coerces anything else to a string that must be absolute. So `builtins.readFile { outPath = "/etc/hosts"; }` reads the file, and `builtins.readFile 1` is `cannot coerce an integer to a string: 1`. `builtins.path { path = 1; }` read the relative path `1`, and `builtins.toPath` gave a path where upstream gives the coerced path as a string with its context, which interpolation does not copy. `baseNameOf` and `dirOf` coerce what is not a path as upstream's `coerceToString` does, so an `outPath` or a `__toString` answers, and `dirOf` of a set gives a string. (#283)- **`builtins.pathExists` checks the final symlink in place and demands a directory for a trailing slash, `builtins.readFileType` refuses a symlink above its path, and `builtins.path`, `filterSource` and path coercion resolve a symlink root.** Upstream's `prim_pathExists` (2.24.9) resolves a plain argument through its ancestors only and lstats the final component, so a dangling symlink exists, and resolves a string ending in `/` or `/.` fully and requires a directory, so `builtins.pathExists "/etc/passwd/"` is `false`; nova-nix followed the final link (a dangling one read as absent) and erased the trailing slash in canonicalization. `readFileType` lstats its argument without resolution, and upstream's accessor refuses a symlink anywhere in the parent chain with `path '...' is a symlink` (`PosixSourceAccessor::assertNoSymlinks`) in every mode, so `builtins.readFileType /tmp/x` on macOS, where `/tmp` is a symlink, fails exactly as it does under `nix-instantiate`; nova-nix answered the target's type. `builtins.path`, `builtins.filterSource` and a path coerced into the store now resolve their root through its symlinks before reading the tree, as upstream's `addPath` and `copyPathToStore` do, so a root that is a symlink stores what it points at under the root's own name and lands at upstream's store path; nova-nix tried to store a symlink. (#75)- **Interpolating a path that is a symlink copies what it points to.** `"${./link}"` stored the link itself, where upstream's `copyPathToStore` stores `path.resolveSymlinks()` under the path's own name (eval.cc at 2.24.9). The store path therefore differed from upstream's, and so did the drvPath of every derivation that interpolates such a path. (#279)- **A list coerces to a string as upstream joins it.** `builtins.toString [ [ ] 1 ]` was `" 1"` and is now `"1"`: upstream's `coerceToString` (eval.cc at 2.24.9) puts a space after every element but the last, except after one that is itself an empty list, where nova-nix joined every element with a space. A list now coerces wherever upstream's permissive coercion runs, so `toString { __toString = s: [ 1 2 ]; }` and `toString { outPath = [ 1 2 ]; }` are `"1 2"`, where nova-nix refused the list, and a derivation attribute or argument holding a list joins the same way. Interpolation still refuses a list, as upstream's does. (#282)- **`builtins.storePath` follows a symlink into the store and refuses with upstream's messages.** Upstream's `prim_storePath` resolves a path's symlinks unless the path is itself a store path (primops.cc at 2.24.9), so a link outside the store pointing into it names the store path it reaches, where nova-nix refused it. A path outside the store is `path '/x' is not in the Nix store`, naming the resolved path, and a component under the store that is no store path is the `StorePath` constructor's refusal (path.cc), `'x' is too short to be a valid store path` or `store path '...' contains illegal base-32 character 'E'`, where nova-nix said `builtins.storePath: not a valid store path` for all of them. (#293)- **`builtins.toXML` writes upstream's document and keeps the contexts of the strings in it, so a NixOS toplevel evaluates to upstream's drvPath.** The writer was an approximation of `printValueAsXML` (value-to-xml.cc and xml-writer.cc at 2.24.9) in five ways. It indented by list and set nesting rather than by element: the value under `<expr>` started at column 0 and an `<attr>`'s value sat at the attribute's own indent, where upstream's `XMLWriter` indents every element two spaces per element open around it. A newline in an attribute value was written raw; upstream writes `&#xA;`, since an XML parser normalizes a literal one to a space. Every function was `<function />`; upstream writes a lambda's argument pattern, `<varpat name="x" />` or an `<attrspat>` listing the formals in name order with the `@` binding and the ellipsis as attributes, and a primop as `<unevaluated />`. A derivation was written as a plain set, and since its `all` and output attributes refer back to it the writer never finished; upstream writes a `<derivation drvPath=... outPath=...>` element for it, holding its attributes the first time its drvPath appears and only `<repeated />` every time after. And the result was a plain string, where `prim_toXML` gives it the contexts of the strings it wrote. NixOS writes GRUB's installer configuration with `pkgs.writeText "grub-config.xml" (builtins.toXML ...)`, so the configuration's text and its missing inputs made the toplevel's drvPath differ from upstream's. Every case was checked against nix-instantiate 2.24.9 and 2.33.2, and the toplevel joins the parity case set. (#221)- **`builtins.toJSON` escapes backspace and form feed as `\b` and `\f`, as upstream does.** It wrote them as `\u0008` and `\u000c`. Upstream serializes through nlohmann's `dump()`, whose escaper has two-character escapes for the quote, the backslash, backspace, form feed, newline, carriage return and tab, and `\u00xx` only for the other control characters. The same rendering now writes a structured derivation's `__json`, whose bytes are hashed into its store path. (#36)- **`builtins.toJSON` converts a set with `outPath` through the `outPath` value itself, and a set with `__toString` through upstream's coercion of the result.** Either kind of set was coerced to a string with the derivation-environment rules, so `{ outPath = { a = 1; }; }` and `{ outPath = [ 1 2 ]; }` failed with `cannot coerce`, `{ outPath = 1; }` and `{ __toString = s: 1; }` became the string `"1"`, and `{ __toString = s: ./x; }` copied `x` to the store. Upstream's `printValueAsJSON` (value-to-json.cc at 2.24.9, unchanged in 2.33.2) converts the `outPath` value as it converts any value, so those become `{"a":1}`, `[1,2]` and `1`, and a path there is still copied to the store with its context. It coerces a `__toString` result through `tryAttrsToString` with `coerceMore` and `copyToStore` both off, so an integer is an error, a path is its own absolute text with no store copy and no context, and a string keeps its context. A structured derivation's `__json` is built by the same conversion, so its attributes follow the same rules. Every case was compared with nix-instantiate 2.33.2. (#36)- **An environment value's bytes reach the evaluator unchanged, as upstream's do.** `builtins.getEnv` and `builtins.nixPath` read a variable through base's `lookupEnv`, which decodes it with the file-system encoding and carries a byte with no UTF-8 reading as a lone surrogate, and the conversion to text then replaced that with U+FFFD: `NIX_PATH` holding the byte 0xFC followed by `=/x` gave a three-byte prefix (EF BF BD) where `nix-instantiate` 2.33.2 gives the one byte. Upstream reads a variable with `getenv` and keeps its bytes (`getEnv` in `src/libutil/environment-variables.cc` at Nix 2.24.9). On POSIX the evaluator now makes the same call through the unix package, for the name as well as the value, so `builtins.getEnv` of a name that is not valid UTF-8 looks that variable up instead of failing. `NIX_PATH` is split and parsed as bytes, as upstream's parser is, and a search path prefix is compared byte for byte (`suffixIfPotentialMatch`), so an entry whose prefix has no UTF-8 reading no longer stops a `<name>` lookup from reaching the entries after it. A matching entry whose path has no UTF-8 reading is an error, since path values are text here, and such a root adds nothing to the restricted-mode allow list instead of a lossy spelling of itself. A Windows environment is UTF-16: a value becomes its UTF-8 bytes, and one holding an unpaired surrogate, which has no UTF-8 form, is refused rather than approximated (`builtins.getEnv` raises an evaluation error, a `NIX_PATH` fails setting up the evaluation), the rule the NAR serializer applies to such a file name. The read also stops catching every exception as "unset", which turned an interrupt arriving during the read into an empty value. (#253)- **`-`, `*`, `/`, the arithmetic and bitwise builtins and the comparisons fail with upstream's messages.** Each is an upstream primop (`prim_sub`, `prim_mul`, `prim_div`, `prim_add`, `prim_bitAnd` and its kin, `prim_lessThan`, primops.cc at 2.24.9) that checks its operands with `forceInt`, or with `forceFloat` once either is a float. So `1 - {}` reports `expected an integer but found a set: { }` where nova-nix said `cannot apply subtraction to an integer and a set`, `1.0 - {}` reports `expected a float but found a set: { }`, and `builtins.bitAnd 1 {}` names the value it refuses where nova-nix said `builtins.bitAnd: expected two integers`. Division looks at its divisor first, as upstream's does: `1 / {}` fails the divisor's `forceFloat`, and a zero divisor is `division by zero` before the dividend is checked, so `{} / 0` is a division by zero, for `/` and `builtins.div` alike (nova-nix prefixed the builtin's message). Comparing two types is `cannot compare an integer with a set`, and comparing a type with no order is `cannot compare a Boolean with a Boolean; values of that type are incomparable`, where nova-nix wrote `cannot compare an integer and a set` and `cannot compare a Boolean and a Boolean`; a lambda and a primop are one type there, upstream's `nFunction`. From 2.25 upstream appends both values to a comparison's message, and 2.24.9's wording is kept. (#278)- **`+` and string coercion fail with upstream's messages, and a message that names a type names it as upstream's `showType` does.** `1 + "a"` reported `cannot coerce an integer to a string with the + operator` and now reports `cannot add a string to an integer`, and `"a" + 1`, `"${1}"` and `builtins.toString {}` report `cannot coerce an integer to a string: 1` and `cannot coerce a set to a string: { }`, the messages of upstream's `ExprConcatStrings::eval` and `coerceToString` (eval.cc at 2.24.9). The left operand of `+` is dealt with before the right is evaluated, and its type alone decides the operation, as upstream's loop decides it: an integer or float makes `+` arithmetic and refuses a right operand that is not a number, and anything else makes it a strict concatenation. So `true + 1` fails to coerce the Boolean instead of failing to add it, and `{} + throw "b"` fails on the set without evaluating the throw, an error `builtins.tryEval` does not catch. Upstream copies a path into the store only when the left operand is a string, so `{ outPath = ./src; } + "x"` is now the path's own text with no context, where nova-nix copied the source. A store-path context appended to a path reports upstream's `a string that refers to a store path cannot be appended to a path`, and an interpolated path literal looks for one only once every piece has coerced, as upstream does, so a later piece that fails to coerce is the error reported. A string with context is `a string with context`, a primop `the built-in function 'map'` and a partial application of one `the partially applied built-in function 'map'`, where nova-nix said `a string` and `a built-in function`, in every type error and in a selection path's error alike. (#250)- **The value a type error shows, and the one `builtins.trace` prints, is a set's attributes and a list's items as upstream's `printValue` prints them (print.cc at 2.24.9), where nova-nix printed `<<a set>>` and `<<a list>>`.** Attributes print by name, and in an error with `_type` and `type` first, as upstream sorts them whenever the print is bounded. An error's print shows at most ten attributes and ten items over the whole value and ten levels of nesting, and counts what it leaves out, the bounds of upstream's `errorPrintOptions` (print-options.hh). Nothing is forced: an entry not yet evaluated prints as upstream's thunk marker, a primop as its primop marker, and a thunk being forced as upstream's marker for a possible infinite recursion. Which entries are thunks follows nova-nix's evaluator, which agrees with upstream's for a literal written in the set or list, a function's argument and anything already forced, and not for an indented string, a `~/` path, a variable bound to a literal by `let` or `rec`, or a global such as `map`, all of which upstream hands over as values. A function value carries neither its name nor its source position, so a lambda's marker is the bare word where upstream adds both, and a set or list reached twice prints again where upstream marks it repeated. (#250)- **Integer overflow and negation fail as upstream does.** An overflowing `+`, `-` or `*` reports upstream's `integer overflow in adding 9223372036854775807 + 1`; upstream checks these from 2.25, and 2.24.9 leaves them to undefined C++ arithmetic. Dividing the smallest integer by -1, which 2.24.9 does check, reports its `overflow in integer division`, where nova-nix wrote `integer overflow in dividing a and b`. Unary minus is upstream's `__sub 0 e` (parser.y at 2.24.9) in every respect, so `-(0.0)` is positive zero and `builtins.toJSON (-0.0)` is `"0.0"`, and `-{ }` fails with `expected an integer but found a set: { }`. (#250)- **A failed read of a source path reports upstream's message, not GHC's.** `builtins.readFile ./nope` reported `/d/nope: withBinaryFile: does not exist (No such file or directory)` and now reports `opening file '/d/nope': No such file or directory`, the wording of upstream's `PosixSourceAccessor` (posix-source-accessor.cc at 2.24.9), which names the access and the path and appends the system error. An absent path under an lstat (`readFileType`, interpolation, `builtins.path`, `filterSource`, the target of an `import`) is `path '/d/nope' does not exist`, as `SourceAccessor::lstat` has it, and a path reached through a file counts as absent there; a file is opened with `opening file`, a directory read as a file is `reading from file '/d/dir': Is a directory`, and a directory is listed with `reading directory`. Each names the path as upstream does: resolved through its symlinks for a read, `readDir` and a copy, as given for `readFileType`. A failure inside the walk of a copied directory still carries GHC's text. (#277)- **A non-set operand of `//` and a non-function passed to `builtins.functionArgs` fail with upstream's messages.** `null // {}` reported `cannot merge null and a set` and now reports `expected a set but found null: null`, the message of `evalAttrs`, which upstream's `ExprOpUpdate::eval` runs on the left operand and then the right (eval.cc at 2.24.9). A non-set left therefore fails before the right is evaluated, so `builtins.tryEval (null // throw "b")` raises the type error instead of catching the throw. 2.33.2 checks the right operand first; 2.24.9 is followed. `builtins.functionArgs 1` reports upstream's `'functionArgs' requires a function` (`prim_functionArgs`, primops.cc). The offending value is printed as upstream's `printValue` prints it, and `builtins.trace` shares that printer, so a float it prints has upstream's six significant digits: `trace: 1.23457e+06`, where it printed `trace: 1234567`. (#245)- **`builtins.warn` refuses a message that is not a string, as upstream does.** It printed any value as the warning; upstream's `prim_warn` forces the message with `forceString` (primops.cc at 2.24.9), so `builtins.warn 1 2` fails with `expected a string but found an integer: 1`, which `builtins.tryEval` does not catch. Upstream keeps the argument a string to leave room for extending it; `builtins.trace` remains the way to print any value. (#249)- **`builtins.deepSeq`, `builtins.trace` and `builtins.warn` finish with their first argument before they force their second.** Upstream's `prim_deepSeq` forces the first argument deeply, `prim_trace` prints it and `prim_warn` warns with it, and only then does each force the second (primops.cc at 2.24.9). nova-nix forced both arguments before the builtin ran, so `builtins.deepSeq { a = throw "a"; } (throw "b")` failed with `b` where upstream fails with `a`, `builtins.trace "hi" (throw "b")` failed without printing the trace, and a value printed inside `deepSeq`'s second argument still showed unforced thunks. `builtins.warn`'s line now carries upstream's `evaluation warning:` prefix, where nova-nix wrote `warning:`. (#285)- **`builtins.head` and `builtins.tail` no longer copy the list, and `head`, `tail`, `elemAt` and `length` fail with upstream's messages.** `head` built a Haskell list of every element to return the first, and `tail` built one to copy all but the first into a new C list. `head` now indexes the C array as `elemAt` does, and `tail` returns a new header over the same array, which is safe because a list is never written after construction; upstream's `prim_tail` copies (primops.cc). A copy per call made a chain of tails quadratic in time and in arena memory, which is freed only when evaluation ends: folding `tail` 9999 times over a 10000-element list took 0.72 s and 449 MB and now takes 0.01 s and 33 MB, and `head` of an 800000-element list takes 0.13 s, as `elemAt` does, where it took 0.20 s. The messages are 2.24.9's. An index outside the list fails with `list index 5 is out of bounds`, which `head` of an empty list reports too as `list index 0 is out of bounds`, since upstream's `prim_head` is its `elemAt` at index 0; `tail` of an empty list fails with `'tail' called on an empty list`, a non-list with `forceList`'s `expected a list but found an integer: 1`, and a non-integer index with `expected an integer but found a string: "x"`, checked before the list because upstream forces the index first. 2.26.0 reworded the empty-list and bounds messages, so nix-instantiate 2.33.2 prints `'builtins.head' called on an empty list` and `'builtins.elemAt' called with index 5 on a list of size 2`. (#48)- **`map`, `genList`, `concatMap`, `mapAttrs` and `zipAttrsWith` no longer compile code for every element they make, and an `inherit (from)` no longer compiles its selects each time it is evaluated.** Each element these builtins make is a deferred application, and its three or five instructions were compiled afresh per element into the bytecode store, which is freed only when evaluation ends, so the store grew with every element mapped; an `inherit (from)` likewise compiled the select of each name it inherits every time its binding ran. Every store now opens with that application code at fixed indices, and each element runs it in an env of its own holding the function and its arguments, as upstream builds an app value per element (`mkApp` in primops.cc at 2.24.9); `genList` passes the index as an argument value, as `prim_genList` allocates an int per element. The compiler makes each inherited name's select once, with its binding, as upstream's parser makes an `ExprSelect` per name (parser.y at 2.24.9). Evaluating `hello.drvPath` on the pinned nixpkgs 24.11 compiles 102800 instructions where it compiled 862288 and peaks at 116 MB resident where it peaked at 127 MB, and mapping over 100000 elements compiles 79 instructions where it compiled 600074. `map` and `concatMap` also share one thunk for the function across their elements, where they allocated one per element. A `genList` that is built and never forced costs more than it did, since an env and an int per element replace three instructions: building a million elements takes 0.27 s of user time and 260 MB, against 0.19 s and 226 MB. (#48)- **Store paths, derivations and string literals evaluate with less work.** A store path's hash was folded to its 20 bytes through a fresh 20-element list for every byte of the digest; it is now XOR'd together a chunk at a time, the same bytes upstream's `compressHash` produces by folding byte `i` into position `i mod 20` (hash.cc). A derivation's `.drv` text was rendered twice, once to hash for its path and once to record for the build, where upstream's `writeDerivation` hashes and writes one rendering; it is rendered once. A string with no interpolation went through the general path an interpolated string takes; it is now its bytes, as upstream's parser makes it an `ExprString` holding its value (parser.y). `hello.drvPath` allocates 2082 MB where it allocated 2203 MB and takes 0.90 s of user time where it took 0.96 s, 2000 derivations allocate 292 MB where they allocated 623 MB, and a million evaluations of `if a == "a" then "b" else "a"` take 0.65 s where they took 0.92 s. (#48)- **Reaching the C data layer outside the `arenaInit` .. `arenaDestroy` window raises `ArenaNotInitialized` instead of crashing the process.** Evaluating anything before `Nix.Eval.Arena.arenaInit`, or after `arenaDestroy`, was a SIGSEGV, so a library user who left the bracket out could not tell a missing setup step from memory corruption. Each C sub-arena's one allocation funnel now reports failure through the sentinel its callers already check (NULL, `UINT32_MAX`, `NN_SYMBOL_INVALID`) instead of dereferencing state it does not have, and the Haskell boundary asks `nn_arena_live` on that failure path and raises the new `Nix.Eval.CStatus.CStatusError`: `ArenaNotInitialized` naming the C entry point that refused, or `CAllocationFailed` when the arena is live and the allocation itself failed. The question is asked only after a failure, so evaluation pays one sentinel comparison per allocation and nothing more, and `hello.drvPath` evaluates in the same time. Upstream guards the same boundary with `assert(gcInitialised)` in the `EvalState` constructor, an abort rather than an error a caller can catch, which is the one place this diverges on purpose. `checkedCPtr` moves to `Nix.Eval.CStatus` and runs in `IO`, so the arena is asked at the moment the call failed rather than when a lazy message is rendered; the bytecode emitters raise `CStatusError` where they raised an `IOError`; and the thunk allocators, slot arrays and list construction now check their C result, where a NULL previously flowed on to the next dereference or became a silently empty list. Parsing needs no arena. `ArenaNotInitialized` is a setup diagnosis rather than an error to catch and retry in the same process: GHC updates a thunk whose evaluation raised with that exception, so a shared value whose evaluation reached C before the window re-raises it inside a later, live arena. (#206)- **The C data layer reports a failed or oversized allocation as `CAllocationFailed` instead of aborting the process, and its 32-bit counts no longer wrap.** The symbol table, the attribute set's insert, union and key removal, and the bookkeeping behind lists, closures and context strings called `abort()` when an allocation failed, so evaluation ended with SIGABRT and no way for a caller to recover. Each now refuses through its status, the Haskell boundary raises `Nix.Eval.CStatus.CAllocationFailed` naming the C entry point, and `builtins.tryEval` does not catch it. That is upstream's shape: its collector turns exhaustion into `std::bad_alloc` (eval-gc.cc at 2.24.9), which `tryEval` lets through and the CLI reports as an error. Upstream's symbol table still aborts at its own `uint32_t` ceiling (`ChunkedVector::addChunk`); refusing there instead is deliberate. The 32-bit arithmetic is now checked where it wrapped. An attribute set holds at most 4294967295 entries, the ceiling upstream's `Bindings` has, and its doubling and union sizes are computed in 64 bits; a key past index 2^31 was reported absent and is now found. A string of 4 GiB or more is refused where its length was truncated to 32 bits, so that it read back as only its first bytes, and a list of 2^32 or more elements is refused where its count wrapped to a shorter allocation. `nn_list_new` and `nn_list_drop` report failure through a status of their own, since the NULL they returned also meant the empty list. A thunk whose force fails while its value is being stored is left re-forceable, and a refused thunk state transition raises the new `CInvariantViolated` instead of being ignored. The `null`, `true` and `false` thunks are shared static cells, as upstream shares `vNull`, `vTrue` and `vFalse`: they need no arena, so forcing one before `arenaInit` no longer raises `ArenaNotInitialized` for the rest of the process, and one kept across `arenaDestroy` no longer points into freed memory. Re-initializing the symbol table frees the previous one. (#19)### Store- **The store has garbage-collector roots, a reachability walk, a sweep, and a store-wide lock that keeps a collection and a writer apart.** Roots live under the store's own metadata directory, `.nova-nix/gcroots`, since this store has no state directory apart from that one and a store copied as one directory then keeps its roots. Both of upstream's permanent-root forms are read: a symlink whose target lies in the store, which roots the store path the target lies in (the path itself, a trailing-separator spelling of it, or anything beneath it, upstream's `toStorePath`), and a regular file named `<hash>-<name>`, which is the form that needs no symlink privilege. An out-link's indirect root is a regular file under `gcroots/auto`, named by a digest of the link's absolute path and holding that path, where upstream's is a symlink to the link; the record has to be writable on every platform the store runs on, and a symlink on Windows needs Developer Mode. The record is published by rename, so a listing under the shared lease never reads a torn one. A record whose out-link is gone is removed on the next walk with upstream's `removing stale link` line; a symlink root naming a path the database does not hold is skipped with its `skipping invalid root` line, a regular-file root naming one is dropped silently, and an entry the walk cannot read is reported with its `cannot read potential root` line and skipped, each as upstream does. The walk is pure over the references map; dead rows go in one transaction, because the outputs of one derivation reference each other both ways and no order of one-row deletes gets through a cycle; trees go one by one after the rows, so an interruption leaves inert unregistered trees rather than rows describing nothing. What the sweep removes is every store directory entry that is not live, as upstream's sweep removes it: a dead path's tree, a store-shaped tree no row describes, junk, and a dead path's lock file. A live path's lock file stays: upstream's holders delete their lock files on release, so its sweep reclaims crash debris, while here a holder never deletes and the live path's lock file is its normal state. A dead row with no tree is unregistered without a line or a count, since upstream's sweep walks the directory and never meets one, and what is announced and counted is what upstream announces and counts. The store directory is keyed by its canonical spelling from the moment it is opened (absolute, `.` and `..` collapsed, no trailing separator, symlinks unresolved, as upstream's `absPath` keys a `--store` path), so one directory named two ways keys one set of rows; a database holding a path under another spelling of the directory would compare as dead throughout, so the collector and the checked delete refuse it rather than sweep a rooted closure over a text mismatch. Upstream serializes collection against writers with a shared-or-exclusive `gc.lock` plus a socket; nova-nix keeps the lock and drops the socket: every open store handle holds `.nova-nix/gc.lock` shared from open to close, and a collection (or a checked delete) trades the handle's lease for the exclusive lock, so it runs only while no other process has the store open. An opener arriving meanwhile waits, announced with upstream's `waiting for the big garbage collector lock...`; upstream's own opener never waits there, since it hands its roots to the running collector through the socket, so the collector's line is the one that names the wait. A handle whose lease cannot be renewed after a collection keeps a surrendered lease rather than none, so it still closes. Listing the roots needs only the handle's shared lease, as upstream's listing takes no collector lock. The per-path locks the builder and substituter hold were not enough on their own: they cover a path while it is being produced, not the window between a dependency's registration and the build that consumes it, nor the writers that register without one (the `.drv` closure, the eval-time store writes). Not implemented, and stated in the module: runtime roots (upstream's `/proc` scan on Linux and `lsof` elsewhere), temporary roots, `keep-derivations` and `keep-outputs` (the builder records no deriver, so an unrooted `.drv` and the sources only it references are collected), and the `.links` optimization sweep. (#24)- **The store probes whether its volume folds case when it opens, and case-hacks sibling names only where it does.** Whether two NAR entries differing only by case can share a directory was decided at compile time by operating system, so a store on a case-sensitive APFS volume still had `makefile` written beside `Makefile` as `makefile~nix~case~hack~1`. The store now asks the volume (`pathconf(_PC_CASE_SENSITIVE)` on macOS, the Win32 default on Windows, inherent on Linux) and carries the answer in the new `Store` field `stCaseSensitivity`; every NAR materialization keys names by it, and a volume that does not fold gets its true names. Upstream's `use-case-hack` is a per-process setting defaulting to on for Darwin (archive.cc at 2.24.9), so upstream case-hacks on a case-sensitive macOS volume as well; that spelling is a workaround for folding, and a volume that does not fold needs none, so this is a deliberate divergence in on-disk spelling only, since either tree re-serializes to the same NAR. (#68)- **A store path is read back under its volume's case-hack mode, so a case-sensitive macOS store keeps a name that literally ends in `~nix~case~hack~N`.** The store case-hacks sibling names only where its volume folds, but the serializer stripped the suffix by operating system (nova-cache's `defaultCaseHack`, on for macOS and Windows). On a case-sensitive macOS volume nothing is ever hacked, yet every registration, on-disk recheck, adoption check, fixed-output check, push and evaluation read of a store path stripped the suffix, and the unpack refused an incoming NAR entry carrying it, so a tree holding such a name could not be substituted or registered. Upstream ties both directions to one per-process setting, `use-case-hack`, on for Darwin (archive.cc at 2.24.9), so it strips and hacks alike on every macOS volume. The store now reads its own paths under its probed volume's answer: stripped where the volume folds, as before and as upstream, and verbatim where it does not, which is upstream with `use-case-hack` off, and an incoming name carrying the suffix is refused only where the volume strips it. A path read as a source, outside any store, keeps the per-process setting, as upstream's every read does. (#236)- **A NAR entry name or symlink target the host's filesystem can hold is materialized as its bytes, as upstream restores it on POSIX; each platform refuses only what its own filesystems cannot hold.** The store refused, on every platform, a name with no UTF-8 reading and every name Windows reserves (a device stem such as `aux.c` or `con.h`, a colon, a backslash, a trailing dot or space), so a NAR that `nix-store --restore` unpacks on Linux and macOS failed here. Upstream's restore appends each name to the destination path and hands each target to `symlink` as bytes (`RestoreSink` in fs-sink.cc at Nix 2.24.9), refusing only what the archive grammar refuses: an empty name, `.`, `..`, a `/` or a NUL (`parse` in archive.cc), which stay refused on every platform. Linux now holds every other name and target byte for byte, through the strict and the streaming unpack alike. macOS refuses a name that is not UTF-8 or holds a Unicode noncharacter: APFS refuses both at the create, and HFS+ stores such a name with each byte outside UTF-8 (and U+FFFE and U+FFFF) rewritten as a `%XX` escape, a tree that no longer reproduces its NAR. A link target keeps its bytes there. Windows refuses a device name, a trailing dot or space, a character Win32 reserves (`<>:"\|?*` and the controls), and a name or target with no UTF-16 form. Names reach `open`, `mkdir` and `symlink` as `OsPath` bytes rather than through the locale's codec, which could not encode a UTF-8 name under an ASCII file-system encoding. A store tree is therefore no longer guaranteed to materialize identically on every platform: a path holding a name some host cannot hold is refused when it is substituted onto that host, naming the entry and the reason, and materializes everywhere else. (#84)- **A sibling pair the volume folds but the case-hack key keeps apart fails at the write, naming the entry, instead of silently replacing the earlier one.** On a folding volume the store keys sibling names by their uppercase, and that is not the volume's own fold table: APFS reads capital and small sharp s (U+1E9E, U+00DF) as one name while the key keeps them apart. Both NAR unpack paths created or truncated each file and merged directories, so the second entry of such a pair landed on the first, `builtins.path` returned a store path its tree did not reproduce, and a later build refused to register it with advice that re-evaluation could not follow. Every regular file and directory an unpack writes is now created exclusively, so the volume decides and the collision fails where upstream's restore makes it fail (`RestoreSink` in fs-sink.cc at 2.24.9: `O_CREAT | O_EXCL` for a file, a refused `create_directory` for a directory), with upstream's text. A file reads `creating file '"<path>"': File exists`, the inner quotes being `std::quoted`, through which upstream streams a `std::filesystem::path`, and a directory over a directory reads `path '<path>' already exists`. A directory over anything else reads `creating directory '<path>': File exists`, and a link `creating symlink from '<path>' -> '<target>': File exists`: 2.24.9 printed the C++ library's `filesystem_error` text for these two, which is implementation-defined and differs by platform, and 2.25 wrapped it in these messages, which are followed. The unpack's root is created the same way, so `unpackNarEntry` and the streaming sink refuse a destination that already holds an entry rather than writing into it, as upstream's restore does; every caller clears a stale destination first. `copyPathInto`, the fallback for a build output that cannot be renamed into place, creates exclusively as well and raises the same refusals. (#234)- **A coerced source path is restored into the store from a dump of the source, as upstream restores one, so a sibling pair the source's volume keeps apart and the store's folds is case-hacked instead of failing the build.** The build driver copied each coerced source (`src = ./dir`) file by file and registered whatever landed under the store path evaluation had computed from the source, with nothing checking that the copy reproduced it. On a folding store, a source from a case-sensitive volume holding `Makefile` and `makefile` merged and was registered under the two-file address. Upstream never copies: `LocalStore::addToStoreFromDump` restores the dump it hashed (`restorePath`, local-store.cc at 2.24.9), so its case-hack applies on the way in. The store now does the same and holds `Makefile` and `makefile~nix~case~hack~1` under the path, NAR hash and size nix-instantiate 2.33.2 records for that source. The source's NAR streams from the walk through the hash into the streaming unpack sink, so no file is held whole. The dump must reproduce the address evaluation computed, so a source edited between evaluation and the build is refused rather than registered under a hash its bytes no longer have, and the restored tree is rechecked on disk before its row exists. `builtins.path` without a filter, `fetchTarball` and `fetchGit` likewise unpack the NAR entry they hashed rather than copying the source, as a filtered `builtins.path` already did. Sources follow the store's per-platform name rules (#84): on Linux and macOS a device stem such as `aux.c`, a colon or a trailing dot restores as its bytes, as the copy stored it and as upstream does. (#235)### Builder- **A derivation carrying `__json` is built as upstream builds one: its attributes reach the builder as `.attrs.json` and `.attrs.sh` in the build directory, named by `NIX_ATTRS_JSON_FILE` and `NIX_ATTRS_SH_FILE`, and not as environment variables.** The builder copied every environment entry of the `.drv` into the build's environment, so a structured derivation's builder saw one `__json` variable and neither of the files stdenv's setup script looks for. Upstream takes the mode from the presence of `__json` (`ParsedDerivation`, parsed-derivations.cc at 2.24.9), sets `outputs` to an object naming each output's path, writes the object to `.attrs.json` and the part of it bash can hold to `.attrs.sh`, and passes no attribute and no output through the environment (`initTmpDir` and `writeStructuredAttrs`, local-derivation-goal.cc at 2.24.9). The shell file follows `writeStructuredAttrsShell`: a string single-quoted, an integral number in decimal, null as `''`, a boolean as `1` or nothing, an array or object of those as `declare -a` or `declare -A`, and anything else, or any name that is not a shell identifier, left out. nova-nix now does each of these, rewriting placeholders and store paths in both files as it does in the environment, and reads `impureEnvVars` from the object, where it must be a list of strings. A structured build here wrote `.attrs.json` and `.attrs.sh` byte-identical to a Nix 2.33.2 build of the same derivation, the store directory aside. Upstream writes a number through `static_cast<int>`, so an integer keeps its low 32 bits, and a float past `int`'s range is undefined behavior there; nova-nix writes what an aarch64 build of upstream writes, the saturated value, where an x86-64 build writes `-2147483648`. `outputChecks`, `exportReferencesGraph` and `unsafeDiscardReferences` are neither enforced nor exported in this mode, as their flat-mode counterparts are not. (#36)- **An x86_64 host runs i686 derivations of its own operating system natively, as upstream's default extra-platforms does.** `i686-linux` and `i686-windows` are platforms of their own now rather than unrecognized strings. A derivation for `i686-windows` spawns directly on an x86_64 Windows host, where WoW64 runs it, and `i686-linux` does the same on an x86_64 Linux host, where the kernel does; upstream adds `i686-linux` to its extra platforms on `x86_64-linux` by default and has no Windows entry yet, so the Windows rule is the same one applied to the platform upstream has not reached. On any other host an i686 derivation is refused or launched through `--exec-wrapper` like any foreign system. (#213)- **`builtin:fetchurl` retries a transient failure with backoff before moving to the next URL, as upstream's transfer layer does.** One timeout, reset or 5xx against a flapping host used to end that URL's attempt at once, so a short outage on every listed mirror cost the whole fetch. Each URL now gets upstream's five attempts (the `download-attempts` default in `libstore/filetransfer.hh` at 2.24.9), waiting 250 ms before the first retry and doubling after that, with upstream's jitter on the exponent, and each retry is announced on stderr with upstream's `; retrying in N ms` suffix. Upstream's classification decides what a retry can outlive (`libstore/filetransfer.cc` at 2.24.9): a 404 or 410, a 401, 403 or 407, any other 4xx except 408 and 429, a 501, 505 or 511, a malformed or unsupported URL, a redirect loop, a failure writing the output, and a download that verifies wrong are deterministic and move straight to the next URL; everything else, name resolution and TLS included, is retried. A retry restarts the download from the first byte with a fresh hash, where upstream resumes from the written offset only when the server accepts ranges. The policy lives in `BuildConfig` as `bcFetchRetry`, a `FetchRetryPolicy` whose default is upstream's, and the retry loop, delay formula and both classifications are exported from `Nix.Http` with their effects injected, so the policy is tested without a clock or a network. (#238)- **An interrupt during a push, a fetch cache read or write, a store derivation read or an archive unpack stops the process instead of being read as a missing file, a cache miss or a failed push.** Each of these caught every exception, so a Ctrl-C or a killed thread arriving mid-operation became its fallback value and execution went on: a push reported `push failed: user interrupt` or `HTTP error for <url>: user interrupt` as if the cache had refused it, a fetch cache entry being read became a miss and one being written was dropped, a `.drv` being read became a missing derivation (a failed build or a modulo-hash error), a source tree being verified on disk became a mismatch and was deleted or refused, and an archive being unpacked failed the `builtin:unpack` build. Each now catches only the failure it expects: an `IOException` for a file read, write or removal, an `HttpException` for a push request, and the `ErrorCall` the zstd decoder raises for a corrupt frame. A push, which also meets sqlite and serializer failures, catches every synchronous exception through `Nix.Http.catchSync` and lets an asynchronous one through. Upstream draws the same line by type: `Interrupted` is a `BaseError` beside `Error` rather than under it (`src/libutil/signals.hh` and `src/libutil/error.hh` at 2.24.9), and its fallbacks catch `Error`, as substitution does (`substitution-goal.cc`). A push reads each response body through the transfer layer, so a connection lost mid-body is reported as an HTTP error like any other failure of the request. (#251)### Substitution- **The substituter retries a narinfo or NAR download under upstream's transfer-layer policy, the one `builtin:fetchurl` uses.** Upstream serves every download through one `FileTransfer` (`libstore/filetransfer.cc` at 2.24.9) with one backoff and one table of the failures that are never retried, and the substituter kept an older policy of its own. A narinfo fetch was not retried at all, so a single timeout, reset or 5xx on the narinfo cost the path its substitution and, with no other cache holding it, a local build; it now gets upstream's five attempts. A NAR download retried every 5xx and every failure the HTTP client raised, so a 501, 505 or 511 and a redirect loop spent five attempts on an answer that cannot change; they now stop at once, as upstream's never-retried statuses and curl results do, while a 4xx other than 408 and 429 stops at once as before. The delays between attempts become upstream's 250 ms doubling with jitter on the exponent, where the NAR retry waited 0.5, 1, 1.5 and 2 seconds, and each retry is announced on stderr with upstream's `; retrying in N ms` suffix. A narinfo answered 404, 410, 401, 403 or 407 is a miss and is never retried, where only a 404 was a miss and the other four were substitution errors: upstream's transfer layer calls the first two `NotFound` and the rest `Forbidden`, and its binary cache store reads both as the file not being in that cache, since an S3 bucket that cannot be listed answers a missing key with 403. A NAR the narinfo named and the cache answers the same way stops after one request, as before and as upstream's `SubstituteGone` does. An unreachable cache therefore costs each narinfo the full retry budget before the scan moves on (the delays alone come to four to five seconds), as it does upstream, which disables a failing cache for a minute only when `fallback` is set. A connection reset in the middle of a body is now a transport failure, retried like any other, in `builtin:fetchurl` too: the HTTP client wraps what fails while a response is opened but hands the body reader over unwrapped, so a reset mid-body arrived as a bare `IOException` and was taken for a failure writing the output, where curl's receive errors are transient upstream. `bcFetchRetry` governs the substituter's requests as well as `builtin:fetchurl`'s, as upstream's one `download-attempts` setting governs every transfer. (#243)- **Every HTTP request nova-nix's own client makes identifies itself, as upstream's do.** Only `builtin:fetchurl` sent a User-Agent; the substituter and `push` sent none. A request with no User-Agent is what bot mitigation in front of a server scores lowest: Cloudflare in front of cache.novavero.ai challenged such requests from a GitHub runner and passed the same requests carrying `nova-nix/VERSION`, so the public cache could be read by a person's browser and not by the tool built to read it. Upstream sends `curl/VERSION Nix/VERSION` on every request. The header is now set in one place for the fetcher, the substituter and `push`, with the version Cabal built in. `builtins.fetchurl` and `builtins.fetchTarball` run `curl`, which sends its own User-Agent. (#215)### Windows packages- **`pkgs/windows/fetchurl.nix` understands nixpkgs' `mirror://<site>/<path>` scheme, and hello and sed fetch through `mirror://gnu/`.** A recipe named a hand-picked handful of hosts, so one unreachable host could fail the fetch. The site's hosts now come from `pkgs/windows/mirrors.nix`, a verbatim copy of the sets this package set uses from nixpkgs' `pkgs/build-support/fetchurl/mirrors.nix` at the commit the file names, so a recipe spells its source the way the nixpkgs recipe for the same package does and gets the whole list, tried in nixpkgs' order. nixpkgs expands the scheme in its fetch builder at build time; `builtin:fetchurl` runs no shell, so the expansion happens at eval and the derivation records the expanded list, which drops the `ftp://` host the HTTP client cannot fetch. An unknown site is an eval error naming the recipe's URL, where nixpkgs' build script only warns; a mirror URL with no path (`mirror://gnu`) is an eval error too, where nixpkgs expands it to the bare hosts. The source output paths are unchanged (they are fixed by the hash); the source and package derivation paths change, as they describe the new URL list. (#238)### Distribution- **Each Hackage upload carries the library's documentation, built on the pinned toolchain.** Hackage's own documentation builder runs a GHC older than the base floor this package declares, so it could not plan the build, and the package page showed a failed build report and no documentation. The Hackage workflow now builds the haddocks for the library and uploads them after the sdist, and a docs-only run uploads them for a version that is already on Hackage. (#211)- **The public cache carries the current Windows Hello closure, refreshed on every push to main.** cache.novavero.ai was seeded by hand once and nothing republished it when the recipes changed, so a fresh Windows store pointed at it substituted the MinGW-w64 toolchain and built everything else. A publish job after the Windows end-to-end job builds the closure, runs Hello and pushes it, and a second job substitutes that closure into a fresh store from the public cache alone and fails on any local build, so a stale cache turns CI red instead of causing a silent rebuild. (#212)- **The `default.nix` at the repository root is removed.** It pinned nixpkgs 24.11, whose newest GHC cannot satisfy this package's `base >= 4.22`, so it could not build nova-nix, and nothing used it. (#317)### Dependencies- **`unix` (POSIX) and `Win32` (Windows) become direct dependencies, at `unix >= 2.8 && < 2.9` and `Win32 >= 2.9 && < 2.15`.** `base` has no exclusive open, and the store's unpack now needs one, so it calls the platform's own (`openFd` with `O_EXCL`, `CreateFileW` with `CREATE_NEW`). Both are GHC boot packages that `directory` and `process` already pulled into every build, so the solver resolves the versions it already had. The floors are the APIs used: unix 2.8 is the first whose `openFd` takes `creat` and `cloexec` in its flags, and Win32 2.9 the first whose `hANDLEToHandle` serves the native Windows I/O manager. (#234)- **New dependencies and raised floors.** The library adds `random >= 1.2 && < 1.4` and the executable adds `file-io >= 0.1.1 && < 0.2`. `directory` rises to `>= 1.3.8` in the library and executable, and `filepath` to `>= 1.4.100` in all three. The test suite adds `http-types >= 0.12 && < 0.13` and `QuickCheck >= 2.12.5 && < 2.19`, and requires `process >= 1.6.12`.## 0.8.0.0 - 2026-10-080.7.0.0 was published on GitHub but not uploaded to Hackage, so on Hackage this release follows 0.6.0.0. Library users upgrading from 0.6.0.0 should read the 0.7.0.0 entries below as well.### Library APIBreaking changes for code that uses nova-nix as a library:- **`Nix.Eval.Types.MonadEval` has five new methods with no defaults:** `adoptStorePath`, `lookupFetchCache`, `onEvalError`, `setExecutableFile` and `writeFetchCache`. Every instance defined outside this package needs them.- **`Nix.Builder.BuildConfig` has a new strict field,** `bcExecWrappers :: Map Text FilePath`.- **`BuildConfig` drops `bcBashPath` and `bcSandbox`, which nothing read.** Both were defined and defaulted, and no code consulted either one: the Windows stdenv takes bash from the MSYS2 seed, and no platform implements build sandboxing. A field that reads like a switch while switching nothing suggests isolation that does not exist, so it goes until there is a mechanism for it to gate (#25). Library code that set either field stops compiling and loses no behavior. (#209)- **`Nix.Substituter.CacheConfig` replaces `ccPublicKey :: Text` with `ccPublicKeys :: [Text]`,** since a narinfo is now accepted when any trusted key verifies it.- **The store-write cache records how each path was written.** `Nix.Eval.IO.EvalState`'s `esStoreWriteCache` maps each key to `([StorePath], StoreWriteMode)`, and `Nix.Store.materializeEvalStoreWrites` takes the same shape.- **`Nix.Eval.StringInterp.coerceToString` takes a `CoercePath m` argument** that decides how a path is coerced at each call site.- **`Nix.Expr.Types.Expr` has a new constructor, `EPathStr`, and `Nix.Parser.Lexer.Token` has `TokPathInterpStart`, `TokPathLit` and `TokPathEnd`,** so exhaustive matches over either need new cases.### CLI- **`build` selects an attribute, or takes an expression, not only a file.** `nova-nix build FILE.nix -A a.b.c` follows a dotted attribute path into the file's value, and `nova-nix build --expr 'EXPR'` builds with no file at all. A build previously took one file whose value had to be a derivation itself, so a package set could only be built by carrying a pointer file per package, which is the arrangement the nixpkgs by-name layout exists to remove. A component may be double-quoted to carry a literal dot (`-A 'foo."bar.baz"'`), matching upstream's tokenizer including the behaviours that read as accidents: quotes concatenate rather than delimit, so `foo"bar"` is the single name `foobar`, and a trailing dot is dropped rather than becoming an empty component. Three upstream behaviours are deliberately absent. A numeric component indexes a list upstream and is an ordinary attribute name here, because nothing this selects over is a list and upstream's integer-or-name test defers to a C++ numeric parse whose accepted spellings have not been checked against a running Nix. A near-miss attribute name gets no `Did you mean` line, which upstream renders from a Levenshtein search this evaluator has no suggestion channel to carry; the message itself is upstream's, only without that second line. Every selection message matched upstream byte for byte when diffed against `nix-instantiate` 2.33.2. And `-A` is not repeatable: upstream accumulates a derivation per occurrence, while a build here realizes one, so a second `-A` is an error rather than a silent last-one-wins. (#174)- **`--exec-wrapper SYSTEM=PATH` builds a derivation whose system this machine cannot execute, through a named launcher.** `--exec-wrapper x86_64-windows=/path/to/wine` builds an `x86_64-windows` derivation on Linux through Wine. `SYSTEM` is the derivation's own `system` string, spelled exactly as a `.drv` spells it. The launcher is prepended to the builder at the spawn boundary and never enters the derivation, so the store paths a wine-hosted build produces are the same ones a Windows host produces. A derivation for the host's own platform is spawned directly whatever is configured; a derivation for any other system with no launcher named for it is refused before the builder runs, rather than spawned natively and left to fail in the loader. The option is accepted before or after `build`'s target, and repeated options accumulate across both positions with the same duplicate-system and launcher checks. (#171, #201)- **`eval` accepts `--store` after the subcommand.** The eval sub-parser rejected `--store` where `build`, `push` and `store delete` accepted it, even though eval-side reads follow the selected store identically. (#193)- **Substituters and trusted public keys can be configured in nix.conf and NIX_CONFIG, not only as flags.** A machine can now say once, in `nix/nix.conf` under `$XDG_CONFIG_HOME` (by default `~/.config`, or `%APPDATA%` on Windows) or in the NIX_CONFIG environment variable, which binary caches to substitute from and which public keys to trust, instead of repeating `--substituter` and `--trusted-key` on every invocation. The format matches upstream's: name = value lines, a # comment truncates the rest of the line, list values split on whitespace, the binary-caches and binary-cache-public-keys aliases are honored, and an extra- prefix appends to a list rather than replacing it. Sources are resolved in upstream's precedence order, the user file, then NIX_CONFIG, then the command line, with the command line winning; a plain assignment in a higher source replaces the accumulated value and an extra- widens it, which is the load-bearing rule for trusted-public-keys since a mishandled precedence would silently widen what the machine trusts. The trusted-key set is now flat as upstream models it: a narinfo is accepted when its signature verifies under any trusted key, and a malformed key anywhere in the set is a loud error rather than a silently skipped one. The include/!include directives and the /etc/nix and XDG_CONFIG_DIRS sources are tracked separately in #199. (#200)### Evaluation- **Path literals accept string interpolation (`./${v}/x`), which the nixpkgs 26.05 tree uses 89 times across 54 files.** The lexer had no representation for an interpolated path, so both ./${v}/x and /tmp/${v}/y were parse errors. The lexer now carries a path mode alongside the string modes, mirroring upstream's INPATH machinery: the head piece opens the literal, chunks and interpolations follow, and a synthesized end token closes at the first non-path character. Every semantic rule is pinned to nix-instantiate 2.33.2's observed behavior: the result is a path; pieces concatenate with no separator (mid-segment and back-to-back interpolation included) and the whole canonicalizes textually, so a dot-dot arriving at runtime collapses; a path segment coerces without a store copy, unlike string interpolation, and a string carrying store-path context is refused ("cannot be appended to a path"); and a trailing slash is a parse error ("path has a trailing slash"), now for plain path literals too, matching upstream's grammar. A search path followed by /${v} stays two expressions, as upstream parses it. The head piece is absolutized in the same pre-eval pass as plain literals, so closure capture across import keeps working. (#189)- **An attrset coerced through outPath now copies to the store and carries context, matching upstream byte for byte.** The coercion engine handled paths with a fixed context-free case, so a path reached through an attrset's outPath (or a __toString result) rendered as raw filesystem text with no store copy and no string context, wherever the attrset stood in for the path: src = builtins.fetchGit { ... } produced empty inputSrcs and a drvPath diverging from real Nix 2.33.2 while the .outPath spelling worked, a user { outPath = ./dir; } leaked the raw path into the build environment, and the same drop reached interpolation, the + operator, and builtins.toJSON. The path behavior is now a parameter the attrset recursion carries, so every coercion site states its mode: interpolation, derivation fields, +, and toJSON copy to the store; builtins.toString stays verbatim. Verified against nix-instantiate 2.33.2: the attrset form's drvPath now matches upstream exactly. (#187)- **A syntax error inside a lambda is reported where it happened, not as an attr-set complaint at the top of the file.** The parser decided lambda-versus-attr-set (and lambda-versus-expression) by backtracking, and a failed try discarded its error entirely, so a real failure at line 410 of a nixpkgs file surfaced as "expected '=' but got ','" at line 2, column 6: the valid comma in the file's opening formals. Two changes close it. A parsed lambda header now commits: "ident :", "ident @", and "{ formals } :" never begin anything else, so a body failure propagates from its own position instead of rewinding, which also covers the case where the other reading succeeds on a prefix (the empty attr set in "{ }: body") and the old parser complained at the stray colon. And when no reading parses at all, the error from the branch that got furthest into the input is the one reported, with end-of-input ranking past every positioned failure; upstream's LR parser never backtracks and always errors at the true site, and this is the closest a backtracking parser comes. (#181)- **`builtins.fetchGit` remembers a pinned revision.** A fetch of a pinned `rev` is now recorded under the user's cache directory and reused while the tree it names is still in the store, since re-cloning it on every evaluation is pure waste and fatal whenever the far end is down. A bare `ref` is never cached, since it means "whatever this branch points at now". Everything that decides what comes back is in the key, `shallow` included: it does not change the tree, but it does change `revCount`, which can reach a derivation's environment. A hit re-records the store write the fetch would have made, so the path it hands back is registered before any derivation naming it is built. (#172)- **`builtins.fetchGit` with `shallow = true` reports revCount 0 and can check out a pinned rev.** A shallow fetch counted the truncated history, so revCount was always 1 regardless of the real depth, a wrong number that can reach a derivation's environment. Upstream reports 0 under shallow (its fetcher skips computing the attribute and evaluation fills the default; observed from nix-instantiate 2.33.2, whose shallow result keeps all eight attributes with revCount = 0), and nova-nix now records and reports the same 0 without running rev-list at all. A pinned rev also becomes the fetch refspec itself, matching upstream's construction: a depth-1 fetch of a branch tip cannot contain any other revision, so asking the remote for the SHA is what lets shallow and rev compose, and what finds a rev not on the fetched ref. A server may refuse a SHA it does not advertise; that failure surfaces as git's own fetch error, the same surface upstream has. (#184)- **`builtins.fetchGit` honors allRefs, verifies a declared narHash, refuses unsupported attributes, and cleans up after a failed fetch.** allRefs = true fetches every remote ref (upstream's refs/*:refs/* refspec), the caller's way to a pinned rev the remote refuses as a direct SHA want; the scratch clone has a worktree, unlike upstream's bare cache repo, so the fetch passes --update-head-ok, which is safe because an explicit checkout always follows. A declared narHash is verified against the fetched tree on the cache-hit and fresh paths alike, and a mismatch is an error in upstream's orientation (expected is what the fetch produced, got is the declared pin), never a silent recompute; upstream matched from nix-instantiate 2.33.2. An attribute outside the supported set (url, name, ref, rev, submodules, shallow, allRefs, narHash) is refused instead of silently dropped, which is exactly how the unhonored pins stayed invisible. A failing fetch no longer leaks its scratch clone: every throwing step runs under a new onEvalError cleanup primitive, the error half of a bracket. (#188)- **`builtins.placeholder` is substituted at build time.** `builtins.placeholder "out"` evaluates to a sentinel, since an input-addressed derivation's output path is a hash of the derivation itself and the expression cannot name a path it hasn't produced yet. The sentinel now gets replaced in a derivation's `args` and in its environment, names as well as values, at the spawn boundary, with the same per-output path `$out` already carries, so argument-passing and environment-passing builders agree on where to write. Upstream rewrites the whole `name=value` string rather than the value alone, so a placeholder in a dynamic attribute name is substituted too. This is what lets a builder that takes its destination as an argument rather than reading the environment (stage0's `hex0 input output`) be driven directly. The builder path itself is left alone: a placeholder there would name a program that does not exist yet. (#126)### Store- **Eval-time store writes are verified at both ends: writers rewrite a mismatched leftover, and registration refuses content that does not reproduce its path.** Every eval-side writer skipped its write when the destination existed (and the fetchurl writer wrote unconditionally, crashing on a sealed leftover), so a file truncated by an interrupted earlier run was adopted as-is, registered valid under the hash of the content it should have had, sealed read-only so nothing could repair it, and then consumed by builds. Writers now adopt an existing destination only when its bytes are the intended bytes (raw comparison for toFile and fetchurl, recursive NAR digest for source copies and builtins.path) and otherwise clear and rewrite, which is where the bytes exist to rewrite with, matching upstream's delete-then-rewrite in addTextToStore. Registration independently re-derives each recorded path from its on-disk content under the scheme that named it (the write cache now carries text, recursive, or flat alongside the references) and refuses loudly on a mismatch rather than sealing a hash the bytes do not have. (#182)- **The eval-side materializers join the per-path lock protocol.** materializeEvalSources ran its check-then-act with no lock: two processes materializing the same source path raced the validity check, and the loser's clear-and-recopy deleted the tree the winner had just registered. Both materializers now run each path's adopt or prepare under the same cross-process path lock the builder and substituter hold, with validity re-checked once the lock is held, so a peer mid-producing a path is waited out rather than raced. The store-write materializer's batched registration stays outside the lock deliberately: registration is an upsert over content both holders verified reproduces the same path. (#192)- **A concurrent invocation waits for the store database instead of dying on ErrorBusy.** SQLite's default busy timeout is zero, so while one process held a write transaction (a registration mid-commit), a second nova-nix crashed in under a tenth of a second with an uncaught SQLError instead of waiting its turn, which at build volume means any concurrent pair of builds or substitutions could kill one side. The connection now sets the one-hour busy timeout upstream configures at open (sqlite3_busy_timeout, sqlite.cc at 2.28.7; the pragma reaches the same API), so concurrent invocations queue on the database exactly as upstream's do. (#180)- **The executable bit survives on Windows.** A NAR records whether each regular file is executable, and a store path's identity is the hash of that. Windows has no such bit: `getPermissions` answers from the file's extension there, so a checked-out `configure` serialised as non-executable and a tracked `foo.exe` as executable, whatever either one was, and the substituter's unpacked tree then failed to reproduce the declared hash, so any cached path holding a mis-extensioned executable was downloaded, rejected, and deleted. The bit now lives in an NTFS alternate data stream whose presence is the bit. `builtins.fetchGit` sets the marks from git's index before `.git` is stripped. On Unix nothing changes. (#128)- **Windows NAR hashing streams instead of materializing the tree in memory.** The executable bit lives in an alternate data stream that nova-cache's own walk could not see, so on Windows narHashOfPath serialised the whole tree in memory and rewrote the flags afterwards. nova-cache 0.11.1 added the exec-bit resolver hook for exactly this: the walk now asks the ADS source of truth per regular file, with the on-disk case-hack-suffixed name, so hashing streams in chunks on every platform and the post-hoc flag-rewrite walk is gone. (#191)### Builder- **A build writes into its output path, not into a temp directory it is moved out of.** `$out` is now the final store path, as upstream's is. Building somewhere else and moving afterwards looks equivalent and is not: anything that records where it was built (a compiler driver, a libtool archive) recorded the temp path, which is deleted the moment the build ends, leaving a store path that isn't self-contained and that the reference scanner can note but not repair. A stale tree from an interrupted run is cleared before the builder starts rather than at registration, and a failed build takes its partial output back out of the store, an interrupted one included. (#130)- **A partial rebuild no longer hands the builder an output that is already valid.** A multi-output derivation with one output deleted still runs one builder, which writes every output; a registered path's `NarHash` describes bytes that must not change, and it is sealed read-only besides. Such an output gets a scratch path for the duration of the build, discarded afterwards, exactly as upstream's `makeFallbackPath` does. Where upstream then rewrites the scratch path back out of the produced outputs' contents, this refuses instead: an output that recorded a scratch path fails the build and names it. That divergence is deliberate, because a dangling reference becomes a loud failure rather than a registered lie, and it is the only part of upstream's hash-rewriting machinery not reproduced here. (#130)- **Builders run in a scrubbed environment: the ambient environment no longer flows into builds.** The child process previously inherited every host variable not overridden by the build environment, so a builder consulting an undeclared variable embedded machine-specific data in its output, undermining the reproducibility SOURCE_DATE_EPOCH exists to pin. Upstream builds in a cleared environment (initEnv begins with env.clear() and the child is exec'd with exactly that block), and nova-nix now matches: on Unix nothing ambient passes through, and on Windows, where a process block cannot be empty, exactly SystemRoot, SystemDrive, and windir pass through (SystemRoot is a hard execution requirement, verified on a clean Windows 11 machine, where the CLR's crypto provider fails to load without it), COMSPEC is synthesized from SystemRoot, and PATHEXT is pinned to .COM;.EXE;.BAT;.CMD instead of inheriting the host's resolution rules. All four temp-directory names (TMPDIR, TEMPDIR, TMP, TEMP) now point at the build directory, matching upstream's single assignment of all four; scrubbing without repointing them would send Windows temp files to the Windows directory itself. (#186)- **A fixed-output derivation's impureEnvVars reach the scrubbed build environment.** Upstream's carve-out for fetchers that need proxies: the variables the derivation's impureEnvVars attribute lists are copied from the ambient environment into the child, gated on the derivation being fixed-output (upstream gates on the type being non-sandboxed, which for nova-nix is exactly the fixed-output case). A listed variable absent from the ambient environment is set to the empty string, not omitted, and the carve-out is written last so it wins even over the derivation's own values, both matching upstream's initEnv. Every other derivation still sees only the scrubbed allowlist. (#190)- **On Windows a build's process tree runs in a Win32 job object, so an interrupt or a builder exit no longer orphans grandchildren.** The builder was spawned without process-tree containment, so terminateProcess reached only the direct child: on Ctrl-C or a nonzero builder exit, a builder's whole grandchild tree (bash to make to cc, or anything cmd.exe spawned) was orphaned and kept running. The build spawn now sets use_process_jobs, wrapping the tree in a job with kill-on-job-close, so terminateProcess becomes TerminateJobObject and reaps the whole tree and waitForProcess waits for all of it. This is Windows only; POSIX builds are unchanged, and there is still no build timeout. It is phase one of build sandboxing (process containment); filesystem and privilege isolation and resource limits remain tracked in #194 and #195. (#196)### Substitution- **Substituting a store path whose symlinks have multi-component targets now works on Windows.** A symlink target like bin/tool was stored by Windows as a reparse point with backslashes, so re-serialising the unpacked tree read it back as bin\tool, the NAR hash no longer matched the signed narinfo, and the on-disk recheck failed the substitution systematically (a hard failure, never silent corruption). nova-cache 0.11.1.1 normalises a symlink target's separators to the POSIX spelling at the NAR boundary on Windows. (#198)### Windows packages- **`pkgs/windows` follows the nixpkgs layout, and the package set is a fixpoint.** Packages moved to `by-name/<shard>/<pname>/package.nix` (shard = the pname's first two characters), the stdenv machinery to `stdenv/`, and the sha256-pinned MSYS2 seeds to `bootstrap/`. `pkgs/windows/lib.nix` adds `callPackageWith`, modelled on nixpkgs' `lib.customisation.callPackageWith`, and `default.nix` discovers `by-name` with `builtins.readDir` and calls each `package.nix` through it. A package now declares its dependencies as formal parameters (`{ stdenv, zlib }: ...`) and callPackage supplies them from the set, instead of each recipe reaching across the tree with a relative import; adding a package is adding a directory. The walk reads the entry type `readDir` returns, so a stray file in `by-name` is passed over rather than opened as a directory. No recipe changed beyond its dependency plumbing, but every one of them moved, so all six drvPaths change and nothing already built is reused. `pkgs/windows/hello.nix` now builds the by-name GNU Hello through the stdenv, so its executable is at `bin\hello.exe`, where `make install` puts it, rather than at the output root. (#127)- **Windows source fetches retry ordered mirrors and verify every download.** `pkgs/windows/fetchurl.nix` accepts a non-empty `urls` list for flat fixed-output downloads. HTTP errors, incomplete responses, and hash mismatches advance to the next URL; only verified bytes enter the store. Cancellation stops the build and releases its output lock without trying another mirror. Hello, sed, and zlib use multiple pinned source locations. Their source and package output paths stay unchanged, while their derivation paths change to describe the new inputs. The bundled upstream `fetchurl.nix` remains unchanged, and single-URL calls retain its interface. (#203)### Dependencies- **nova-cache moves to `>= 0.11.1.1 && < 0.12`, with the xz binding pinned to its bundled sources.** The 0.11.1 releases carry four things this project consumes. The per-file executable-bit resolver (`SerialiseOptions`, `withNarSourceOpts`) is the seam the Windows alternate-data-stream executable model plugs into, streaming verifier included. The POSIX default executable answer now reads the file's own owner-execute bit as upstream's dump does, where it previously asked `access(2)` what the calling process could do, so NAR bytes stop depending on who serialised (root, ACLs, and foreign-owned files were the divergence). A symlink target's separators are normalised on Windows. And the xz codec's binding moved off the Hackage-deprecated `lzma-static` onto its successor `xz`, which prefers a pkg-config-found system liblzma; the new `constraints: xz -system-xz` line pins the bundled sources so every build links the same C regardless of the host. (#177, #191, #198)## 0.7.0.0 - 2026-08-22- **A copied nova-nix finds its own bundled expressions.** The `<nix/*>` search path came from Cabal's `getDataDir`, which bakes an absolute path in at configure time naming the machine that did the build. That is right for a local `cabal install` and wrong for every copied or downloaded binary: `import <nix/fetchurl.nix>` resolved to a directory that does not exist on the host running it, and the Windows package recipes all open with that line. The data dir now comes from `NIX_DATA_DIR` when set (upstream's own variable name), otherwise from `share/nova-nix` beside the executable's own `bin` directory, which is the layout a release archive ships and needs nothing configured, and otherwise from Cabal as before, so a local install is unchanged. The build matrix now checks both fallbacks against a relocated copy with Cabal's own override pointed at nothing, so a pass cannot come from the baked path.- **Tags publish downloadable binaries, not only a Hackage sdist.** Seventeen tags had produced zero GitHub releases, because the publish workflow only ever uploaded an sdist, so the only way to get nova-nix was to build it. Each tag now also attaches a per-platform archive for Linux, macOS and Windows, carrying `bin/` beside `share/` and `pkgs/`, so an unpacked copy resolves `<nix/*>` and builds with no toolchain and nothing to configure, plus a `SHA256SUMS` file generated over the exact uploaded bytes. The recipes ride along because they are what there is to build: every path in `pkgs/` is either relative to itself or the `<nix/*>` entry `share/` already provides, so the command the README opens with runs against the unpacked copy rather than needing the repository cloned beside it. Every archive is smoke-tested before it is attached, and the release is created as a draft and only published once all four assets are present, since `releases/latest/download` is a public URL that must not exist while empty. (#12)  Two gaps the first cut left open. The smoke test ran on the machine that built the binary, where a full GHC toolchain sits on `PATH`, so it could not tell a self-contained executable from one quietly finding its DLLs next door; the Windows archive is now run again with `PATH` cut to the system directories, which is the download's actual situation, so a dependency that starts linking zlib, zstd or libgcc dynamically fails the release instead of the first person to unpack the zip. And the Hackage upload waited only on the checks, not on the archives, so a tag whose binaries failed to build would still have taken the one step of a release that cannot be undone: a Hackage version is immutable. It waits on the packaging job now.- **`nova-nix --version` and `--help` answer, and `--help` answers on stdout.** A downloaded binary could not say what it was. The CLI had no version handling at all, so a bug report from a machine with no toolchain had no way to name the build it came from, which is most of what a release exists to enable. `--help` did not work either, failing with `unknown argument: --help`: usage came only from a bare invocation, on stderr, exiting non-zero. Both are flags now, answered before the rest of the line is parsed, so `--version` reports the build even when the command after it is one this build does not have. The two spellings of usage keep their difference for the reason they have one: a bare invocation is a usage error and stays on stderr with a non-zero status, while `--help` is a request that succeeded and goes to stdout exiting zero, so it pipes without redirecting stderr. The version is Cabal's, the one the publish workflow's tag guard already checks a tag against, and the archive smoke test now asserts the binary agrees with it before the release is attached: the guard reads a source tree, this reads the executable actually built from it.- **`--store` is honored on evaluation's reads, not only its writes.** The store directory reached the five eval-time write sites and none of the eleven read sites, which resolved through the platform default, so a redirected store was written to and then read from somewhere else: `builtins.readFile (builtins.toFile "a" "hi")` wrote the file into the chosen store and then failed to find it under `/nix/store`. `builtins.path`, `filterSource`, `fetchGit` followed by `import`, and every other eval-time read had the same split. Before the store directory reached evaluation at all both sides ignored the flag and were at least consistent with each other, so this was newly broken rather than long-standing. The resolver takes the store directory it should read from instead of assuming the platform one, and evaluation passes the store it was given.  No test caught it because the integration harness built its evaluator with the platform store while handing the build a different one, so the two halves were never asked to agree. The harness now uses one store for both. (#145)- **Every store object evaluation writes is registered, not only `builtins.toFile`'s.** `writeToStore` recorded its writes for the build driver to register; `copyPathToStore`, `addSourceNar` and `addFixedOutputFile` recorded nothing, so a path from `builtins.path`, `filterSource`, `builtins.fetchurl`, or `builtins.fetchGit` reached `drvInputSrcs` with no registration row and the build died with `registerPaths: ... references unregistered path`. That made `builtins.fetchGit`'s `outPath` unusable as a derivation input, which is the reason it computes one. Recording now happens in one place every eval-time writer goes through, rather than being repeated per builtin and forgotten in three of four.- **The release workflow's artifact actions match the rest of CI.** `publish.yml` pinned `actions/upload-artifact@v4` and `actions/download-artifact@v4` while `ci.yml` was already on v7, so the workflow that produces every release asset was two and four majors behind the one that builds them. Both move to the current majors (upload v7, download v8), whose inputs the workflow already uses.- **CI lints its own workflows.** Haskell, C and source encoding were all covered while `.github/workflows/` itself was validated only by GitHub agreeing to parse it after a push. `actionlint` now checks `uses:` references, `${{ }}` expressions, matrix references and job dependencies, and runs shellcheck over every `run:` block, pinned to a version rather than floating so a lint release cannot turn an unrelated pull request red.- **A build holds its outputs' path locks, so two builds of one derivation cannot interleave.** Per-path locks made delete, materialize and register a single critical section, and the build path never joined it, while `computeBuildDir` hands both processes the same build directory. Two concurrent builds of one derivation therefore wrote into one tree and registered the result as valid: reproduced with a builder appending a line per second, where the registered output held eight interleaved lines instead of six and nothing reported an error. A build now takes every output's lock before it starts and holds them until registration commits, and re-checks validity once they are granted so a derivation another process finished while we waited is adopted rather than rebuilt over. Outputs are locked in store-path order so two processes racing a multi-output derivation request them in the same sequence, and a build holds locks for its own outputs only, so there is no cycle to deadlock on.- **`builtins.fetchGit` validates `ref` and `rev` before they reach git, closing an eval-time command execution.** Both attributes were spliced straight into git's argument vector with no separator and no shape check, and git parses options after the remote name, so a `ref` of `--upload-pack=<cmd>` named the command git runs as the transport. With a local or `file://` url (both accepted, and the local transport is enabled in the clone's own config) git ran that command through a shell, so evaluating an untrusted expression executed it and the evaluation still succeeded with an ordinary attrset. `ref` is now checked against upstream's `refRegexS` and `rev` against its `revRegexS`, the same shapes upstream enforces before either value reaches git, and `--` separates the positional arguments in `git fetch`. Rejecting an abbreviated `rev` is upstream parity in its own right: a revision that still resolves through git's DWIM rules is not pinned. (#143)- **The Windows stdenv builds again: no drive letter in derivation text.** `mkDerivation` passed its setup script as `/cygdrive/c${setup}`, a hardcoded drive glued in front of a canonical store path. Once the builder began rendering `/nix/store` to the machine's real store directory at the spawn boundary, the two composed into `/cygdrive/cC:\nix\store/...-setup.sh` and every `mkDerivation` package failed before the builder's first line. The same rewrite reaches environment values, so `setup.sh`'s mapping (which matched on the canonical spelling) stopped firing and put a drive-lettered path into a colon-separated `PATH`, splitting the entry in two. Derivation text is now canonical throughout, which is what its hash is computed over and the only spelling that is correct on a store that is not on C:. `setup.sh` maps native paths to the two forms its consumers need, MSYS2 `/cygdrive/<drive>` for bash and mixed `C:/` for the native mingw tools, in pure parameter expansion, so it no longer shells out to `cygpath` (which the seed's package set does not provide) and no longer infers a drive from `$NIX_STORE`. The Windows E2E job now builds GNU hello through the real stdenv: the existing job drives `cmd.exe` directly and never loaded `stdenv.nix`, which is why this went unnoticed. (#144)- **`--store` reaches evaluation, not only the builder.** Evaluation resolved every store read and write through the platform default (`C:\nix\store` on Windows, `/nix/store` elsewhere) while the builder honored the flag, so a non-default store left evaluation writing to one directory and the build reading from another. The store directory is now carried in the evaluation state and every eval-time store path resolves through it. A derivation's own strings are rendered at the spawn boundary for the same reason: the builder path, its arguments and its environment values all carry the canonical `/nix/store` spelling that hashes depend on, and that text is mapped to the configured directory only as the process is spawned. On Windows this is what lets a store-path builder be executed at all, since a bare `/`-rooted path there resolves against the current drive rather than the store's.- **`builtins.fetchGit` fetches a pinned revision, not just a branch tip** - `rev`, `ref`, `submodules` and `shallow` are all now read from the argument set, `git fetch`/`checkout` replace the old unconditional `--depth 1` clone, and the result is the same attrset upstream's returns: `outPath`, `rev`, `shortRev`, `revCount`, `narHash`, `lastModified`, `lastModifiedDate` and `submodules`, all read from the clone before its (and every submodule's) `.git` metadata is stripped and it is copied to the store. Checked against a real Nix on the same two repositories: identical `outPath`, `narHash`, and every other field, submodule fetches included.- **Substitution accepts bzip2, so historical cache paths and narinfos with no Compression field at all can be fetched.** cache.nixos.org narinfos written before the xz switch declare `Compression: bzip2`, and upstream C++ Nix reads an absent or empty Compression field as bzip2, so those paths could only ever fail here: the register named the codec in its rejection but no decoder stood behind the name. Both decompression paths - streaming and the strict oracle - now dispatch it through nova-cache 0.11's bzip2 sublibrary, bounded by the declared NarSize exactly as xz and zstd are, with stream errors retried and output past the bound refused as the served object misdeclaring; there is no decoder-memory knob to set, because bzip2 carries no attacker-chosen dictionary size and its decoder state is a small constant of the format. The empty spelling now decodes rather than rejects, completing the upstream parity the register was written for. The bound rises to nova-cache >= 0.11 && < 0.12 with the bzip2 sublibrary added to the library's set, and the pinned index-state advances past the release. 0.11 also tightens the zstd codec, which the suite now pins: a truncated frame and trailing bytes after the last frame refuse with a stream error instead of yielding a short output, so truncation is caught at the codec rather than left to the NAR grammar above it. (#115)- **Cancellation is never spent as retry budget nor as cache fallthrough.** The retry classifier already re-threw asynchronous exceptions, but the per-cache catch-all one frame up converted every exception into a substitution error, so a Ctrl-C or timeout arriving mid-download was swallowed, the cache scan continued, and the build fell through to building locally instead of aborting. The sync/async split now lives in one shared helper used by the retry classifier, the per-cache attempt, and the builder's top-level catch-all: only synchronous exceptions convert into recoverable failures, and an interrupt propagates out of the whole operation.- **Per-store-path locks close the substitution race.** The streaming substituter deleted the destination before the first byte downloaded, with no lock and no validity re-check anywhere, so two processes sharing a store could interleave delete, materialize, and register into a valid database row pointing at deleted or torn bytes. Substitution now takes an exclusive lock on upstream's "\<store-path\>.lock" file - a raw write-access descriptor locked through filelock (flock on POSIX, LockFileEx on Windows; CC0-licensed, so nothing encumbers the Apache-2.0 distribution), because base's Handle-based locks cannot express this lock - before touching the destination, re-checks validity under the lock and adopts another process's finished path instead of deleting and redoing it (waiting on a busy lock is announced, as upstream does), and holds the lock across download, materialization, the on-disk recheck, and the caller's registration transaction, releasing it on every exit path. The protocol is upstream C++ Nix's pathlocks mechanism (src/libstore/pathlocks.cc and the substitution path in local-store.cc) exactly. One deliberate divergence, documented in Nix.Store.Lock: lock files persist instead of being marked and deleted, which removes upstream's deleted-lock-file hazard outright and needs no separate Windows path.- **store delete joins the per-path lock protocol, and lock files are not delete targets.** The delete command ran its unregister-and-remove sequence with no lock, so a delete racing another process's substitution of the same path could remove the freshly materialized tree between the substituter's on-disk recheck and its registration commit - the exact valid-row-pointing-at-deleted-bytes race the locks close, reopened through the other door. Deletion now holds the target's path lock across the whole sequence, blocking (with the announced wait) while a substituter holds it, as upstream's deletePath does. A target naming a lock file is refused with the reason: lock files are never deleted here by design, and removing one would reopen the deleted-lock-file hazard that design removes. Names like flake.lock are legal store-path names, so the refusal consults the registration rows: only an unregistered file whose suffix-stripped name is a well-formed store basename reads as a lock file, and a registered object of the same shape deletes normally.- **zstd, both directions: substitution accepts it, push can produce it.** The modern caches (Cachix, attic, FlakeHub) serve NARs zstd-compressed; both decompression paths - streaming and the strict oracle - now speak it through nova-cache 0.10's zstandard sublibrary, bounded by the declared NarSize like xz (the strict decompressor's resolved function moves into IO: the zstd binding's decoder is IO-native, and the shape follows the codecs). Push gains --compression none|zstd, a property of the destination cache as upstream models it - none stays the default so existing cache content stays uniform - with the compressed object named by its own file hash and the narinfo's file fields describing it. The bound rises to nova-cache 0.10 with the zstandard sublibrary and the pinned index-state advances past the release. (#111)- **Substitution failures carry a retry class, and every failure path cleans up.** Exceptions thrown mid-stream - a dropped connection, a full disk - previously escaped both the retry budget and the partial-tree cleanup, so the single most common transient failure never retried and could orphan an unverified tree at the store path. Every attempt now converts synchronous exceptions into the pipeline's failure channel (asynchronous cancellation re-throws untouched) and removes the tree on every exit. Failures classify explicitly, matching upstream's transfer layer: transport errors, torn transfers, and truncation retry with backoff; a completed transfer that verifies wrong, a body past its ceiling, or a 4xx fails at once, since retrying a deterministic failure only delays the local-build fallback.- **The NAR download cap derives from the signed NarSize.** The compressed-body cap was keyed to the narinfo's FileSize, which the Ed25519 fingerprint does not cover, so a rewritten FileSize on a validly-signed narinfo could buy an unbounded download. The cap is now a ceiling computed from the signed NarSize plus a small framing-overhead margin, and the unsigned FileSize may only lower it, never raise it. Caches that omit FileSize (on-the-fly compressors) gain the same margin, so incompressible NARs whose compressed body slightly exceeds NarSize substitute where they previously aborted.- **An empty Compression field means bzip2, never identity.** Upstream decodes an absent or empty Compression as bzip2, the field's historical default, and nova-cache's parser matches that coercion; treating the empty string as identity diverged from it. The compression vocabulary now lives in one register (Nix.Compression) parsed once at the narinfo boundary, so the streaming and strict dispatch cannot drift.- **Substitution streams: download, decompress, hash, parse, and unpack in one bounded pass.** The substituter realized every NAR in memory before touching disk - an RSS spike the size of the path being fetched, documented in place since the first cut. The pipeline now drives nova-cache's streaming pieces end to end: the HTTP body feeds the bounded xz source, the incremental hash, the chunk-fed NAR parser, and a new streaming store sink that materializes events as they arrive, so memory is bounded by decoder buffers and the parser's structural-string cap, never by archive or file size. Disk writes therefore begin before the hash can be known - upstream's ordering exactly - and any failure or mismatch removes the tree it wrote; the on-disk recheck streams too. One divergence, documented at the sink: sibling names colliding on a folding filesystem always take upstream's case-hack renaming, never the NTFS true-name path, which can only be enabled on an empty directory the stream cannot pre-scan. (#107)- **Substitution from cache.nixos.org works: xz NARs decompress.** The default cache serves every NAR xz-compressed, and decompressorFor rejected the value up front, so the shipped configuration could never substitute a single path. nova-cache 0.9's bounded decoder is wired in via its public nova-cache:xz sublibrary - an ordinary solver-visible dependency, no flags on either side; the bound rises to >= 0.9 && < 0.10 and the pinned index-state advances past the release - with output capped at the narinfo's signed NarSize and decoder memory at nova-cache's default, so a hostile stream expands to nothing the narinfo did not promise. Unsupported compression values still reject before any download is paid for. Verified against production data: recorded cache.nixos.org narinfos parse, validate, and signature-verify offline in the suite, and a real path substitutes end to end from the live cache. (#27)- **nova-cache 0.8.0.0.** The bound rises to >= 0.8 && < 0.9 and the pinned index-state advances past the release. NAR parsing now rejects the full Windows reserved-device set at the parse boundary - COM0/LPT0, space-padded device stems ("NUL .txt"), and the superscript-digit forms - the same names materialization already refused, so the refusal moves earlier and the two guards agree. 0.8 also brings the streaming NAR interface and the NarSize-bounded xz decoder that foreign-cache substitution builds on next.- **builtin:unpack resolves srcs through the store dir.** The srcs env value carries eval's canonical /nix/store spelling; unpack opened it verbatim, and on Windows a bare /-rooted path resolves against the current drive - the build worked only when the process happened to run from C:. Found by the e2e job's first flights (#100) on GitHub's D:-workspace runners. Each srcs entry now parses as a store path and renders through the configured store dir (the identity on Unix), a non-store-path entry fails loudly, and the e2e job no longer pins its working directory. (#101)- **Toolchain: GHC 9.14.1 (the first GHC LTS release)** - CI, the release pipeline, and the README badge move from GHC 9.8.4 to 9.14.1. GHC 9.14 opens GHC's new LTS scheme (a minimum of two years of bugfix releases), and under that scheme every earlier series stops receiving fixes, so no version in between had a future. Dependency bounds already admitted the newer compiler and the full set resolves on it. The project targets the LTS alone: base >= 4.22, and foldl' comes from the Prelude, so its eleven redundant Data.List imports are gone. The deprecated pattern namespace specifier stays for now - hlint cannot yet parse the data replacement GHC suggests - with its deprecation warning muted in the cabal file until hlint learns the new spelling.- **`builtins.toFile` writes are registered before a build that names them.** `writeToStore` computed a content-addressed path and wrote the bytes during evaluation, but nothing registered it, so a derivation naming a `toFile` output as an input died with `registerPaths: ... references unregistered path ...`. The write is recorded in eval state and registered in one batch by the build driver, before building - the same treatment `materializeEvalSources` already gives path literals eval coerces into the store, batched so a text path referencing another resolves. The write is idempotent too: the path is the hash of the bytes, so a file already there already holds them, and skipping the rewrite avoids a permission error on a second evaluation once registration makes the path read-only.- **A path literal resolves against the file it is written in, not the file being evaluated when it is forced.** Relative path literals were rewritten to absolute ones only for `import`ed and `scopedImport`ed files; the top-level file and `--expr` were left to resolve at force time against whatever directory the evaluator happened to be in. Those differ whenever a literal outlives the scope it was written in, and `builtins.scopedImport { q = ./data.txt; } ./sub/useq.nix` is the short way to see it: `q` is forced during `sub/useq.nix`'s evaluation, so `./data.txt` named `sub/data.txt`, and `builtins.readFile` on it returned the wrong file's contents into whatever consumed them. Resolution is now part of parsing, which is where upstream does it (`absPath(path, state->basePath...)` in the `PATH` production through 2.24, `CanonPath(literal, state->basePath.path).abs()` in 2.35, unchanged in between), so `parseNix` takes the directory to resolve against and no caller can skip the step. A second bug fell out of widening it: `~/x` was treated as relative and joined to the importing file's directory, burying the tilde mid-path where nothing expands it, so `~/x` inside an imported file resolved to `<dir>/~/x`. Home-relative literals are now left for the evaluator, which expands them against `HOME`.- **A value that needs no evaluation is shown, not reported as a thunk.** Printing an unforced list or attr set showed `<thunk>` for entries that were already values: `[ "a" "b" ]` came back as `[ <thunk> <thunk> ]` where upstream prints the strings, `[ ./x ]` and `[ [ ] ]` the same, and every attr set value regardless of what it was, so `{ a = 1; }` reported a thunk over the literal `1`. The cause was that the decision was made on how a value is represented at runtime (an integer fits an immediate slot, a string does not) rather than on what the expression is, which is what upstream asks: `maybeThunk` is overridden by `ExprInt`, `ExprFloat`, `ExprString` and `ExprPath` to hand back a value already built, and both `ExprList::eval` and the non-recursive branch of `ExprAttrs::eval` go through it. String and URI literals, path literals, and the empty list join the integers and booleans that were already answered directly, and a non-recursive attr set resolves its values the same way; recursive sets and `let` still defer, because the frame their variables point into is still being tied. Path literals can only be answered here because parsing now resolves them, so what reaches the evaluator is already absolute; a `~/` literal still defers, since expanding it reads the environment. Checked against a real `nix-instantiate` 2.24.9 in CI rather than against a reading of its source, and the same overrides are byte-identical in 2.35.2.  Empty containers print as `[ ]` and `{ }` rather than with the two spaces a join of no elements left between the brackets.## 0.6.0.0 - 2026-06-12### Milestone: A Stage-1 stdenv That Builds Real Softwarenova-nix now builds real third-party software from source on Windows through a small stage-1 stdenv. A package is `{ name; src; buildInputs; }`, and a `setup.sh` genericBuild drives unpack, configure, build, install, and a fixup that makes outputs standalone - proven on GNU hello, GNU sed, and zlib plus a program that links it.- **New: a store-pinned MSYS2 userland seed and `mkDerivation`** - the seed bash runs `setup.sh`, which unpacks the source, runs `./configure && make && make install`, and builds through the mingw toolchain. GNU hello and GNU sed build from source with a two-line derivation.- **New: `buildInputs`** - a package depends on another package. Each input's `include/` goes on `CPPFLAGS`, `lib/` on `LDFLAGS`, and `bin/` on `PATH`, and its derivation builds first. Proven by libgreet (a library built from source) and greeter (a program that links it).- **New: a `cc-wrapper`** - a `gcc`/`cc` shim installed on the build `PATH` ahead of the real toolchain. It strips ambient header/library search paths from the environment (hermeticity), defaults to `-std=gnu17` so classic gnulib-bearing sources compile under gcc 15+'s C23 default, and adds `-Wl,--no-insert-timestamp` for reproducible PE headers. A package can override the standard with its own `-std`.- **New: a fixup phase** - Windows has no RPATH, so a distributable binary must carry its non-system DLLs beside it. fixup reads each output binary's PE import table and, for every imported DLL outside the guaranteed Windows ABI, finds it among the declared inputs and bundles it, recursing to a fixpoint. An undeclared non-system DLL fails the build rather than shipping silently broken.- **New: build-phase overrides** - optional `dontConfigure` / `buildPhase` / `installPhase` attrs let a package build differently from the autotools default (e.g. via a hand-written makefile) while the common case stays a two-line derivation.- **Real third-party library: zlib 1.3.2** - its `./configure` emits Unix `.so` naming under MSYS2, so zlib builds via its `win32/Makefile.gcc` for a proper `zlib1.dll` and `libz.dll.a` import lib. A demo links zlib (statically against `libz.a`, or dynamically against `zlib1.dll` with the DLL bundled) and round-trips data.- **Relicensed from BSD-3-Clause to Apache-2.0.** Apache adds an explicit patent grant and trademark terms, and a `NOTICE` file now carries the copyright (Novavero AI Inc.). Earlier releases on Hackage remain under BSD-3-Clause.- **Substituter: retry transient NAR download failures** before falling back to a local build, matching Nix's `download-attempts` (5 attempts, linear backoff), so a dropped connection or a stale CDN negative no longer forces a rebuild.- **`builtin:fetchurl` sends a User-Agent**, so hosts that reject empty-UA requests (some GNU mirrors) serve the fetch.- **Docs:** 100% Haddock coverage across all modules.## 0.5.0.0 - 2026-06-11### Milestone: Push and Pull Against a Binary CacheA native Windows build can now publish its outputs to a binary cache and substitute them back on another machine. The toolchain seed and the `hello` build push to `cache.novavero.ai` with `nova-nix push`, and a fresh store realizes them by signed download instead of rebuilding.- **New: `nova-nix push`** - uploads store paths and their full reference closure to a binary cache. Each path is NAR-serialized (via `nova-cache`), its NAR uploaded before its narinfo so a client never sees metadata pointing at absent data, and the server signs each narinfo on receipt. Already-cached paths are skipped via one `GET /narinfo-hashes` diff, the recorded NAR hash is cross-checked against the store database before upload, and a signed round-trip is verified at the end. Published narinfos use the canonical `/nix/store` path form. Usage: `nova-nix push --cache URL --key-file KEY (--all | <paths>)`.- **New: `build --substituter URL --trusted-key K`** - try a binary cache before building. The trusted key (`name:base64`) is required alongside the substituter, since substituting without signature verification would be unsafe; the build falls back to local compilation for any path the cache lacks.- **New: `--store DIR`** - run a command against an alternate store directory instead of the platform default, so a build or push can target a scratch store.- **Reproducible `hello`** - `hello.nix` links with `-Wl,--no-insert-timestamp`, and the builder pins `SOURCE_DATE_EPOCH` (1980-01-01) for every build, so determinism-aware tools write fixed timestamps. Two cold bootstraps produce a byte-identical `hello.exe`.- **Dependencies modernized** - builds against `nova-cache >= 0.4.2` (Ed25519 signing, `normalizeKeyText`), `crypton >= 1.1` with `ram` replacing the deprecated `memory`, and current upper bounds for `containers`, `http-client-tls`, and `time`. No source change beyond the dependency swap; derivation-hash parity is unaffected (CI-verified).## 0.4.0.0 - 2026-06-10### Native Windows builds`nova-nix build pkgs/windows/hello.nix` compiles and runs a C program through a Nix derivation, natively on Windows: evaluation records the derivation closure, the builder realizes 17 fixed-output fetches and a toolchain unpack in dependency order, and a compiler that is itself a store path produces `C:\nix\store\...-hello\hello.exe`: nova-nix's first package built natively on Windows.- **New: `builtin:unpack`** - an in-process archive extractor, the counterpart to `builtin:fetchurl`: the unpacker is the thing being bootstrapped, so it cannot be a store tool, and ambient `tar` is unpinned. Extracts `.tar.zst`/`.tar` archives listed in `srcs` into the single `out` output, in order. MSYS2 packages share the `mingw64/` prefix, so a package set merges into one working toolchain root. Symlink and hardlink entries are materialized as copies (store outputs must not require Developer Mode), pacman per-package metadata is skipped, and cross-archive file collisions and path traversal fail the build loudly. MSYS2's zstd frames carry no pledged content size, so decompression is streaming. New dependencies: `tar >= 0.7.1`, `zstd`.- **New: `pkgs/windows/seed.nix`** - stage 0 of the native Windows stdenv: the 17-package runtime closure of `mingw-w64-x86_64-gcc`, sha256-pinned against `repo.msys2.org`, fetched and merged into a single toolchain root. `pkgs/windows/hello.nix` is the proof build; its recipe also documents the Windows DLL rule (a subprocess resolves DLLs via `PATH`, not RPATH, so dependencies' `bin` dirs go on the build `PATH`).- **Fix: the build driver materializes eval-coerced source paths** - `src = ./file` produced only the source store path *text* during evaluation (eval performs no store writes - the parity runner's store is not writable), so input validation failed on the missing path. The driver now copies each coerced source into the store, marks it read-only, and registers it with its real NAR hash before building.- **`data/nix/fetchurl.nix` documentation rewritten as original prose** - the functional content is fixed byte-for-byte by derivation-hash parity and is unchanged (CI-verified).## 0.3.0.0 - 2026-06-06### Milestone: Derivation-Hash Parity with Upstream Nix`(import <nixpkgs> {}).hello.drvPath`, and all 253 derivations in its closure, now hash byte-for-byte identically to `nix-instantiate`, verified in CI on the same nixpkgs tree. A new `eval --aterm` mode dumps a derivation's ATerm for diffing against `nix derivation show`.- **Fix: indented-string indentation is stripped per literal string-part, before interpolation** - the common indentation was removed from the fully-interpolated string, so a multi-line interpolated value (e.g. `${commonPreHook}` in the stdenv `preHook`) could lower the computed minimum indent to zero and leave the literal lines indented. Indentation is now computed from the literal parts only - interpolated values are opaque content - matching C++ Nix.- **Fix: path literals interpolated into strings are copied to the store** - `"${./foo}"` left the raw source path in the result; it now copies the file to the store and yields its store path, with the path added to the string context so it lands in the derivation's `inputSrcs`. `builtins.toString` still does not copy, per Nix semantics.- **Fix: `builtins.placeholder`** - now returns `/` followed by the full SHA-256 of `nix-output:<name>` in Nix base-32, matching Nix's `hashPlaceholder`. It previously truncated the hash and wrapped it as a `/nix/store` path, so any derivation using `${placeholder "out"}` (e.g. perl's `configureFlags`) diverged.- **Fix: a derivation's default output is its first declared output** - a bare reference to a multi-output derivation now resolves to `outputs[0]` (both name and path), not a hardcoded `out`. This affected packages whose first output is not `out`, such as `xz` (first output `bin`).- **Fix: `builtins.attrNames` is sorted lexicographically** - names were returned in interned-symbol order rather than sorted by key, and inconsistently with `builtins.attrValues`. Surfaced in `fetchurl`'s `impureEnvVars` (the generated `NIX_MIRRORS_*` list).## 0.2.0.0 - 2026-06-05### Milestone: `import <nixpkgs> {}` Evaluates- **`import <nixpkgs> {}` now evaluates to WHNF** - the top-level package set resolves and enumerates ~23,000 attributes, and a package evaluates through the full stdenv bootstrap down to a derivation: `(import <nixpkgs> {}).hello.drvPath` yields a `/nix/store/...-hello-2.12.1.drv` path. (Derivation-hash parity with upstream Nix and on-Windows building are the next fronts - this milestone is evaluation, not yet building.)- **Fix: `inherit <name>;` de Bruijn level in positional let/rec blocks** - `inherit x;` (without `from`) in a positional `let`/`rec` block desugars to `x = x;` with the right-hand side resolved against the *outer* scope, so it refers to the enclosing `x` rather than the binding being defined. But the desugared thunk is evaluated at runtime in the *inner* (let/rec) env, which adds one parent-chain level the outer resolution did not count - so every resolved level was short by one. This produced `nn_env_lookup_resolved: idx out of bounds` whenever an outer *lexical* variable was inherited inside a positional block - first triggered by perl's `inherit version;` (argument-set slot 7) nested in a 4-binding `let`. Fixed by shifting the desugared `inherit` RHS up one de Bruijn level in `Nix.Expr.Resolve`. (`inherit (from) ...` was already correct: its RHS resolves against the inner scope.)- **Fix: Hackage build - ship C headers in the sdist** - the `cbits/*.h` headers are `#include`d by the C sources (via `include-dirs: cbits`) but were never listed in the cabal file, so `cabal sdist` omitted them and the Hackage build failed with `nn_*.h: No such file or directory`. Added `extra-source-files: cbits/*.h`. A regression introduced in 0.1.9.0 (the first release to ship the C data layer); CI never caught it because CI builds the working tree, not the sdist. Verified by building from a freshly-extracted sdist tarball in isolation.## 0.1.9.0 - 2026-06-05### nixpkgs Evaluation: Lazy Derivations- **Fix: `import <nixpkgs> {}` infinite recursion - lazy `derivation` over `derivationStrict`** - `builtins.derivation` was eager: forcing a derivation to WHNF forced its entire env/input closure. This turned nixpkgs' lazy `perl` and `libxcrypt` dependency cycle into a blackhole - `perl`'s `assert (libxcrypt != null)` forced `libxcrypt`'s build, which forced `perl` mid-construction. Restored Nix's two-tier model: the eager `builtins.derivationStrict` primop (identical content-hashing, renamed from the old `builtins.derivation` body) plus a lazy `derivation` wrapper over it (mirroring `corepkgs/derivation.nix`). Forcing a derivation to WHNF now yields its attribute spine without computing `drvPath`/`outPath` or forcing its inputs, so referencing a package no longer builds its closure. No C changes; `drvPath`/`outPath` hashes unchanged. The stdenv bootstrap now progresses through derivation construction instead of looping (next blocker: a variable-slot bug while evaluating perl's `@`-pattern).### Correctness and the C Data Layer- **Fix: Nix integer division semantics** - `builtins.div` and `builtins.mod` now use floored division (`div`/`mod`) instead of truncated (`quot`/`rem`). `-7 / 3` correctly returns `-3` (was `-2`). Affects `builtinDiv`, `builtinMod`, and `evalDiv`.- **Fix: `inherit (from)` in positional let/rec blocks** - The resolution pass treated `inherit (expr) x y;` as positional, but the bytecode evaluator did not handle `BcInheritFrom` in `allBcPositional`, `bcBindingSlotCount`, `buildBcSlotThunks`, or `buildBcAttrMapFromSlots`. This caused env slot count mismatches and `idx out of bounds` assertions on any nixpkgs expression using `inherit (from)` in a positional let block.- **C memory safety** - `nn_bytecode.c`: `ensure_op_space`/`ensure_data_space` now return error codes instead of failing silently; overflow guard on capacity doubling. `nn_lambda.c`: `NN_ASSERT` bounds checks on entry accessors prevent null dereference when `formal_count == 0`. `nn_attrset.c`: documented partial-realloc-failure behavior.- **Dead code removal** - Removed unused `cattrsetIntersect` Haskell wrapper, `nn_attrset_intersect`, and `nn_attrset_values_ptr` C functions.- **New: `nn_assert.h`** - Debug-mode bounds checking macro. Compiles to nothing under `NDEBUG`.- **Performance** - Stress test: 6.25 MB max residency, 56.3% GC productivity (down from 69.7 MB / 1.6% pre-C-data-layer).## 0.1.8.0 - 2026-03-08### Builder Correctness, Windows Store Paths, Hackage Fix- **Fix #1: builder no longer pre-creates output paths** - `buildDerivationInner` no longer calls `createDirectoryIfMissing` for `$out`, `$dev`, etc. before running the builder. The builder is now responsible for creating its own outputs, matching real Nix semantics. Builds fail with `"builder succeeded but outputs missing"` if the builder exits successfully but expected outputs don't exist.- **File outputs supported** - `$out` can now be a regular file, not just a directory. `registerSingleOutput`, `addToStore`, `scanReferences`, and `pathExists` all use `doesPathExist` instead of `doesDirectoryExist`. `moveOutput` (renamed from `moveDirectory`) handles both files and directories in cross-device fallback. `collectRegularFiles` accepts file paths directly for reference scanning.- **Fix #2: Windows store paths use native separators** - CLI now uses `platformStoreDir` (`C:\nix\store` on Windows, `/nix/store` on Unix) for filesystem operations and display. Evaluator internals keep canonical `/nix/store` for ATerm hash compatibility.- **Fix: `crypton < 1.1` in .cabal file** - Previous `crypton` pin was only in `cabal.project` (which Hackage ignores). Moved to `.cabal` so the Hackage solver respects it. `crypton >= 1.1` switched from `memory` to `ram` for `ByteArrayAccess`, breaking `http-client-tls`.## 0.1.7.1 - 2026-03-07### Hackage Build Fix- **Fix: `nova-cache < 0.3.1` bound** - Hackage ignores `cabal.project` constraints, so the solver picked `nova-cache-0.3.1.0` (which uses `ram`) alongside `http-client-tls` (which uses `memory`), causing `ByteArrayAccess` instance mismatches. Narrowed bound to `< 0.3.1` to force `nova-cache-0.3.0.0` (which uses `memory`) until `http-client-tls` migrates to `ram`.## 0.1.7.0 - 2026-03-07### Build Fix: drvPath Resolution + cmd.exe Quoting- **Fix: `nova-nix build` drvPath resolution** - `builtinDerivation` now writes `drvPath` and output paths (`out`, `dev`, etc.) into `drvEnv` on the `Derivation` struct. Previously these were only present in the eval result attr set, so `buildAndRegister` could not find the `.drv` store path for dependency resolution (error: "no drvPath available for dependency resolution").- **Fix: `extractDerivation` returns `StorePath`** - The CLI `build` command now extracts the `drvPath` `StorePath` directly from the eval result alongside the `Derivation`, passing it explicitly to `buildWithDeps`. Eliminates the fragile `Map.lookup "drvPath" drvEnv` fallback.- **Fix: cmd.exe builder quoting on Windows** - New `mkBuilderProcess` detects when the builder is `cmd.exe` with `/c` and uses `Proc.shell` instead of `Proc.proc`. GHC's `proc` wraps each argument in double-quotes for `CommandLineToArgvW`, but cmd.exe doesn't use that convention - `args = [ "/c" "echo Hello" ]` would fail because cmd.exe tried to find an executable literally named `"echo Hello"`.- **Fix: UTF-16 auto-detection** - New `readFileAutoEncoding` detects UTF-16 LE/BE and UTF-8 BOM at the byte level before decoding. PowerShell's `>` operator writes UTF-16 LE by default - a Windows-first Nix implementation must handle this at the input boundary. Wired into all 5 file-read sites (Parser, Eval/IO, Main).- **nova-cache `>= 0.3.0`** - Bumped lower bound to track nova-cache 0.3.x series.- **`crypton < 1.1` pin** - `http-client-tls` still uses `memory`'s `ByteArrayAccess`; `crypton >= 1.1` switched to `ram`, causing instance mismatches. Pinned in `cabal.project` until `http-client-tls` migrates.## 0.1.6.0 - 2026-02-26### De Bruijn-Style Positional Env + SmallArray Slots- **De Bruijn-style variable resolution** - New `Nix.Expr.Resolve` pass replaces `EVar` with `EResolvedVar level index` for lambda-bound variables. Called at parse time; all subsequent evaluation uses positional indices instead of name-based `Map` lookups.- **Array-based Env** - `envSlots :: SmallArray Thunk` replaces `envBindings :: Map Text Thunk`. Lambda formals get O(1) positional indexing via `indexSmallArray` instead of O(log n) `Map.lookup`. Let/rec bindings and builtins remain in name-based `envLazyScope` (already zero Map.Bin overhead).- **Scope chain** - `Env` uses parent pointer chain instead of `Map.union`. Variable lookup walks the chain: positional slots, then `envLazyScope`, then parent, then with-scopes. Avoids O(n) `Map.union` when extending large envs.- **Inherit desugaring** - `inherit x;` is desugared to `x = x;` in the resolution pass so inherited lambda formals resolve to `EResolvedVar` (lambda slots have no names at runtime).- **Heap savings** - Eliminates 29.9M Map.Bin nodes (1.37 GB) from lambda formals. Replaced by SmallArray (one heap object per env, O(1) index) + scope chain parent pointers.- `primitive` dependency added for `Data.Primitive.SmallArray`## 0.1.5.0 - 2026-02-26### New Builtins, Coercion Fixes, CI Cleanup- **`builtins.warn`** - prints warning to stderr, returns second arg- **`builtins.path`** - copies file/dir to store with `SCPlain` context- **`builtins.seq` fix** - now forces first arg to WHNF (was silent no-op)- **`builtins.trace`/`traceVerbose` fix** - print to stderr via `MonadEval.traceMessage`- **`coerceToString` fix** - handle `VAttrs` with `__toString` and `outPath`, enabling `"${pkgs.hello}/bin/hello"` interpolation (was type error on all attrsets)- **`fetchTarball` fix** - downloads and extracts via curl|tar pipeline (was returning raw .tar.gz)- **`MonadEval`** - added `traceMessage`, `copyPathToStore` methods- CI: switched to `haskell-actions/run-ormolu@v16` (matching all Novavero repos)## 0.1.4.0 - 2026-02-26### Memory Optimization + Lazy Non-Rec Attrsets- **Lazy non-rec attrsets** - `evalNonRecAttrs` now uses `LazyAttrs` to defer thunk+IORef allocation until first access. For `all-packages.nix` (~15k entries per stdenv stage), only accessed packages allocate thunks.- **Per-binding Env in `LazyBinding`** - Each `LazyExpr`/`LazyInherit`/`LazyInheritFrom` carries its own `Env` instead of sharing one per-attrset. Fixes a bug where `//` merges of `LazyAttrs` from different scopes lost variables - broke `lib.extends` overlay pattern used by `makeExtensibleWithCustomName`.- **Batched formal set matching** - `matchFormalSet` creates ONE `Env` with all formals instead of N singleton `Env`s. Uses knot-tying so default expressions can reference other formals, including forward references (`{ a ? b, b ? 1 }: a` evaluates to `1`).- **Env scope chain** - `Env` now uses a parent pointer chain instead of `Map.union`. Variable lookup walks the chain: local bindings, then parent, then with-scopes. Avoids O(n) `Map.union` when extending large envs (e.g. 30k-entry nixpkgs rec set). Peak Map.Bin heap: 956MB down to ~40MB.- **ThunkCell release** - On force, `Pending expr env` is overwritten to `Computed val`, dropping all references to `Expr` and `Env` (matching C++ Nix in-place mutation). Previously retained dead closures indefinitely.- **Lazy `//` operator** - `mergeAttrSets` preserves `LazyAttrs` when possible, merging binding recipe maps instead of materializing all thunks.- **Lazy with-scopes** - `pushWithScope` accepts `AttrSet` directly so `LazyAttrs` with-scopes stay lazy. `lookupWithScopes` uses `attrSetLookup` to materialize only the accessed key.- **Key-driven `intersectAttrs`** - Only touches keys present in both sets instead of materializing entire attrsets.- **New builtins** - `min`, `max`, `mod`, base64 `encode`/`decode` (via nova-cache 0.2.4)- `nova-cache >= 0.2.4` dependency bump- 511 tests, -Werror clean, ormolu 0.7.7.0 clean, hlint clean## 0.1.3.0 - 2026-02-25### nixpkgs Compatibility: Module System, Callable Sets, Parser Fixes- **`__functor` support** - Attribute sets with `__functor` are now callable, matching real Nix. `(set.__functor set) arg` dispatch enables nixpkgs patterns like `lib.makeOverridable` and `lib.setFunctionArgs`.- **`builtins.setFunctionArgs`** - Wraps a function in a callable attrset with `__functor` and `__functionArgs` metadata. Used by `lib.mirrorFunctionArgs`, `lib.makeOverridable`, and the entire nixpkgs override system.- **Null dynamic keys** - `{ ${null} = val; }` now skips the binding instead of erroring (matching real Nix). Used extensively by the nixpkgs module system for conditional attributes like `${if cond then "key" else null}`.- **Indented string interpolation fix** - `''${expr}''` now parses correctly. The lexer had an overzealous guard (`isIndStringEscape`) that blocked `''` from opening an indented string when followed by `$`. This broke `lib.generators` and many nixpkgs files.- **`splitVersion` fix** - Dots are separators, not components. `splitVersion "1.2.3"` now returns `["1" "2" "3"]` (was `["1" "." "2" "." "3"]`). Fixes `lib.versions.majorMinor` and all version comparison logic.- **`builtins.functionArgs` on callable sets** - Now inspects `__functionArgs` metadata on attrsets produced by `setFunctionArgs`, enabling `lib.functionArgs` to work on overridable functions.- **CLI eval sub-parser** - `--strict` and `--nix-path` flags now work after `eval` command (e.g. `nova-nix eval --strict --expr '...'`). Previously only worked before the command.- **Bundled `<nix/fetchurl.nix>`** - Ships as a Cabal data-file, added to search paths automatically. nixpkgs stdenv bootstrap imports this file; no system Nix install needed.- **nixpkgs module system working** - `lib.evalModules`, `lib.mkOption`, `lib.mkIf`, `lib.types.*` all evaluate correctly.- **nixpkgs functional patterns working** - `lib.makeOverridable`, `lib.makeExtensible`, `lib.fix`, `lib.generators.toKeyValue` all correct.- **`lib.systems.elaborate` instant** - Was taking minutes before lazy builtins; now returns immediately for any system string.- 101 builtins (up from 91), 511 tests## 0.1.2.0 - 2026-02-24### Lazy Builtins + Correctness Fixes- **Lazy `map`** - returns deferred thunks instead of eagerly forcing all elements. `map f [80000 items]` is now O(1) until elements are demanded.- **Lazy `genList`** - each element is a deferred `f(i)` thunk, forced only on demand- **Lazy `mapAttrs`** - each attr value is a deferred `f key val` thunk. Critical for nixpkgs which `mapAttrs` over the entire package set.- **Semi-lazy `concatMap`** - forces applications to discover list structure for concatenation, but element thunks within sub-lists stay lazy- **`@`-pattern scoping fix** - `{ system ? args.system or ..., ... }@args:` now correctly binds the `@`-name before evaluating defaults, matching real Nix. Previously, default expressions couldn't reference the `@`-binding.- **Synthetic thunk memo cell fix** - `mkSyntheticThunk` uses env bindings (not expr) for IORef uniqueness, preventing GHC's full-laziness transform from sharing one memo cell across all deferred thunks. Without this, `map f [a b c]` would return `[f(a) f(a) f(a)]`.- `deferApply` helper: builds thunks wrapping `EApp (EResolvedVar 0 0) (EResolvedVar 0 1)` in a self-contained env with positional slots, reusing existing eval + memoization machinery- 511 tests (3 new: map laziness, genList laziness, mapAttrs laziness)## 0.1.1.0 - 2026-02-24- **Thunk memoization** - Per-thunk `IORef` memo cells (matching real Nix in-place mutation). `forceThunk` is a `MonadEval` method: IO evaluators memoize per-allocation, pure evaluators re-evaluate. GC reclaims dead thunks naturally - no unbounded global cache. `unsafePerformIO` CAF float-out prevented via `NOINLINE` + `seq` pattern.- **8.4x builtin dispatch speedup** - Case dispatch replacing polymorphic `Map` reconstruction on every call. Direct pattern match on builtin name for zero-allocation dispatch in the hot path.- **Regex builtins** - `builtins.match` and `builtins.split` via `regex-tdfa` (pure Haskell POSIX ERE, cross-platform)- `ESearchPath !Text` AST constructor - `<nixpkgs>` is now its own node, desugared at eval time to `builtins.findFile builtins.nixPath "nixpkgs"` (matching real Nix semantics)- NIX_PATH parsing: `parseNixPath` converts colon-separated `name=path` entries into `{ prefix, path }` attrset thunks- `builtinEnv` now accepts search paths: `builtinEnv :: Integer -> [Thunk] -> Env`- `EvalState.esSearchPaths` populated from `NIX_PATH` environment variable at startup- Directory imports: `import ./dir` automatically resolves to `./dir/default.nix`- Dynamic attribute keys: `{ ${expr} = val; }` fully supported in all contexts (non-rec, rec, let, select, hasAttr)- Two-phase binding resolution for knot-tying: `resolveBindingKeys` (monadic, evaluates dynamic keys) then `buildResolvedBindingsMap` (pure, enables recursive self-reference)- Monadic `resolveKey` replaces pure `resolveStaticKey` - handles both `StaticKey` and `DynamicKey` uniformly- CLI `--nix-path NAME=PATH` flag (repeatable, merged with NIX_PATH)- CLI `--expr EXPR` for inline expression evaluation- CLI deep-force and pretty-printing for eval output- `README.md` added to `extra-doc-files` in cabal (shows on Hackage)- Parser fix: `TokInterpOpen` in expression context expects `TokRBrace` (not `TokInterpClose`) for closing brace- 91 builtins (up from 88)- 508 tests (14 new: parseNixPath, search path parsing/eval, dynamic keys, directory import, populated search path resolution)## 0.1.0.0 - 2026-02-24### Cross-Platform Fixes- Cross-platform ATerm serialization: `storePathToText` always uses `/` for store paths regardless of OS, `parseStorePath` accepts both `/` and `\`- Builder inherits system environment, overlays build env via `Map.union` - fixes silent process failures on Windows (missing `SYSTEMROOT`)- Builder PATH derived from builder location (`buildPath`) - includes builder dir and MSYS2 sibling `usr/bin` for coreutils discovery- `findTestShell` prefers known Git for Windows bash over WSL launcher (`System32\bash.exe`)- Parser strips UTF-8 BOM - Windows editors (Notepad, PowerShell) commonly add byte order marks- Demo `test.nix` included: derivations, lambdas, builtins.map, arithmetic - runs on all platforms- 16 builtins exposed at top level without `builtins.` prefix (`toString`, `map`, `throw`, `import`, `derivation`, `abort`, `baseNameOf`, `dirOf`, `isNull`, `removeAttrs`, `placeholder`, `scopedImport`, `fetchTarball`, `fetchGit`, `fetchurl`, `toFile`) - matches real Nix language spec, required for nixpkgs compatibility### String Contexts, Dependency Resolution, Binary Substituter- String context tracking on all `VStr` values: `SCPlain`, `SCDrvOutput`, `SCAllOutputs`- Context propagation through interpolation, string concatenation, `replaceStrings`, `substring`, `concatStringsSep`, and all string builtins- `Nix.Eval.Context` module: pure helpers for context construction, queries, and extraction- `derivation` builtin now collects string contexts into `drvInputDrvs` and `drvInputSrcs`- New builtins: `hasContext`, `getContext`, `appendContext`- `Nix.DependencyGraph`: BFS graph construction with `Data.Sequence` (O(V+E)), topological sort via Kahn's algorithm, cycle detection- `Nix.Substituter`: full HTTP binary cache protocol - narinfo fetch/parse, Ed25519 signature verification, NAR download/decompress/unpack, store DB registration, priority-ordered multi-cache- `Nix.Builder.buildWithDeps`: recursive dependency resolution - topo sort, cache check, binary substitution, local build fallback- CLI `nova-nix build` now builds full dependency trees, not just single derivations- Cleanup pass: eliminated all partial functions (`T.head`/`T.tail` to `T.uncons`, `!!` to safe lookup, `last` to pattern match), flattened deeply nested code into composed functions, `Data.Sequence` BFS queues throughout, semantic section organization- 494 tests (68 new: string context, context propagation, dependency graph, substituter, build orchestrator)### Content-Addressed Store + Derivation Builder- Real SQLite-backed store database (`ValidPaths` + `Refs` tables, WAL mode)- Store operations: `addToStore` (cross-device safe), `scanReferences` (byte-scan for store path references), `setReadOnly` (recursive), `writeDrv`- `parseStorePath`: parse full store path strings into `StorePath` values- ATerm parser (`fromATerm`): hand-rolled recursive descent, full round-trip with `toATerm`- `builtinDerivation` now populates `drvOutputs` with `DerivationOutput` records- Full `buildDerivation` loop: input validation, temp directory setup, environment construction, process execution via `System.Process`, reference scanning, output registration in store DB- CLI `nova-nix build FILE.nix`: evaluate, extract derivation, write `.drv`, build, print output path- 426 tests (45 new: 10 store DB, 13 store ops, 10 ATerm parser, 8 builder, 4 CLI end-to-end)### Parser, Lazy Evaluator, 85 Builtins- Full Nix expression parser (hand-rolled recursive descent, 13 precedence levels)- Lazy evaluator with thunk-based evaluation, knot-tying for recursive bindings- 85 builtins: type checks, arithmetic, bitwise, strings, lists, attrsets, higher-order, JSON, hashing, version parsing, tryEval, deepSeq, genericClosure, all IO builtins, derivation- MonadEval typeclass - evaluator is polymorphic in its effect monad (PureEval for tests, EvalIO for real evaluation)- IO builtins: import, readFile, pathExists, readDir, getEnv, toPath, toFile, findFile, scopedImport, fetchurl, fetchTarball, fetchGit, currentTime- derivation builtin: attrset to .drv build recipe with computed drvPath and outPath- ATerm serialization with string escaping, sorted environments- placeholder and storePath builtins via nova-cache hashing- Content-addressed store path types with Windows/Unix support- Derivation types, platform detection, and textToPlatform/platformToText- Shared hash utilities in Nix.Hash (SHA-256 hex, truncated base-32, byteToHex)- CLI: `nova-nix eval FILE.nix` evaluates a .nix file and prints the result- 381 tests, zero framework dependencies- CI pipeline: HLint, Ormolu, build with -Werror, test, Hackage publish on tags### Security- Total functions only - no `read`, `head`, `tail`, `!!`, `fromJust`, or `Map.!`- Argument injection prevention in fetch builtins (`--` separator before user URLs)- Path traversal validation in writeToStore (rejects `/`, `..`, null bytes)- Content-hashed temp directories for fetchGit (no predictable paths)- Store paths set read-only after registration (immutability enforcement)### Architecture- Store paths parameterized via `StoreDir` - no hardcoded `/nix/store/` strings- Cross-device safe directory moves (rename with copy+remove fallback)- Hash utilities deduplicated into Nix.Hash (single source of truth)- currentSystem is a constant (not a function), matching real Nix semantics- Platform-aware environment setup (HOME vs USERPROFILE, Unix vs Windows PATH)