diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-02-14 20:39:44 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-02-14 21:06:11 +0100 |
commit | 023e45977745ffd6c16eec299a00affd65176669 (patch) | |
tree | 859c9b9126358e723c5e70c97cf7c490c3e6487f /src/nix | |
parent | 744a101a36696f39653400b76a6c9f6ba9bcbad8 (diff) |
InstallableFlake: Default attr paths cleanup
This removes some duplicated logic, and fixes "nix bundle" parsing its
installable twice.
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/bundle.cc | 19 | ||||
-rw-r--r-- | src/nix/develop.cc | 3 | ||||
-rw-r--r-- | src/nix/flake.cc | 15 | ||||
-rw-r--r-- | src/nix/profile.cc | 1 |
4 files changed, 19 insertions, 19 deletions
diff --git a/src/nix/bundle.cc b/src/nix/bundle.cc index 113ceca33..c13018328 100644 --- a/src/nix/bundle.cc +++ b/src/nix/bundle.cc @@ -74,21 +74,16 @@ struct CmdBundle : InstallableCommand { auto evalState = getEvalState(); - auto [progFlakeRef, progName] = parseFlakeRefWithFragment(installable->what(), absPath(".")); - const flake::LockFlags lockFlagsProg{ .writeLockFile = false }; - auto programInstallable = InstallableFlake(this, - evalState, std::move(progFlakeRef), - Strings{progName == "" ? "defaultApp" : progName}, - Strings(this->getDefaultFlakeAttrPathPrefixes()), - lockFlagsProg); - auto val = programInstallable.toValue(*evalState).first; + auto val = installable->toValue(*evalState).first; auto [bundlerFlakeRef, bundlerName] = parseFlakeRefWithFragment(bundler, absPath(".")); const flake::LockFlags lockFlags{ .writeLockFile = false }; - auto bundler = InstallableFlake(this, - evalState, std::move(bundlerFlakeRef), - Strings{bundlerName == "" ? "defaultBundler." + settings.thisSystem.get() : settings.thisSystem.get() + "." + bundlerName, bundlerName}, - Strings({"","bundlers."}), lockFlags); + InstallableFlake bundler{this, + evalState, std::move(bundlerFlakeRef), bundlerName, + {"defaultBundler." + settings.thisSystem.get()}, + {"bundlers." + settings.thisSystem.get() + "."}, + lockFlags + }; auto vRes = evalState->allocValue(); evalState->callFunction(*bundler.toValue(*evalState).first, *val, *vRes, noPos); diff --git a/src/nix/develop.cc b/src/nix/develop.cc index 42e13436a..f88f5909c 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -498,7 +498,8 @@ struct CmdDevelop : Common, MixEnvironment this, state, installable->nixpkgsFlakeRef(), - Strings{"bashInteractive"}, + "bashInteractive", + Strings{}, Strings{"legacyPackages." + settings.thisSystem.get() + "."}, nixpkgsLockFlags); diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 4bc79820c..3effce2c1 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -649,12 +649,14 @@ struct CmdFlakeCheck : FlakeCommand } }; +static Strings defaultTemplateAttrPathsPrefixes{"templates."}; +static Strings defaultTemplateAttrPaths = {"defaultTemplate"}; + struct CmdFlakeInitCommon : virtual Args, EvalCommand { std::string templateUrl = "templates"; Path destDir; - const Strings attrsPathPrefixes{"templates."}; const LockFlags lockFlags{ .writeLockFile = false }; CmdFlakeInitCommon() @@ -669,8 +671,8 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand completeFlakeRefWithFragment( getEvalState(), lockFlags, - attrsPathPrefixes, - {"defaultTemplate"}, + defaultTemplateAttrPathsPrefixes, + defaultTemplateAttrPaths, prefix); }} }); @@ -685,9 +687,10 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand auto [templateFlakeRef, templateName] = parseFlakeRefWithFragment(templateUrl, absPath(".")); auto installable = InstallableFlake(nullptr, - evalState, std::move(templateFlakeRef), - Strings{templateName == "" ? "defaultTemplate" : templateName}, - Strings(attrsPathPrefixes), lockFlags); + evalState, std::move(templateFlakeRef), templateName, + defaultTemplateAttrPaths, + defaultTemplateAttrPathsPrefixes, + lockFlags); auto [cursor, attrPath] = installable.getCursor(*evalState); diff --git a/src/nix/profile.cc b/src/nix/profile.cc index b9279414d..55b5ff736 100644 --- a/src/nix/profile.cc +++ b/src/nix/profile.cc @@ -423,6 +423,7 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf this, getEvalState(), FlakeRef(element.source->originalRef), + "", {element.source->attrPath}, {}, lockFlags); |