-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix build hook error for libstore library users
A library shouldn't require changes to the caller's argument handling, especially if it doesn't have to, and indeed we don't have to. This changes the lookup order to prioritize the hardcoded path to nix if it exists. The static executable still finds itself through /proc and the like.
- Loading branch information
Showing
8 changed files
with
84 additions
and
1 deletion.
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
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
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,5 @@ | ||
source common.sh | ||
|
||
drv="$(nix-instantiate simple.nix)" | ||
cat "$drv" | ||
./test-libstoreconsumer/test-libstoreconsumer "$drv" |
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,6 @@ | ||
|
||
A very simple C++ consumer of the libstore library. | ||
|
||
- Keep it simple. Library consumers expect something simple. | ||
- No build hook, or any other reinvocations. | ||
- No more global state than necessary. |
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,12 @@ | ||
programs += test-libstoreconsumer | ||
|
||
test-libstoreconsumer_DIR := $(d) | ||
|
||
test-libstoreconsumer_SOURCES := \ | ||
$(wildcard $(d)/*.cc) \ | ||
|
||
test-libstoreconsumer_CXXFLAGS += -I src/libutil -I src/libstore | ||
|
||
test-libstoreconsumer_LIBS = libexpr libstore libutil | ||
|
||
test-libstoreconsumer_LDFLAGS = -pthread $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS) |
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,34 @@ | ||
#include "globals.hh" | ||
#include "store-api.hh" | ||
#include <iostream> | ||
|
||
using namespace nix; | ||
|
||
int main (int argc, char **argv) | ||
{ | ||
if (argc != 2) { | ||
std::cerr << "Usage: " << argv[0] << " store/path/to/something.drv\n"; | ||
return 1; | ||
} | ||
|
||
std::string drvPath = argv[1]; | ||
|
||
initLibStore(); | ||
|
||
auto store = nix::openStore(); | ||
|
||
// build the derivation | ||
|
||
std::vector<DerivedPath> paths { | ||
DerivedPath::Built( | ||
store->parseStorePath(drvPath), | ||
OutputsSpec::Names{"out"} | ||
) | ||
}; | ||
|
||
store->buildPaths(paths, bmNormal, store); | ||
|
||
// print the out path maybe? | ||
|
||
return 0; | ||
} |