2023-02-19 16:11:20 +00:00
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
2023-04-17 15:22:31 +00:00
|
|
|
#include "experimental-features.hh"
|
2023-02-19 16:11:20 +00:00
|
|
|
#include "derivations.hh"
|
|
|
|
|
|
|
|
#include "tests/libstore.hh"
|
2023-10-26 21:58:45 +00:00
|
|
|
#include "tests/characterization.hh"
|
2023-02-19 16:11:20 +00:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2023-10-26 21:58:45 +00:00
|
|
|
using nlohmann::json;
|
|
|
|
|
2023-02-19 16:11:20 +00:00
|
|
|
class DerivationTest : public LibStoreTest
|
|
|
|
{
|
2023-04-17 15:22:31 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* We set these in tests rather than the regular globals so we don't have
|
|
|
|
* to worry about race conditions if the tests run concurrently.
|
|
|
|
*/
|
|
|
|
ExperimentalFeatureSettings mockXpSettings;
|
2023-10-26 21:58:45 +00:00
|
|
|
|
|
|
|
Path unitTestData = getUnitTestData() + "/libstore/derivation";
|
|
|
|
|
|
|
|
Path goldenMaster(std::string_view testStem) {
|
|
|
|
return unitTestData + "/" + testStem;
|
|
|
|
}
|
2023-02-19 16:11:20 +00:00
|
|
|
};
|
|
|
|
|
2023-04-17 15:22:31 +00:00
|
|
|
class CaDerivationTest : public DerivationTest
|
|
|
|
{
|
|
|
|
void SetUp() override
|
|
|
|
{
|
|
|
|
mockXpSettings.set("experimental-features", "ca-derivations");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-04-19 15:33:48 +00:00
|
|
|
class DynDerivationTest : public DerivationTest
|
|
|
|
{
|
|
|
|
void SetUp() override
|
|
|
|
{
|
|
|
|
mockXpSettings.set("experimental-features", "dynamic-derivations ca-derivations");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-04-17 15:22:31 +00:00
|
|
|
class ImpureDerivationTest : public DerivationTest
|
|
|
|
{
|
|
|
|
void SetUp() override
|
|
|
|
{
|
|
|
|
mockXpSettings.set("experimental-features", "impure-derivations");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-01 22:05:53 +00:00
|
|
|
TEST_F(DerivationTest, BadATerm_version) {
|
|
|
|
ASSERT_THROW(
|
|
|
|
parseDerivation(
|
|
|
|
*store,
|
2023-10-26 21:58:45 +00:00
|
|
|
readFile(goldenMaster("bad-version.drv")),
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-01 22:05:53 +00:00
|
|
|
"whatever",
|
|
|
|
mockXpSettings),
|
|
|
|
FormatError);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DynDerivationTest, BadATerm_oldVersionDynDeps) {
|
|
|
|
ASSERT_THROW(
|
|
|
|
parseDerivation(
|
|
|
|
*store,
|
2023-10-26 21:58:45 +00:00
|
|
|
readFile(goldenMaster("bad-old-version-dyn-deps.drv")),
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-01 22:05:53 +00:00
|
|
|
"dyn-dep-derivation",
|
|
|
|
mockXpSettings),
|
|
|
|
FormatError);
|
|
|
|
}
|
|
|
|
|
2023-10-26 21:58:45 +00:00
|
|
|
#define TEST_JSON(FIXTURE, NAME, VAL, DRV_NAME, OUTPUT_NAME) \
|
|
|
|
TEST_F(FIXTURE, DerivationOutput_ ## NAME ## _from_json) { \
|
|
|
|
if (testAccept()) \
|
|
|
|
{ \
|
|
|
|
GTEST_SKIP() << cannotReadGoldenMaster; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
auto encoded = json::parse( \
|
|
|
|
readFile(goldenMaster("output-" #NAME ".json"))); \
|
|
|
|
DerivationOutput got = DerivationOutput::fromJSON( \
|
|
|
|
*store, \
|
|
|
|
DRV_NAME, \
|
|
|
|
OUTPUT_NAME, \
|
|
|
|
encoded, \
|
|
|
|
mockXpSettings); \
|
|
|
|
DerivationOutput expected { VAL }; \
|
|
|
|
ASSERT_EQ(got, expected); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
TEST_F(FIXTURE, DerivationOutput_ ## NAME ## _to_json) { \
|
|
|
|
auto file = goldenMaster("output-" #NAME ".json"); \
|
|
|
|
\
|
|
|
|
json got = DerivationOutput { VAL }.toJSON( \
|
|
|
|
*store, \
|
|
|
|
DRV_NAME, \
|
|
|
|
OUTPUT_NAME); \
|
|
|
|
\
|
|
|
|
if (testAccept()) \
|
|
|
|
{ \
|
|
|
|
createDirs(dirOf(file)); \
|
|
|
|
writeFile(file, got.dump(2) + "\n"); \
|
|
|
|
GTEST_SKIP() << updatingGoldenMaster; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
auto expected = json::parse(readFile(file)); \
|
|
|
|
ASSERT_EQ(got, expected); \
|
|
|
|
} \
|
2023-02-19 16:11:20 +00:00
|
|
|
}
|
|
|
|
|
2023-04-17 15:22:31 +00:00
|
|
|
TEST_JSON(DerivationTest, inputAddressed,
|
2023-02-19 16:11:20 +00:00
|
|
|
(DerivationOutput::InputAddressed {
|
|
|
|
.path = store->parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-drv-name-output-name"),
|
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-04-19 18:48:53 +00:00
|
|
|
TEST_JSON(DerivationTest, caFixedFlat,
|
|
|
|
(DerivationOutput::CAFixed {
|
2023-07-05 22:53:44 +00:00
|
|
|
.ca = {
|
2023-04-19 18:48:53 +00:00
|
|
|
.method = FileIngestionMethod::Flat,
|
|
|
|
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
|
|
|
TEST_JSON(DerivationTest, caFixedNAR,
|
2023-02-19 16:11:20 +00:00
|
|
|
(DerivationOutput::CAFixed {
|
2023-07-05 22:53:44 +00:00
|
|
|
.ca = {
|
2023-04-19 18:48:53 +00:00
|
|
|
.method = FileIngestionMethod::Recursive,
|
|
|
|
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
2023-02-28 17:46:00 +00:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-04-19 15:33:48 +00:00
|
|
|
TEST_JSON(DynDerivationTest, caFixedText,
|
2023-02-28 17:46:00 +00:00
|
|
|
(DerivationOutput::CAFixed {
|
2023-07-05 22:53:44 +00:00
|
|
|
.ca = {
|
2023-04-19 18:48:53 +00:00
|
|
|
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
2023-02-19 16:11:20 +00:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-04-17 15:22:31 +00:00
|
|
|
TEST_JSON(CaDerivationTest, caFloating,
|
2023-02-19 16:11:20 +00:00
|
|
|
(DerivationOutput::CAFloating {
|
|
|
|
.method = FileIngestionMethod::Recursive,
|
|
|
|
.hashType = htSHA256,
|
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-04-17 15:22:31 +00:00
|
|
|
TEST_JSON(DerivationTest, deferred,
|
2023-02-19 16:11:20 +00:00
|
|
|
DerivationOutput::Deferred { },
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-04-17 15:22:31 +00:00
|
|
|
TEST_JSON(ImpureDerivationTest, impure,
|
2023-02-19 16:11:20 +00:00
|
|
|
(DerivationOutput::Impure {
|
|
|
|
.method = FileIngestionMethod::Recursive,
|
|
|
|
.hashType = htSHA256,
|
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-02-17 23:37:35 +00:00
|
|
|
#undef TEST_JSON
|
|
|
|
|
2023-10-26 21:58:45 +00:00
|
|
|
#define TEST_JSON(FIXTURE, NAME, VAL) \
|
|
|
|
TEST_F(FIXTURE, Derivation_ ## NAME ## _from_json) { \
|
|
|
|
if (testAccept()) \
|
|
|
|
{ \
|
|
|
|
GTEST_SKIP() << cannotReadGoldenMaster; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
auto encoded = json::parse( \
|
|
|
|
readFile(goldenMaster( #NAME ".json"))); \
|
|
|
|
Derivation expected { VAL }; \
|
|
|
|
Derivation got = Derivation::fromJSON( \
|
|
|
|
*store, \
|
|
|
|
encoded, \
|
|
|
|
mockXpSettings); \
|
|
|
|
ASSERT_EQ(got, expected); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
TEST_F(FIXTURE, Derivation_ ## NAME ## _to_json) { \
|
|
|
|
auto file = goldenMaster( #NAME ".json"); \
|
|
|
|
\
|
|
|
|
json got = Derivation { VAL }.toJSON(*store); \
|
|
|
|
\
|
|
|
|
if (testAccept()) \
|
|
|
|
{ \
|
|
|
|
createDirs(dirOf(file)); \
|
|
|
|
writeFile(file, got.dump(2) + "\n"); \
|
|
|
|
GTEST_SKIP() << updatingGoldenMaster; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
auto expected = json::parse(readFile(file)); \
|
|
|
|
ASSERT_EQ(got, expected); \
|
|
|
|
} \
|
2023-02-17 23:37:35 +00:00
|
|
|
}
|
|
|
|
|
2023-10-26 21:58:45 +00:00
|
|
|
#define TEST_ATERM(FIXTURE, NAME, VAL, DRV_NAME) \
|
|
|
|
TEST_F(FIXTURE, Derivation_ ## NAME ## _from_aterm) { \
|
|
|
|
if (testAccept()) \
|
|
|
|
{ \
|
|
|
|
GTEST_SKIP() << cannotReadGoldenMaster; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
auto encoded = readFile(goldenMaster( #NAME ".drv")); \
|
|
|
|
Derivation expected { VAL }; \
|
|
|
|
auto got = parseDerivation( \
|
|
|
|
*store, \
|
|
|
|
std::move(encoded), \
|
|
|
|
DRV_NAME, \
|
|
|
|
mockXpSettings); \
|
|
|
|
ASSERT_EQ(got.toJSON(*store), expected.toJSON(*store)) ; \
|
|
|
|
ASSERT_EQ(got, expected); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
TEST_F(FIXTURE, Derivation_ ## NAME ## _to_aterm) { \
|
|
|
|
auto file = goldenMaster( #NAME ".drv"); \
|
|
|
|
\
|
|
|
|
auto got = (VAL).unparse(*store, false); \
|
|
|
|
\
|
|
|
|
if (testAccept()) \
|
|
|
|
{ \
|
|
|
|
createDirs(dirOf(file)); \
|
|
|
|
writeFile(file, got); \
|
|
|
|
GTEST_SKIP() << updatingGoldenMaster; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
auto expected = readFile(file); \
|
|
|
|
ASSERT_EQ(got, expected); \
|
|
|
|
} \
|
2023-09-05 15:16:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Derivation makeSimpleDrv(const Store & store) {
|
|
|
|
Derivation drv;
|
|
|
|
drv.name = "simple-derivation";
|
|
|
|
drv.inputSrcs = {
|
|
|
|
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"),
|
|
|
|
};
|
|
|
|
drv.inputDrvs = {
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-01 22:05:53 +00:00
|
|
|
.map = {
|
2023-09-05 15:16:39 +00:00
|
|
|
{
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-01 22:05:53 +00:00
|
|
|
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv"),
|
|
|
|
{
|
|
|
|
.value = {
|
|
|
|
"cat",
|
|
|
|
"dog",
|
|
|
|
},
|
|
|
|
},
|
2023-09-05 15:16:39 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
drv.platform = "wasm-sel4";
|
|
|
|
drv.builder = "foo";
|
|
|
|
drv.args = {
|
|
|
|
"bar",
|
|
|
|
"baz",
|
|
|
|
};
|
|
|
|
drv.env = {
|
|
|
|
{
|
|
|
|
"BIG_BAD",
|
|
|
|
"WOLF",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
2023-10-26 21:58:45 +00:00
|
|
|
TEST_JSON(DerivationTest, simple, makeSimpleDrv(*store))
|
2023-09-05 15:16:39 +00:00
|
|
|
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-01 22:05:53 +00:00
|
|
|
TEST_ATERM(DerivationTest, simple,
|
2023-09-05 15:16:39 +00:00
|
|
|
makeSimpleDrv(*store),
|
|
|
|
"simple-derivation")
|
2023-02-19 16:11:20 +00:00
|
|
|
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-01 22:05:53 +00:00
|
|
|
Derivation makeDynDepDerivation(const Store & store) {
|
|
|
|
Derivation drv;
|
|
|
|
drv.name = "dyn-dep-derivation";
|
|
|
|
drv.inputSrcs = {
|
|
|
|
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"),
|
|
|
|
};
|
|
|
|
drv.inputDrvs = {
|
|
|
|
.map = {
|
|
|
|
{
|
|
|
|
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv"),
|
|
|
|
DerivedPathMap<StringSet>::ChildNode {
|
|
|
|
.value = {
|
|
|
|
"cat",
|
|
|
|
"dog",
|
|
|
|
},
|
|
|
|
.childMap = {
|
|
|
|
{
|
|
|
|
"cat",
|
|
|
|
DerivedPathMap<StringSet>::ChildNode {
|
|
|
|
.value = {
|
|
|
|
"kitten",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"goose",
|
|
|
|
DerivedPathMap<StringSet>::ChildNode {
|
|
|
|
.value = {
|
|
|
|
"gosling",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
drv.platform = "wasm-sel4";
|
|
|
|
drv.builder = "foo";
|
|
|
|
drv.args = {
|
|
|
|
"bar",
|
|
|
|
"baz",
|
|
|
|
};
|
|
|
|
drv.env = {
|
|
|
|
{
|
|
|
|
"BIG_BAD",
|
|
|
|
"WOLF",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
2023-10-26 21:58:45 +00:00
|
|
|
TEST_JSON(DynDerivationTest, dynDerivationDeps, makeDynDepDerivation(*store))
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-01 22:05:53 +00:00
|
|
|
|
|
|
|
TEST_ATERM(DynDerivationTest, dynDerivationDeps,
|
|
|
|
makeDynDepDerivation(*store),
|
|
|
|
"dyn-dep-derivation")
|
|
|
|
|
2023-02-19 16:11:20 +00:00
|
|
|
#undef TEST_JSON
|
2023-09-05 15:16:39 +00:00
|
|
|
#undef TEST_ATERM
|
2023-02-19 16:11:20 +00:00
|
|
|
|
|
|
|
}
|