aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2020-12-21Add 'nix develop' and `nix print-dev-env' manpagesEelco Dolstra
2020-12-21Add 'nix search' manpageEelco Dolstra
2020-12-21Add 'nix copy' manpageEelco Dolstra
2020-12-21Add 'nix run' and 'nix shell' manpagesEelco Dolstra
2020-12-21Add 'nix build' manpageEelco Dolstra
2020-12-21Move doc() to ArgsEelco Dolstra
2020-12-21Merge pull request #4385 from obsidiansystems/store-subclassEelco Dolstra
Overhaul store subclassing
2020-12-21Merge pull request #4355 from Infinisil/private-value-typeEelco Dolstra
Refactoring for private Value type
2020-12-20Overhaul store subclassingJohn Ericson
We embrace virtual the rest of the way, and get rid of the `assert(false)` 0-param constructors. We also list config base classes first, so the constructor order is always: 1. all the configs 2. all the stores Each in the same order
2020-12-18Replace Value type setters with mk* functionsSilvan Mosberger
Move clearValue inside Value mkInt instead of setInt mkBool instead of setBool mkString instead of setString mkPath instead of setPath mkNull instead of setNull mkAttrs instead of setAttrs mkList instead of setList* mkThunk instead of setThunk mkApp instead of setApp mkLambda instead of setLambda mkBlackhole instead of setBlackhole mkPrimOp instead of setPrimOp mkPrimOpApp instead of setPrimOpApp mkExternal instead of setExternal mkFloat instead of setFloat Add note that the static mk* function should be removed eventually
2020-12-17Rename Value::normalType() -> Value::type()Silvan Mosberger
2020-12-17Rename ValueType -> InternalType, NormalType -> ValueTypeSilvan Mosberger
And Value::type to Value::internalType, such that type() can be used in the next commit to get the new ValueType
2020-12-17Fix the detection of already built drv outputsregnat
PRs #4370 and #4348 had a bad interaction in that the second broke the fist one in a not trivial way. The issue was that since #4348 the logic for detecting whether a derivation output is already built requires some logic that was specific to the `LocalStore`. It happens though that most of this logic could be upstreamed to any `Store`, which is what this commit does.
2020-12-16Merge pull request #4370 from NixOS/ca/more-precise-build-noopEelco Dolstra
Better detect when `buildPaths` would be a no-op
2020-12-16Don't ignore an absent drv file in queryPartialDrvOutputMapregnat
This ignore was here because `queryPartialDrvOutputMap` was used both 1. as a cache to avoid having to re-read the derivation (when gc-ing for example), and 2. as the source of truth for ca realisations The use-case 2. required it to be able to work even when the derivation wasn't there anymore (see https://github.com/NixOS/nix/issues/4138). However, this use-case is now handled by `queryRealisation`, meaning that we can safely error out if the derivation isn't there anymore
2020-12-16Merge pull request #4348 from NixOS/ca/use-hashmoduloEelco Dolstra
Use the hash modulo in the derivation outputs
2020-12-16Fix BinaryCacheStore::registerDrvOutputregnat
Was crashing because coercing a json document into a string is only valid if the json is a string, otherwise we need to call `.dump()`
2020-12-16Better detect when `buildPaths` would be a no-opregnat
`buildPaths` can be called even for stores where it's not defined in case it's bound to be a no-op. The “no-op detection” mechanism was only detecting the case wher `buildPaths` was called on a set of (non-drv) paths that were already present on the store. This commit extends this mechanism to also detect the case where `buildPaths` is called on a set of derivation outputs which are already built on the store. This only works with the ca-derivations flag. It could be possible to extend this to also work without it, but it would add quite a bit of complexity, and it's not used without it anyways.
2020-12-15Fix `addTextToStore` for binary cachesregnat
Because of a too eager refactoring, `addTextToStore` used to throw an error because the input wasn't a valid nar. Partially revert that refactoring to wrap the text into a proper nar (using `dumpString`) to make this method work again
2020-12-14Merge pull request #4330 from NixOS/ca/properly-store-outputsEelco Dolstra
Properly store the outputs of CA derivations − take 2
2020-12-14Merge pull request #4351 from Ma27/json-errtraceEelco Dolstra
primops/fromJSON: add error position in case of parse error
2020-12-13primops/fromJSON: add error position in case of parse errorMaximilian Bosch
This makes it easier to track down where invalid JSON was passed to `builtins.fromJSON`.
2020-12-13Merge pull request #4352 from jonringer/allow-private-cachesEelco Dolstra
treat s3 permission errors as file-not-found
2020-12-12Make Value::type privateSilvan Mosberger
This is an implementation detail and shouldn't be used. Use normalType() and the various is<Type> functions instead
2020-12-12Add ValueType checking functions for types that have the same NormalTypeSilvan Mosberger
2020-12-12Use Value::normalType on all forced values instead of Value::typeSilvan Mosberger
2020-12-12Introduce Value type setters and make use of themSilvan Mosberger
2020-12-12Introduce NormalType for the normal type of a ValueSilvan Mosberger
This will be useful to abstract over the ValueType implementation details Make use of it already to replace the showType(ValueType) function
2020-12-11Restrict the operations on drv outputs in recursive Nixregnat
There's currently no way to properly filter them, so disallow them altogether instead.
2020-12-11Use the hash modulo in the derivation outputsregnat
Rather than storing the derivation outputs as `drvPath!outputName` internally, store them as `drvHashModulo!outputName` (or `outputHash!outputName` for fixed-output derivations). This makes the storage slightly more opaque, but enables an earlier cutoff in cases where a fixed-output dependency changes (but keeps the same output hash) − same as what we already do for input-addressed derivations.
2020-12-11Store the realisations as JSON in the binary cacheregnat
Fix #4332
2020-12-11Rework the db schema for derivation outputsregnat
Add a new table for tracking the derivation output mappings. We used to hijack the `DerivationOutputs` table for that, but (despite its name), it isn't a really good fit: - Its entries depend on the drv being a valid path, making it play badly with garbage collection and preventing us to copy a drv output without copying the whole drv closure too; - It dosen't guaranty that the output path exists; By using a different table, we can experiment with a different schema better suited for tracking the output mappings of CA derivations. (incidentally, this also fixes #4138)
2020-12-11Store metadata about drv outputs realisationsregnat
For each known realisation, store: - its output - its output path This comes with a set of needed changes: - New `realisations` module declaring the types needed for describing these mappings - New `Store::registerDrvOutput` method registering all the needed informations about a derivation output (also replaces `LocalStore::linkDeriverToPath`) - new `Store::queryRealisation` method to retrieve the informations for a derivations This introcudes some redundancy on the remote-store side between `wopQueryDerivationOutputMap` and `wopQueryRealisation`. However we might need to keep both (regardless of backwards compat) because we sometimes need to get some infos for all the outputs of a derivation (where `wopQueryDerivationOutputMap` is handy), but all the stores can't implement it − because listing all the outputs of a derivation isn't really possible for binary caches where the server doesn't allow to list a directory.
2020-12-11treat s3 permission errors as file-not-foundMichael Bishop
Signed-off-by: Jonathan Ringer <jonringer117@gmail.com>
2020-12-11Merge pull request #4350 from NixOS/ca/fix-build-with-nix-commandEelco Dolstra
Fix the `nix` command with CA derivations
2020-12-11Fix the `nix` command with CA derivationsregnat
Prevents a crash because most `nix` subcommands assumed that derivations know their output path, which isn't the case for CA derivations
2020-12-10nix store make-content-addressable: Show rewritten pathEelco Dolstra
2020-12-10Add lvlNotice log levelEelco Dolstra
This is like syslog's LOG_NOTICE: "normal, but significant, condition".
2020-12-09Merge pull request #4342 from tweag/fix-remote-build-hookEelco Dolstra
fix remote build hook
2020-12-09libstore/openStore: fix stores with IPv6 addressesMaximilian Bosch
In `nixStable` (2.3.7 to be precise) it's possible to connect to stores using an IPv6 address: nix ping-store --store ssh://root@2001:db8::1 This is also useful for `nixops(1)` where you could specify an IPv6 address in `deployment.targetHost`. However, this behavior is broken on `nixUnstable` and fails with the following error: $ nix store ping --store ssh://root@2001:db8::1 don't know how to open Nix store 'ssh://root@2001:db8::1' This happened because `openStore` from `libstore` uses the `parseURL` function from `libfetchers` which expects a valid URL as defined in RFC2732. However, this is unsupported by `ssh(1)`: $ nix store ping --store 'ssh://root@[2001:db8::1]' cannot connect to 'root@[2001:db8::1]' This patch now allows both ways of specifying a store (`root@2001:db8::1`) and also `root@[2001:db8::1]` since the latter one is useful to pass query parameters to the remote store. In order to achieve this, the following changes were made: * The URL regex from `url-parts.hh` now allows an IPv6 address in the form `2001:db8::1` and also `[2001:db8::1]`. * In `libstore`, a new function named `extractConnStr` ensures that a proper URL is passed to e.g. `ssh(1)`: * If a URL looks like either `[2001:db8::1]` or `root@[2001:db8::1]`, the brackets will be removed using a regex. No additional validation is done here as only strings parsed by `parseURL` are expected. * In any other case, the string will be left untouched. * The rules above only apply for `LegacySSHStore` and `SSHStore` (a.k.a `ssh://` and `ssh-ng://`). Unresolved questions: * I'm not really sure whether we want to allow both variants of IPv6 addresses in the URL parser. However it should be noted that both seem to be possible according to RFC2732: > This document incudes an update to the generic syntax for Uniform > Resource Identifiers defined in RFC 2396 [URL]. It defines a syntax > for IPv6 addresses and allows the use of "[" and "]" within a URI > explicitly for this reserved purpose. * Currently, it's not supported to specify a port number behind the hostname, however it seems as this is not really supported by the URL parser. Hence, this is probably out of scope here.
2020-12-09Store the final drv outputs in memory when building remotelyregnat
The `DerivationGoal` has a variable storing the “final” derivation output paths that is used (amongst other things) to fill the environment for the post build hook. However this variable wasn't set when the build-hook is used, causing a crash when both hooks are used together. Fix this by setting this variable (from the informations in the db) after a run of the post build hook.
2020-12-09Revert "Re-query for the derivation outputs in the post-build-hook"regnat
This reverts commit 1b1e0760335832c87516b9103b670b34662d5daf. Using `queryPartialDerivationOutputMap` assumes that the derivation exists locally which isn't the case for remote builders.
2020-12-08Merge pull request #4325 from tweag/hide-local-store-sql-statementsEelco Dolstra
Hide the sqlite statements declarations for the local store
2020-12-08Hide the sqlite statements declarations for the local storeregnat
These have no need to be in the public interface and it causes spurious rebuilds each time one wants to add or remove a new statement.
2020-12-08Re-query for the derivation outputs in the post-build-hookregnat
We can't assume that the runtime state knows about them as they might have been built remotely, in which case we must query the db again to get them.
2020-12-06Always default to cache.nixos.org even when different nix store dirMatthew Bauer
Since 0744f7f, it is now useful to have cache.nixos.org in substituers even if /nix/store is not the Nix Store Dir. This can always be overridden via configuration, though.
2020-12-05Merge pull request #4318 from matthewbauer/add-slash-to-trusted-binary-cacheEelco Dolstra
Canonicalize binary caches with ‘/’ when one is missing
2020-12-04Canonicalize binary caches with ‘/’ when one is missingMatthew Bauer
This checks if there is a trusted substituter with a slash, so trusting https://cache.nixos.org also implies https://cache.nixos.org/ is trusted.
2020-12-04Fix compatibility with newer AWS SDKsStéphan Kochen
Tested against AWS SDK 1.8.99. Fixes #3201.
2020-12-04Split 'nix store add-to-store' into 'add-path' and 'add-file'Eelco Dolstra
This makes it consistent with 'nix hash <path|file>'.