-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8848 from BootRhetoric/flake-authentication
- Loading branch information
Showing
11 changed files
with
268 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
#include "registry.hh" | ||
#include "tarball.hh" | ||
#include "url.hh" | ||
#include "value-to-json.hh" | ||
|
||
#include <ctime> | ||
#include <iomanip> | ||
|
@@ -125,6 +126,10 @@ static void fetchTree( | |
attrs.emplace(state.symbols[attr.name], Explicit<bool>{attr.value->boolean}); | ||
else if (attr.value->type() == nInt) | ||
attrs.emplace(state.symbols[attr.name], uint64_t(attr.value->integer)); | ||
else if (state.symbols[attr.name] == "publicKeys") { | ||
experimentalFeatureSettings.require(Xp::VerifiedFetches); | ||
attrs.emplace(state.symbols[attr.name], printValueAsJSON(state, true, *attr.value, pos, context).dump()); | ||
} | ||
else | ||
state.debugThrowLastTrace(TypeError("fetchTree argument '%s' is %s while a string, Boolean or integer is expected", | ||
state.symbols[attr.name], showType(*attr.value))); | ||
|
@@ -427,6 +432,42 @@ static RegisterPrimOp primop_fetchGit({ | |
With this argument being true, it's possible to load a `rev` from *any* `ref` | ||
(by default only `rev`s from the specified `ref` are supported). | ||
- `verifyCommit` (default: `true` if `publicKey` or `publicKeys` are provided, otherwise `false`) | ||
Whether to check `rev` for a signature matching `publicKey` or `publicKeys`. | ||
If `verifyCommit` is enabled, then `fetchGit` cannot use a local repository with uncommitted changes. | ||
Requires the [`verified-fetches` experimental feature](@docroot@/contributing/experimental-features.md#xp-feature-verified-fetches). | ||
- `publicKey` | ||
The public key against which `rev` is verified if `verifyCommit` is enabled. | ||
Requires the [`verified-fetches` experimental feature](@docroot@/contributing/experimental-features.md#xp-feature-verified-fetches). | ||
- `keytype` (default: `"ssh-ed25519"`) | ||
The key type of `publicKey`. | ||
Possible values: | ||
- `"ssh-dsa"` | ||
- `"ssh-ecdsa"` | ||
- `"ssh-ecdsa-sk"` | ||
- `"ssh-ed25519"` | ||
- `"ssh-ed25519-sk"` | ||
- `"ssh-rsa"` | ||
Requires the [`verified-fetches` experimental feature](@docroot@/contributing/experimental-features.md#xp-feature-verified-fetches). | ||
- `publicKeys` | ||
The public keys against which `rev` is verified if `verifyCommit` is enabled. | ||
Must be given as a list of attribute sets with the following form: | ||
```nix | ||
{ | ||
key = "<public key>"; | ||
type = "<key type>"; # optional, default: "ssh-ed25519" | ||
} | ||
``` | ||
Requires the [`verified-fetches` experimental feature](@docroot@/contributing/experimental-features.md#xp-feature-verified-fetches). | ||
Here are some examples of how to use `fetchGit`. | ||
- To fetch a private repository over SSH: | ||
|
@@ -501,6 +542,21 @@ static RegisterPrimOp primop_fetchGit({ | |
} | ||
``` | ||
- To verify the commit signature: | ||
```nix | ||
builtins.fetchGit { | ||
url = "ssh://[email protected]/nixos/nix.git"; | ||
verifyCommit = true; | ||
publicKeys = [ | ||
{ | ||
type = "ssh-ed25519"; | ||
key = "AAAAC3NzaC1lZDI1NTE5AAAAIArPKULJOid8eS6XETwUjO48/HKBWl7FTCK0Z//fplDi"; | ||
} | ||
]; | ||
} | ||
``` | ||
Nix will refetch the branch according to the [`tarball-ttl`](@docroot@/command-ref/conf-file.md#conf-tarball-ttl) setting. | ||
This behavior is disabled in [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.