mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 09:06:15 +02:00
Support per-store Markdown documentation
This commit is contained in:
parent
7704118d28
commit
9eb53bbf17
20 changed files with 181 additions and 4 deletions
|
@ -129,10 +129,14 @@ let
|
||||||
|
|
||||||
storeDocs =
|
storeDocs =
|
||||||
let
|
let
|
||||||
showStore = name: { settings }:
|
showStore = name: { settings, doc }:
|
||||||
''
|
''
|
||||||
## ${name}
|
## ${name}
|
||||||
|
|
||||||
|
${doc}
|
||||||
|
|
||||||
|
**Settings**:
|
||||||
|
|
||||||
${showSettings false settings}
|
${showSettings false settings}
|
||||||
'';
|
'';
|
||||||
in concatStrings (attrValues (mapAttrs showStore cliDump.stores));
|
in concatStrings (attrValues (mapAttrs showStore cliDump.stores));
|
||||||
|
|
|
@ -7,6 +7,13 @@ struct DummyStoreConfig : virtual StoreConfig {
|
||||||
using StoreConfig::StoreConfig;
|
using StoreConfig::StoreConfig;
|
||||||
|
|
||||||
const std::string name() override { return "Dummy Store"; }
|
const std::string name() override { return "Dummy Store"; }
|
||||||
|
|
||||||
|
std::string doc() override
|
||||||
|
{
|
||||||
|
return
|
||||||
|
#include "dummy-store.md"
|
||||||
|
;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DummyStore : public virtual DummyStoreConfig, public virtual Store
|
struct DummyStore : public virtual DummyStoreConfig, public virtual Store
|
||||||
|
|
13
src/libstore/dummy-store.md
Normal file
13
src/libstore/dummy-store.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
R"(
|
||||||
|
|
||||||
|
**Store URL format**: `dummy://`
|
||||||
|
|
||||||
|
This store type represents a store that contains no store paths and
|
||||||
|
cannot be written to. It's useful when you want to use the Nix
|
||||||
|
evaluator when no actual Nix store exists, e.g.
|
||||||
|
|
||||||
|
```console
|
||||||
|
# nix eval --store dummy:// --expr '1 + 2'
|
||||||
|
```
|
||||||
|
|
||||||
|
)"
|
|
@ -13,6 +13,13 @@ struct HttpBinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
|
||||||
using BinaryCacheStoreConfig::BinaryCacheStoreConfig;
|
using BinaryCacheStoreConfig::BinaryCacheStoreConfig;
|
||||||
|
|
||||||
const std::string name() override { return "HTTP Binary Cache Store"; }
|
const std::string name() override { return "HTTP Binary Cache Store"; }
|
||||||
|
|
||||||
|
std::string doc() override
|
||||||
|
{
|
||||||
|
return
|
||||||
|
#include "http-binary-cache-store.md"
|
||||||
|
;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class HttpBinaryCacheStore : public virtual HttpBinaryCacheStoreConfig, public virtual BinaryCacheStore
|
class HttpBinaryCacheStore : public virtual HttpBinaryCacheStoreConfig, public virtual BinaryCacheStore
|
||||||
|
|
8
src/libstore/http-binary-cache-store.md
Normal file
8
src/libstore/http-binary-cache-store.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
R"(
|
||||||
|
|
||||||
|
**Store URL format**: `http://...`, `https://...`
|
||||||
|
|
||||||
|
This store allows a binary cache to be accessed via the HTTP
|
||||||
|
protocol.
|
||||||
|
|
||||||
|
)"
|
|
@ -22,7 +22,14 @@ struct LegacySSHStoreConfig : virtual StoreConfig
|
||||||
const Setting<Path> remoteProgram{(StoreConfig*) this, "nix-store", "remote-program", "path to the nix-store executable on the remote system"};
|
const Setting<Path> remoteProgram{(StoreConfig*) this, "nix-store", "remote-program", "path to the nix-store executable on the remote system"};
|
||||||
const Setting<std::string> remoteStore{(StoreConfig*) this, "", "remote-store", "URI of the store on the remote system"};
|
const Setting<std::string> remoteStore{(StoreConfig*) this, "", "remote-store", "URI of the store on the remote system"};
|
||||||
|
|
||||||
const std::string name() override { return "Legacy SSH Store"; }
|
const std::string name() override { return "SSH Store"; }
|
||||||
|
|
||||||
|
std::string doc() override
|
||||||
|
{
|
||||||
|
return
|
||||||
|
#include "legacy-ssh-store.md"
|
||||||
|
;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Store
|
struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Store
|
||||||
|
|
8
src/libstore/legacy-ssh-store.md
Normal file
8
src/libstore/legacy-ssh-store.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
R"(
|
||||||
|
|
||||||
|
**Store URL format**: `ssh://[username@]hostname`
|
||||||
|
|
||||||
|
This store type allows limited access to a remote store on another
|
||||||
|
machine via SSH.
|
||||||
|
|
||||||
|
)"
|
|
@ -11,6 +11,13 @@ struct LocalBinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
|
||||||
using BinaryCacheStoreConfig::BinaryCacheStoreConfig;
|
using BinaryCacheStoreConfig::BinaryCacheStoreConfig;
|
||||||
|
|
||||||
const std::string name() override { return "Local Binary Cache Store"; }
|
const std::string name() override { return "Local Binary Cache Store"; }
|
||||||
|
|
||||||
|
std::string doc() override
|
||||||
|
{
|
||||||
|
return
|
||||||
|
#include "local-binary-cache-store.md"
|
||||||
|
;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LocalBinaryCacheStore : public virtual LocalBinaryCacheStoreConfig, public virtual BinaryCacheStore
|
class LocalBinaryCacheStore : public virtual LocalBinaryCacheStoreConfig, public virtual BinaryCacheStore
|
||||||
|
|
16
src/libstore/local-binary-cache-store.md
Normal file
16
src/libstore/local-binary-cache-store.md
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
R"(
|
||||||
|
|
||||||
|
**Store URL format**: `file://`*path*
|
||||||
|
|
||||||
|
This store allows reading and writing a binary cache stored in *path*
|
||||||
|
in the local filesystem. If *path* does not exist, it will be created.
|
||||||
|
|
||||||
|
For example, the following builds or downloads `nixpkgs#hello` into
|
||||||
|
the local store and then copies it to the binary cache in
|
||||||
|
`/tmp/binary-cache`:
|
||||||
|
|
||||||
|
```
|
||||||
|
# nix copy --to file:///tmp/binary-cache nixpkgs#hello
|
||||||
|
```
|
||||||
|
|
||||||
|
)"
|
|
@ -44,6 +44,13 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
std::string LocalStoreConfig::doc()
|
||||||
|
{
|
||||||
|
return
|
||||||
|
#include "local-store.md"
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
struct LocalStore::State::Stmts {
|
struct LocalStore::State::Stmts {
|
||||||
/* Some precompiled SQLite statements. */
|
/* Some precompiled SQLite statements. */
|
||||||
SQLiteStmt RegisterValidPath;
|
SQLiteStmt RegisterValidPath;
|
||||||
|
|
|
@ -41,8 +41,9 @@ struct LocalStoreConfig : virtual LocalFSStoreConfig
|
||||||
"require-sigs", "whether store paths should have a trusted signature on import"};
|
"require-sigs", "whether store paths should have a trusted signature on import"};
|
||||||
|
|
||||||
const std::string name() override { return "Local Store"; }
|
const std::string name() override { return "Local Store"; }
|
||||||
};
|
|
||||||
|
|
||||||
|
std::string doc() override;
|
||||||
|
};
|
||||||
|
|
||||||
class LocalStore : public virtual LocalStoreConfig, public virtual LocalFSStore, public virtual GcStore
|
class LocalStore : public virtual LocalStoreConfig, public virtual LocalFSStore, public virtual GcStore
|
||||||
{
|
{
|
||||||
|
|
40
src/libstore/local-store.md
Normal file
40
src/libstore/local-store.md
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
R"(
|
||||||
|
|
||||||
|
**Store URL format**: `local`, *root*
|
||||||
|
|
||||||
|
This store type accesses a Nix store in the local filesystem directly
|
||||||
|
(i.e. not via the Nix daemon). *root* is an absolute path that denotes
|
||||||
|
the "root" of the filesystem; other directories such as the Nix store
|
||||||
|
directory (as denoted by the `store` setting) are interpreted relative
|
||||||
|
to *root*. The store pseudo-URL `local` denotes a store that uses `/`
|
||||||
|
as its root directory.
|
||||||
|
|
||||||
|
A store that uses a *root* other than `/` is called a *chroot
|
||||||
|
store*. With such stores, the store directory is "logically" still
|
||||||
|
`/nix/store`, so programs stored in them can only be built and
|
||||||
|
executed by `chroot`-ing into *root*. Chroot stores only support
|
||||||
|
building and running on Linux when mount and user namespaces are
|
||||||
|
enabled.
|
||||||
|
|
||||||
|
For example, the following uses `/tmp/root` as the chroot environment
|
||||||
|
to build or download `nixpkgs#hello` and then execute it:
|
||||||
|
|
||||||
|
```console
|
||||||
|
# nix run --store /tmp/root nixpkgs#hello
|
||||||
|
Hello, world!
|
||||||
|
```
|
||||||
|
|
||||||
|
Here, the "physical" store location is `/tmp/root/nix/store`, and
|
||||||
|
Nix's store metadata is in `/tmp/root/nix/var/nix/db`.
|
||||||
|
|
||||||
|
It is also possible, but not recommended, to change the "logical"
|
||||||
|
location of the Nix store from its default of `/nix/store`. This makes
|
||||||
|
it impossible to use default substituters such as
|
||||||
|
`https://cache.nixos.org/`, and thus you may have to build everything
|
||||||
|
locally. Here is an example:
|
||||||
|
|
||||||
|
```console
|
||||||
|
# nix build --store 'local?store=/tmp/my-nix/store&state=/tmp/my-nix/state&log=/tmp/my-nix/log' nixpkgs#hello
|
||||||
|
```
|
||||||
|
|
||||||
|
)"
|
|
@ -205,6 +205,13 @@ struct S3BinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
|
||||||
(StoreConfig*) this, 5 * 1024 * 1024, "buffer-size", "size (in bytes) of each part in multi-part uploads"};
|
(StoreConfig*) this, 5 * 1024 * 1024, "buffer-size", "size (in bytes) of each part in multi-part uploads"};
|
||||||
|
|
||||||
const std::string name() override { return "S3 Binary Cache Store"; }
|
const std::string name() override { return "S3 Binary Cache Store"; }
|
||||||
|
|
||||||
|
std::string doc() override
|
||||||
|
{
|
||||||
|
return
|
||||||
|
#include "s3-binary-cache-store.md"
|
||||||
|
;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStoreConfig, public virtual S3BinaryCacheStore
|
struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStoreConfig, public virtual S3BinaryCacheStore
|
||||||
|
|
8
src/libstore/s3-binary-cache-store.md
Normal file
8
src/libstore/s3-binary-cache-store.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
R"(
|
||||||
|
|
||||||
|
**Store URL format**: `s3://`*bucket-name*
|
||||||
|
|
||||||
|
This store allows reading and writing a binary cache stored in an AWS
|
||||||
|
S3 bucket.
|
||||||
|
|
||||||
|
)"
|
|
@ -18,7 +18,14 @@ struct SSHStoreConfig : virtual RemoteStoreConfig
|
||||||
const Setting<Path> remoteProgram{(StoreConfig*) this, "nix-daemon", "remote-program", "path to the nix-daemon executable on the remote system"};
|
const Setting<Path> remoteProgram{(StoreConfig*) this, "nix-daemon", "remote-program", "path to the nix-daemon executable on the remote system"};
|
||||||
const Setting<std::string> remoteStore{(StoreConfig*) this, "", "remote-store", "URI of the store on the remote system"};
|
const Setting<std::string> remoteStore{(StoreConfig*) this, "", "remote-store", "URI of the store on the remote system"};
|
||||||
|
|
||||||
const std::string name() override { return "SSH Store"; }
|
const std::string name() override { return "Experimental SSH Store"; }
|
||||||
|
|
||||||
|
std::string doc() override
|
||||||
|
{
|
||||||
|
return
|
||||||
|
#include "ssh-store.md"
|
||||||
|
;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SSHStore : public virtual SSHStoreConfig, public virtual RemoteStore
|
class SSHStore : public virtual SSHStoreConfig, public virtual RemoteStore
|
||||||
|
|
8
src/libstore/ssh-store.md
Normal file
8
src/libstore/ssh-store.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
R"(
|
||||||
|
|
||||||
|
**Store URL format**: `ssh-ng://[username@]hostname`
|
||||||
|
|
||||||
|
Experimental store type that allows full access to a Nix store on a
|
||||||
|
remote machine.
|
||||||
|
|
||||||
|
)"
|
|
@ -101,6 +101,11 @@ struct StoreConfig : public Config
|
||||||
|
|
||||||
virtual const std::string name() = 0;
|
virtual const std::string name() = 0;
|
||||||
|
|
||||||
|
virtual std::string doc()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
const PathSetting storeDir_{this, false, settings.nixStore,
|
const PathSetting storeDir_{this, false, settings.nixStore,
|
||||||
"store", "path to the Nix store"};
|
"store", "path to the Nix store"};
|
||||||
const Path storeDir = storeDir_;
|
const Path storeDir = storeDir_;
|
||||||
|
|
|
@ -15,6 +15,13 @@ struct UDSRemoteStoreConfig : virtual LocalFSStoreConfig, virtual RemoteStoreCon
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string name() override { return "Local Daemon Store"; }
|
const std::string name() override { return "Local Daemon Store"; }
|
||||||
|
|
||||||
|
std::string doc() override
|
||||||
|
{
|
||||||
|
return
|
||||||
|
#include "uds-remote-store.md"
|
||||||
|
;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class UDSRemoteStore : public virtual UDSRemoteStoreConfig, public virtual LocalFSStore, public virtual RemoteStore
|
class UDSRemoteStore : public virtual UDSRemoteStoreConfig, public virtual LocalFSStore, public virtual RemoteStore
|
||||||
|
|
9
src/libstore/uds-remote-store.md
Normal file
9
src/libstore/uds-remote-store.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
R"(
|
||||||
|
|
||||||
|
**Store URL format**: `daemon`, `unix://`*path*
|
||||||
|
|
||||||
|
This store type accesses a Nix store by talking to a Nix daemon
|
||||||
|
listening on the Unix domain socket *path*. The store pseudo-URL
|
||||||
|
`daemon` is equivalent to `unix:///nix/var/nix/daemon-socket/socket`.
|
||||||
|
|
||||||
|
)"
|
|
@ -175,6 +175,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
||||||
for (auto & implem : *Implementations::registered) {
|
for (auto & implem : *Implementations::registered) {
|
||||||
auto storeConfig = implem.getConfig();
|
auto storeConfig = implem.getConfig();
|
||||||
auto storeName = storeConfig->name();
|
auto storeName = storeConfig->name();
|
||||||
|
stores[storeName]["doc"] = storeConfig->doc();
|
||||||
stores[storeName]["settings"] = storeConfig->toJSON();
|
stores[storeName]["settings"] = storeConfig->toJSON();
|
||||||
}
|
}
|
||||||
res["stores"] = std::move(stores);
|
res["stores"] = std::move(stores);
|
||||||
|
|
Loading…
Reference in a new issue