forked from LnL7/nix
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP Start getting store settings off config.hh
- Loading branch information
1 parent
fcf3e32
commit 3b0edea
Showing
6 changed files
with
103 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
/** | ||
* Look up the setting's name in a map, falling back on the default if | ||
* it does not exist. | ||
*/ | ||
#define CONFIG_ROW(FIELD) \ | ||
.FIELD = { \ | ||
.value = ({ \ | ||
auto p = get(params, descriptions.FIELD.name); \ | ||
p ? *p : defaults.FIELD.value; \ | ||
}) \ | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "store-dir-config.hh" | ||
#include "config-parse.hh" | ||
#include "util.hh" | ||
|
||
namespace nix { | ||
|
||
const StoreDirConfigT<JustValue> storeDirConfigDefaults = { | ||
.storeDir = | ||
{ | ||
.value = settings.nixStore, | ||
}, | ||
}; | ||
|
||
const StoreDirConfigT<SettingInfo> storeDirConfigDescriptions = { | ||
.storeDir = | ||
{ | ||
.name = "store", | ||
.description = R"( | ||
Logical location of the Nix store, usually | ||
`/nix/store`. Note that you can only copy store paths | ||
between stores if they have the same `store` setting. | ||
)", | ||
}, | ||
}; | ||
|
||
StoreDirConfigT<JustValue> parseStoreDirConfig(const StoreReference::Params & params) | ||
{ | ||
constexpr auto & defaults = storeDirConfigDefaults; | ||
constexpr auto & descriptions = storeDirConfigDescriptions; | ||
|
||
return { | ||
CONFIG_ROW(storeDir), | ||
}; | ||
} | ||
|
||
StoreDirConfig::StoreDirConfig(const StoreReference::Params & params) | ||
: StoreDirConfigT<JustValue>{parseStoreDirConfig(params)} | ||
{ | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
///@type | ||
|
||
namespace nix { | ||
|
||
template<typename T> | ||
struct JustValue | ||
{ | ||
T value; | ||
|
||
operator const T &() const | ||
{ | ||
return value; | ||
} | ||
operator T &() | ||
{ | ||
return value; | ||
} | ||
const T & get() const | ||
{ | ||
return value; | ||
} | ||
}; | ||
|
||
template<typename T> | ||
struct SettingInfo | ||
{ | ||
std::string name; | ||
std::string description; | ||
}; | ||
|
||
} |