aboutsummaryrefslogtreecommitdiff
path: root/src/nix/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-03-30 19:14:17 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-03-30 19:16:45 +0200
commite1a94ad852e91fcdcf4efb60fe7e9b9e328df7ac (patch)
tree3bae2236d6bd11e3960394b99278191de021eff8 /src/nix/build.cc
parent367577d9a6ec465d773f7b3ba53a5656253f514d (diff)
Backport 'nix dev-shell' from the flakes branch
This also adds a '--profile' option to 'nix build' (replacing 'nix-env --set').
Diffstat (limited to 'src/nix/build.cc')
-rw-r--r--src/nix/build.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/nix/build.cc b/src/nix/build.cc
index 3c9d2df39..0b0762836 100644
--- a/src/nix/build.cc
+++ b/src/nix/build.cc
@@ -5,7 +5,7 @@
using namespace nix;
-struct CmdBuild : MixDryRun, InstallablesCommand
+struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
{
Path outLink = "result";
@@ -40,6 +40,10 @@ struct CmdBuild : MixDryRun, InstallablesCommand
"To build the build.x86_64-linux attribute from release.nix:",
"nix build -f release.nix build.x86_64-linux"
},
+ Example{
+ "To make a profile point at GNU Hello:",
+ "nix build --profile /tmp/profile nixpkgs.hello"
+ },
};
}
@@ -49,18 +53,19 @@ struct CmdBuild : MixDryRun, InstallablesCommand
if (dryRun) return;
- for (size_t i = 0; i < buildables.size(); ++i) {
- auto & b(buildables[i]);
-
- if (outLink != "")
- for (auto & output : b.outputs)
+ if (outLink != "") {
+ for (size_t i = 0; i < buildables.size(); ++i) {
+ for (auto & output : buildables[i].outputs)
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) {
std::string symlink = outLink;
if (i) symlink += fmt("-%d", i);
if (output.first != "out") symlink += fmt("-%s", output.first);
store2->addPermRoot(output.second, absPath(symlink), true);
}
+ }
}
+
+ updateProfile(buildables);
}
};