Remove bug-avoiding StoreConfig * casts for settings

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80431 has been fixed, and
per the previous commit we now check that is the case at build time.
This commit is contained in:
John Ericson 2023-10-30 18:12:37 -04:00
parent 1f4525531e
commit b2cae33aef
8 changed files with 32 additions and 36 deletions

View file

@ -17,28 +17,28 @@ struct BinaryCacheStoreConfig : virtual StoreConfig
{ {
using StoreConfig::StoreConfig; using StoreConfig::StoreConfig;
const Setting<std::string> compression{(StoreConfig*) this, "xz", "compression", const Setting<std::string> compression{this, "xz", "compression",
"NAR compression method (`xz`, `bzip2`, `gzip`, `zstd`, or `none`)."}; "NAR compression method (`xz`, `bzip2`, `gzip`, `zstd`, or `none`)."};
const Setting<bool> writeNARListing{(StoreConfig*) this, false, "write-nar-listing", const Setting<bool> writeNARListing{this, false, "write-nar-listing",
"Whether to write a JSON file that lists the files in each NAR."}; "Whether to write a JSON file that lists the files in each NAR."};
const Setting<bool> writeDebugInfo{(StoreConfig*) this, false, "index-debug-info", const Setting<bool> writeDebugInfo{this, false, "index-debug-info",
R"( R"(
Whether to index DWARF debug info files by build ID. This allows [`dwarffs`](https://github.com/edolstra/dwarffs) to Whether to index DWARF debug info files by build ID. This allows [`dwarffs`](https://github.com/edolstra/dwarffs) to
fetch debug info on demand fetch debug info on demand
)"}; )"};
const Setting<Path> secretKeyFile{(StoreConfig*) this, "", "secret-key", const Setting<Path> secretKeyFile{this, "", "secret-key",
"Path to the secret key used to sign the binary cache."}; "Path to the secret key used to sign the binary cache."};
const Setting<Path> localNarCache{(StoreConfig*) this, "", "local-nar-cache", const Setting<Path> localNarCache{this, "", "local-nar-cache",
"Path to a local cache of NARs fetched from this binary cache, used by commands such as `nix store cat`."}; "Path to a local cache of NARs fetched from this binary cache, used by commands such as `nix store cat`."};
const Setting<bool> parallelCompression{(StoreConfig*) this, false, "parallel-compression", const Setting<bool> parallelCompression{this, false, "parallel-compression",
"Enable multi-threaded compression of NARs. This is currently only available for `xz` and `zstd`."}; "Enable multi-threaded compression of NARs. This is currently only available for `xz` and `zstd`."};
const Setting<int> compressionLevel{(StoreConfig*) this, -1, "compression-level", const Setting<int> compressionLevel{this, -1, "compression-level",
R"( R"(
The *preset level* to be used when compressing NARs. The *preset level* to be used when compressing NARs.
The meaning and accepted values depend on the compression method selected. The meaning and accepted values depend on the compression method selected.

View file

@ -17,10 +17,10 @@ struct LegacySSHStoreConfig : virtual CommonSSHStoreConfig
{ {
using CommonSSHStoreConfig::CommonSSHStoreConfig; using CommonSSHStoreConfig::CommonSSHStoreConfig;
const Setting<Path> remoteProgram{(StoreConfig*) this, "nix-store", "remote-program", const Setting<Path> remoteProgram{this, "nix-store", "remote-program",
"Path to the `nix-store` executable on the remote machine."}; "Path to the `nix-store` executable on the remote machine."};
const Setting<int> maxConnections{(StoreConfig*) this, 1, "max-connections", const Setting<int> maxConnections{this, 1, "max-connections",
"Maximum number of concurrent SSH connections."}; "Maximum number of concurrent SSH connections."};
const std::string name() override { return "SSH Store"; } const std::string name() override { return "SSH Store"; }
@ -38,7 +38,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
// Hack for getting remote build log output. // Hack for getting remote build log output.
// Intentionally not in `LegacySSHStoreConfig` so that it doesn't appear in // Intentionally not in `LegacySSHStoreConfig` so that it doesn't appear in
// the documentation // the documentation
const Setting<int> logFD{(StoreConfig*) this, -1, "log-fd", "file descriptor to which SSH's stderr is connected"}; const Setting<int> logFD{this, -1, "log-fd", "file descriptor to which SSH's stderr is connected"};
struct Connection struct Connection
{ {

View file

@ -11,25 +11,21 @@ struct LocalFSStoreConfig : virtual StoreConfig
{ {
using StoreConfig::StoreConfig; using StoreConfig::StoreConfig;
// FIXME: the (StoreConfig*) cast works around a bug in gcc that causes const OptionalPathSetting rootDir{this, std::nullopt,
// it to omit the call to the Setting constructor. Clang works fine
// either way.
const OptionalPathSetting rootDir{(StoreConfig*) this, std::nullopt,
"root", "root",
"Directory prefixed to all other paths."}; "Directory prefixed to all other paths."};
const PathSetting stateDir{(StoreConfig*) this, const PathSetting stateDir{this,
rootDir.get() ? *rootDir.get() + "/nix/var/nix" : settings.nixStateDir, rootDir.get() ? *rootDir.get() + "/nix/var/nix" : settings.nixStateDir,
"state", "state",
"Directory where Nix will store state."}; "Directory where Nix will store state."};
const PathSetting logDir{(StoreConfig*) this, const PathSetting logDir{this,
rootDir.get() ? *rootDir.get() + "/nix/var/log/nix" : settings.nixLogDir, rootDir.get() ? *rootDir.get() + "/nix/var/log/nix" : settings.nixLogDir,
"log", "log",
"directory where Nix will store log files."}; "directory where Nix will store log files."};
const PathSetting realStoreDir{(StoreConfig*) this, const PathSetting realStoreDir{this,
rootDir.get() ? *rootDir.get() + "/nix/store" : storeDir, "real", rootDir.get() ? *rootDir.get() + "/nix/store" : storeDir, "real",
"Physical path of the Nix store."}; "Physical path of the Nix store."};
}; };

View file

@ -40,12 +40,12 @@ struct LocalStoreConfig : virtual LocalFSStoreConfig
{ {
using LocalFSStoreConfig::LocalFSStoreConfig; using LocalFSStoreConfig::LocalFSStoreConfig;
Setting<bool> requireSigs{(StoreConfig*) this, Setting<bool> requireSigs{this,
settings.requireSigs, settings.requireSigs,
"require-sigs", "require-sigs",
"Whether store paths copied into this store should have a trusted signature."}; "Whether store paths copied into this store should have a trusted signature."};
Setting<bool> readOnly{(StoreConfig*) this, Setting<bool> readOnly{this,
false, false,
"read-only", "read-only",
R"( R"(

View file

@ -22,10 +22,10 @@ struct RemoteStoreConfig : virtual StoreConfig
{ {
using StoreConfig::StoreConfig; using StoreConfig::StoreConfig;
const Setting<int> maxConnections{(StoreConfig*) this, 1, "max-connections", const Setting<int> maxConnections{this, 1, "max-connections",
"Maximum number of concurrent connections to the Nix daemon."}; "Maximum number of concurrent connections to the Nix daemon."};
const Setting<unsigned int> maxConnectionAge{(StoreConfig*) this, const Setting<unsigned int> maxConnectionAge{this,
std::numeric_limits<unsigned int>::max(), std::numeric_limits<unsigned int>::max(),
"max-connection-age", "max-connection-age",
"Maximum age of a connection before it is closed."}; "Maximum age of a connection before it is closed."};

View file

@ -193,20 +193,20 @@ struct S3BinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
{ {
using BinaryCacheStoreConfig::BinaryCacheStoreConfig; using BinaryCacheStoreConfig::BinaryCacheStoreConfig;
const Setting<std::string> profile{(StoreConfig*) this, "", "profile", const Setting<std::string> profile{this, "", "profile",
R"( R"(
The name of the AWS configuration profile to use. By default The name of the AWS configuration profile to use. By default
Nix will use the `default` profile. Nix will use the `default` profile.
)"}; )"};
const Setting<std::string> region{(StoreConfig*) this, Aws::Region::US_EAST_1, "region", const Setting<std::string> region{this, Aws::Region::US_EAST_1, "region",
R"( R"(
The region of the S3 bucket. If your bucket is not in The region of the S3 bucket. If your bucket is not in
`useast-1`, you should always explicitly specify the region `useast-1`, you should always explicitly specify the region
parameter. parameter.
)"}; )"};
const Setting<std::string> scheme{(StoreConfig*) this, "", "scheme", const Setting<std::string> scheme{this, "", "scheme",
R"( R"(
The scheme used for S3 requests, `https` (default) or `http`. This The scheme used for S3 requests, `https` (default) or `http`. This
option allows you to disable HTTPS for binary caches which don't option allows you to disable HTTPS for binary caches which don't
@ -218,7 +218,7 @@ struct S3BinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
> information. > information.
)"}; )"};
const Setting<std::string> endpoint{(StoreConfig*) this, "", "endpoint", const Setting<std::string> endpoint{this, "", "endpoint",
R"( R"(
The URL of the endpoint of an S3-compatible service such as MinIO. The URL of the endpoint of an S3-compatible service such as MinIO.
Do not specify this setting if you're using Amazon S3. Do not specify this setting if you're using Amazon S3.
@ -229,13 +229,13 @@ struct S3BinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
> addressing instead of virtual host based addressing. > addressing instead of virtual host based addressing.
)"}; )"};
const Setting<std::string> narinfoCompression{(StoreConfig*) this, "", "narinfo-compression", const Setting<std::string> narinfoCompression{this, "", "narinfo-compression",
"Compression method for `.narinfo` files."}; "Compression method for `.narinfo` files."};
const Setting<std::string> lsCompression{(StoreConfig*) this, "", "ls-compression", const Setting<std::string> lsCompression{this, "", "ls-compression",
"Compression method for `.ls` files."}; "Compression method for `.ls` files."};
const Setting<std::string> logCompression{(StoreConfig*) this, "", "log-compression", const Setting<std::string> logCompression{this, "", "log-compression",
R"( R"(
Compression method for `log/*` files. It is recommended to Compression method for `log/*` files. It is recommended to
use a compression method supported by most web browsers use a compression method supported by most web browsers
@ -243,11 +243,11 @@ struct S3BinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
)"}; )"};
const Setting<bool> multipartUpload{ const Setting<bool> multipartUpload{
(StoreConfig*) this, false, "multipart-upload", this, false, "multipart-upload",
"Whether to use multi-part uploads."}; "Whether to use multi-part uploads."};
const Setting<uint64_t> bufferSize{ const Setting<uint64_t> bufferSize{
(StoreConfig*) this, 5 * 1024 * 1024, "buffer-size", this, 5 * 1024 * 1024, "buffer-size",
"Size (in bytes) of each part in multi-part uploads."}; "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"; }

View file

@ -9,16 +9,16 @@ struct CommonSSHStoreConfig : virtual StoreConfig
{ {
using StoreConfig::StoreConfig; using StoreConfig::StoreConfig;
const Setting<Path> sshKey{(StoreConfig*) this, "", "ssh-key", const Setting<Path> sshKey{this, "", "ssh-key",
"Path to the SSH private key used to authenticate to the remote machine."}; "Path to the SSH private key used to authenticate to the remote machine."};
const Setting<std::string> sshPublicHostKey{(StoreConfig*) this, "", "base64-ssh-public-host-key", const Setting<std::string> sshPublicHostKey{this, "", "base64-ssh-public-host-key",
"The public host key of the remote machine."}; "The public host key of the remote machine."};
const Setting<bool> compress{(StoreConfig*) this, false, "compress", const Setting<bool> compress{this, false, "compress",
"Whether to enable SSH compression."}; "Whether to enable SSH compression."};
const Setting<std::string> remoteStore{(StoreConfig*) this, "", "remote-store", const Setting<std::string> remoteStore{this, "", "remote-store",
R"( R"(
[Store URL](@docroot@/command-ref/new-cli/nix3-help-stores.md#store-url-format) [Store URL](@docroot@/command-ref/new-cli/nix3-help-stores.md#store-url-format)
to be used on the remote machine. The default is `auto` to be used on the remote machine. The default is `auto`

View file

@ -16,7 +16,7 @@ struct SSHStoreConfig : virtual RemoteStoreConfig, virtual CommonSSHStoreConfig
using RemoteStoreConfig::RemoteStoreConfig; using RemoteStoreConfig::RemoteStoreConfig;
using CommonSSHStoreConfig::CommonSSHStoreConfig; using CommonSSHStoreConfig::CommonSSHStoreConfig;
const Setting<Path> remoteProgram{(StoreConfig*) this, "nix-daemon", "remote-program", const Setting<Path> remoteProgram{this, "nix-daemon", "remote-program",
"Path to the `nix-daemon` executable on the remote machine."}; "Path to the `nix-daemon` executable on the remote machine."};
const std::string name() override { return "Experimental SSH Store"; } const std::string name() override { return "Experimental SSH Store"; }