mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 02:36:16 +02:00
parent
26c3fc11ea
commit
b5c88650c5
1 changed files with 9 additions and 7 deletions
|
@ -11,11 +11,13 @@
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
|
|
||||||
|
namespace nix::fs { using namespace std::filesystem; }
|
||||||
|
|
||||||
struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption
|
struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption
|
||||||
{
|
{
|
||||||
bool raw = false;
|
bool raw = false;
|
||||||
std::optional<std::string> apply;
|
std::optional<std::string> apply;
|
||||||
std::optional<Path> writeTo;
|
std::optional<fs::path> writeTo;
|
||||||
|
|
||||||
CmdEval() : InstallableValueCommand()
|
CmdEval() : InstallableValueCommand()
|
||||||
{
|
{
|
||||||
|
@ -75,20 +77,20 @@ struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption
|
||||||
if (writeTo) {
|
if (writeTo) {
|
||||||
stopProgressBar();
|
stopProgressBar();
|
||||||
|
|
||||||
if (pathExists(*writeTo))
|
if (fs::symlink_exists(*writeTo))
|
||||||
throw Error("path '%s' already exists", *writeTo);
|
throw Error("path '%s' already exists", writeTo->string());
|
||||||
|
|
||||||
std::function<void(Value & v, const PosIdx pos, const std::filesystem::path & path)> recurse;
|
std::function<void(Value & v, const PosIdx pos, const fs::path & path)> recurse;
|
||||||
|
|
||||||
recurse = [&](Value & v, const PosIdx pos, const std::filesystem::path & path)
|
recurse = [&](Value & v, const PosIdx pos, const fs::path & path)
|
||||||
{
|
{
|
||||||
state->forceValue(v, pos);
|
state->forceValue(v, pos);
|
||||||
if (v.type() == nString)
|
if (v.type() == nString)
|
||||||
// FIXME: disallow strings with contexts?
|
// FIXME: disallow strings with contexts?
|
||||||
writeFile(path.string(), v.string_view());
|
writeFile(path.string(), v.string_view());
|
||||||
else if (v.type() == nAttrs) {
|
else if (v.type() == nAttrs) {
|
||||||
// TODO abstract mkdir perms for Windows
|
// Directory should not already exist
|
||||||
createDir(path.string(), 0777);
|
assert(fs::create_directory(path.string()));
|
||||||
for (auto & attr : *v.attrs()) {
|
for (auto & attr : *v.attrs()) {
|
||||||
std::string_view name = state->symbols[attr.name];
|
std::string_view name = state->symbols[attr.name];
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue