mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
Test derivation options with content-addressing too
Now, both the unit and functional tests relating to derivation options are tested both ways -- with input addressing and content-addressing derivations.
This commit is contained in:
parent
7acc229c8f
commit
307dbe9914
37 changed files with 560 additions and 94 deletions
|
@ -1 +0,0 @@
|
||||||
../../../../tests/functional/derivation/advanced-attributes-defaults.drv
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../tests/functional/derivation/advanced-attributes-structured-attrs-defaults.drv
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../tests/functional/derivation/advanced-attributes-structured-attrs.drv
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../tests/functional/derivation/advanced-attributes.drv
|
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../tests/functional/derivation/ca/advanced-attributes-defaults.drv
|
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
"-c",
|
||||||
|
"echo hello > $out"
|
||||||
|
],
|
||||||
|
"builder": "/bin/bash",
|
||||||
|
"env": {
|
||||||
|
"builder": "/bin/bash",
|
||||||
|
"name": "advanced-attributes-defaults",
|
||||||
|
"out": "/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9",
|
||||||
|
"outputHashAlgo": "sha256",
|
||||||
|
"outputHashMode": "recursive",
|
||||||
|
"system": "my-system"
|
||||||
|
},
|
||||||
|
"inputDrvs": {},
|
||||||
|
"inputSrcs": [],
|
||||||
|
"name": "advanced-attributes-defaults",
|
||||||
|
"outputs": {
|
||||||
|
"out": {
|
||||||
|
"hashAlgo": "sha256",
|
||||||
|
"method": "nar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"system": "my-system"
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../tests/functional/derivation/ca/advanced-attributes-structured-attrs-defaults.drv
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
"-c",
|
||||||
|
"echo hello > $out"
|
||||||
|
],
|
||||||
|
"builder": "/bin/bash",
|
||||||
|
"env": {
|
||||||
|
"__json": "{\"builder\":\"/bin/bash\",\"name\":\"advanced-attributes-structured-attrs-defaults\",\"outputHashAlgo\":\"sha256\",\"outputHashMode\":\"recursive\",\"outputs\":[\"out\",\"dev\"],\"system\":\"my-system\"}",
|
||||||
|
"dev": "/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz",
|
||||||
|
"out": "/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9"
|
||||||
|
},
|
||||||
|
"inputDrvs": {},
|
||||||
|
"inputSrcs": [],
|
||||||
|
"name": "advanced-attributes-structured-attrs-defaults",
|
||||||
|
"outputs": {
|
||||||
|
"dev": {
|
||||||
|
"hashAlgo": "sha256",
|
||||||
|
"method": "nar"
|
||||||
|
},
|
||||||
|
"out": {
|
||||||
|
"hashAlgo": "sha256",
|
||||||
|
"method": "nar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"system": "my-system"
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../tests/functional/derivation/ca/advanced-attributes-structured-attrs.drv
|
|
@ -0,0 +1,44 @@
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
"-c",
|
||||||
|
"echo hello > $out"
|
||||||
|
],
|
||||||
|
"builder": "/bin/bash",
|
||||||
|
"env": {
|
||||||
|
"__json": "{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99\"],\"disallowedRequisites\":[\"/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8\"],\"allowedRequisites\":[\"/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8\"]}},\"outputHashAlgo\":\"sha256\",\"outputHashMode\":\"recursive\",\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}",
|
||||||
|
"bin": "/04f3da1kmbr67m3gzxikmsl4vjz5zf777sv6m14ahv22r65aac9m",
|
||||||
|
"dev": "/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz",
|
||||||
|
"out": "/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9"
|
||||||
|
},
|
||||||
|
"inputDrvs": {
|
||||||
|
"/nix/store/spfzlnkwb1v8s62yvh8vj1apd1kwjr5f-foo.drv": {
|
||||||
|
"dynamicOutputs": {},
|
||||||
|
"outputs": [
|
||||||
|
"out"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"/nix/store/x1vpzav565aqr7ccmkn0wv0svkm1qrbl-bar.drv": {
|
||||||
|
"dynamicOutputs": {},
|
||||||
|
"outputs": [
|
||||||
|
"out"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"inputSrcs": [],
|
||||||
|
"name": "advanced-attributes-structured-attrs",
|
||||||
|
"outputs": {
|
||||||
|
"bin": {
|
||||||
|
"hashAlgo": "sha256",
|
||||||
|
"method": "nar"
|
||||||
|
},
|
||||||
|
"dev": {
|
||||||
|
"hashAlgo": "sha256",
|
||||||
|
"method": "nar"
|
||||||
|
},
|
||||||
|
"out": {
|
||||||
|
"hashAlgo": "sha256",
|
||||||
|
"method": "nar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"system": "my-system"
|
||||||
|
}
|
1
src/libstore-tests/data/derivation/ca/advanced-attributes.drv
Symbolic link
1
src/libstore-tests/data/derivation/ca/advanced-attributes.drv
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../../../../tests/functional/derivation/ca/advanced-attributes.drv
|
|
@ -0,0 +1,50 @@
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
"-c",
|
||||||
|
"echo hello > $out"
|
||||||
|
],
|
||||||
|
"builder": "/bin/bash",
|
||||||
|
"env": {
|
||||||
|
"__darwinAllowLocalNetworking": "1",
|
||||||
|
"__impureHostDeps": "/usr/bin/ditto",
|
||||||
|
"__noChroot": "1",
|
||||||
|
"__sandboxProfile": "sandcastle",
|
||||||
|
"allowSubstitutes": "",
|
||||||
|
"allowedReferences": "/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8",
|
||||||
|
"allowedRequisites": "/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8",
|
||||||
|
"builder": "/bin/bash",
|
||||||
|
"disallowedReferences": "/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99",
|
||||||
|
"disallowedRequisites": "/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99",
|
||||||
|
"impureEnvVars": "UNICORN",
|
||||||
|
"name": "advanced-attributes",
|
||||||
|
"out": "/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9",
|
||||||
|
"outputHashAlgo": "sha256",
|
||||||
|
"outputHashMode": "recursive",
|
||||||
|
"preferLocalBuild": "1",
|
||||||
|
"requiredSystemFeatures": "rainbow uid-range",
|
||||||
|
"system": "my-system"
|
||||||
|
},
|
||||||
|
"inputDrvs": {
|
||||||
|
"/nix/store/spfzlnkwb1v8s62yvh8vj1apd1kwjr5f-foo.drv": {
|
||||||
|
"dynamicOutputs": {},
|
||||||
|
"outputs": [
|
||||||
|
"out"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"/nix/store/x1vpzav565aqr7ccmkn0wv0svkm1qrbl-bar.drv": {
|
||||||
|
"dynamicOutputs": {},
|
||||||
|
"outputs": [
|
||||||
|
"out"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"inputSrcs": [],
|
||||||
|
"name": "advanced-attributes",
|
||||||
|
"outputs": {
|
||||||
|
"out": {
|
||||||
|
"hashAlgo": "sha256",
|
||||||
|
"method": "nar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"system": "my-system"
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../tests/functional/derivation/ia/advanced-attributes-defaults.drv
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../tests/functional/derivation/ia/advanced-attributes-structured-attrs-defaults.drv
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../tests/functional/derivation/ia/advanced-attributes-structured-attrs.drv
|
1
src/libstore-tests/data/derivation/ia/advanced-attributes.drv
Symbolic link
1
src/libstore-tests/data/derivation/ia/advanced-attributes.drv
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../../../../tests/functional/derivation/ia/advanced-attributes.drv
|
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
"-c",
|
||||||
|
"echo hello > $out"
|
||||||
|
],
|
||||||
|
"builder": "/bin/bash",
|
||||||
|
"env": {
|
||||||
|
"__darwinAllowLocalNetworking": "1",
|
||||||
|
"__impureHostDeps": "/usr/bin/ditto",
|
||||||
|
"__noChroot": "1",
|
||||||
|
"__sandboxProfile": "sandcastle",
|
||||||
|
"allowSubstitutes": "",
|
||||||
|
"allowedReferences": "/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo",
|
||||||
|
"allowedRequisites": "/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo",
|
||||||
|
"builder": "/bin/bash",
|
||||||
|
"disallowedReferences": "/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar",
|
||||||
|
"disallowedRequisites": "/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar",
|
||||||
|
"impureEnvVars": "UNICORN",
|
||||||
|
"name": "advanced-attributes",
|
||||||
|
"out": "/nix/store/33a6fdmn8q9ih9d7npbnrxn2q56a4l8q-advanced-attributes",
|
||||||
|
"preferLocalBuild": "1",
|
||||||
|
"requiredSystemFeatures": "rainbow uid-range",
|
||||||
|
"system": "my-system"
|
||||||
|
},
|
||||||
|
"inputDrvs": {
|
||||||
|
"/nix/store/4xm4wccqsvagz9gjksn24s7rip2fdy7v-foo.drv": {
|
||||||
|
"dynamicOutputs": {},
|
||||||
|
"outputs": [
|
||||||
|
"out"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"/nix/store/plsq5jbr5nhgqwcgb2qxw7jchc09dnl8-bar.drv": {
|
||||||
|
"dynamicOutputs": {},
|
||||||
|
"outputs": [
|
||||||
|
"out"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"inputSrcs": [],
|
||||||
|
"name": "advanced-attributes",
|
||||||
|
"outputs": {
|
||||||
|
"out": {
|
||||||
|
"path": "/nix/store/33a6fdmn8q9ih9d7npbnrxn2q56a4l8q-advanced-attributes"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"system": "my-system"
|
||||||
|
}
|
|
@ -18,68 +18,93 @@ using nlohmann::json;
|
||||||
|
|
||||||
class DerivationAdvancedAttrsTest : public CharacterizationTest, public LibStoreTest
|
class DerivationAdvancedAttrsTest : public CharacterizationTest, public LibStoreTest
|
||||||
{
|
{
|
||||||
std::filesystem::path unitTestData = getUnitTestData() / "derivation";
|
protected:
|
||||||
|
std::filesystem::path unitTestData = getUnitTestData() / "derivation" / "ia";
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::filesystem::path goldenMaster(std::string_view testStem) const override
|
std::filesystem::path goldenMaster(std::string_view testStem) const override
|
||||||
{
|
{
|
||||||
return unitTestData / testStem;
|
return unitTestData / testStem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TEST_ATERM_JSON(STEM, NAME) \
|
class CaDerivationAdvancedAttrsTest : public DerivationAdvancedAttrsTest
|
||||||
TEST_F(DerivationAdvancedAttrsTest, Derivation_##STEM##_from_json) \
|
{
|
||||||
{ \
|
void SetUp() override
|
||||||
readTest(NAME ".json", [&](const auto & encoded_) { \
|
{
|
||||||
auto encoded = json::parse(encoded_); \
|
unitTestData = getUnitTestData() / "derivation" / "ca";
|
||||||
/* Use DRV file instead of C++ literal as source of truth. */ \
|
mockXpSettings.set("experimental-features", "ca-derivations");
|
||||||
auto aterm = readFile(goldenMaster(NAME ".drv")); \
|
}
|
||||||
auto expected = parseDerivation(*store, std::move(aterm), NAME); \
|
};
|
||||||
Derivation got = Derivation::fromJSON(*store, encoded); \
|
|
||||||
EXPECT_EQ(got, expected); \
|
template<class Fixture>
|
||||||
}); \
|
class DerivationAdvancedAttrsBothTest : public Fixture
|
||||||
} \
|
{};
|
||||||
\
|
|
||||||
TEST_F(DerivationAdvancedAttrsTest, Derivation_##STEM##_to_json) \
|
using BothFixtures = ::testing::Types<DerivationAdvancedAttrsTest, CaDerivationAdvancedAttrsTest>;
|
||||||
{ \
|
|
||||||
writeTest( \
|
TYPED_TEST_SUITE(DerivationAdvancedAttrsBothTest, BothFixtures);
|
||||||
NAME ".json", \
|
|
||||||
[&]() -> json { \
|
#define TEST_ATERM_JSON(STEM, NAME) \
|
||||||
/* Use DRV file instead of C++ literal as source of truth. */ \
|
TYPED_TEST(DerivationAdvancedAttrsBothTest, Derivation_##STEM##_from_json) \
|
||||||
auto aterm = readFile(goldenMaster(NAME ".drv")); \
|
{ \
|
||||||
return parseDerivation(*store, std::move(aterm), NAME).toJSON(*store); \
|
this->readTest(NAME ".json", [&](const auto & encoded_) { \
|
||||||
}, \
|
auto encoded = json::parse(encoded_); \
|
||||||
[](const auto & file) { return json::parse(readFile(file)); }, \
|
/* Use DRV file instead of C++ literal as source of truth. */ \
|
||||||
[](const auto & file, const auto & got) { return writeFile(file, got.dump(2) + "\n"); }); \
|
auto aterm = readFile(this->goldenMaster(NAME ".drv")); \
|
||||||
} \
|
auto expected = parseDerivation(*this->store, std::move(aterm), NAME, this->mockXpSettings); \
|
||||||
\
|
Derivation got = Derivation::fromJSON(*this->store, encoded, this->mockXpSettings); \
|
||||||
TEST_F(DerivationAdvancedAttrsTest, Derivation_##STEM##_from_aterm) \
|
EXPECT_EQ(got, expected); \
|
||||||
{ \
|
}); \
|
||||||
readTest(NAME ".drv", [&](auto encoded) { \
|
} \
|
||||||
/* Use JSON file instead of C++ literal as source of truth. */ \
|
\
|
||||||
auto json = json::parse(readFile(goldenMaster(NAME ".json"))); \
|
TYPED_TEST(DerivationAdvancedAttrsBothTest, Derivation_##STEM##_to_json) \
|
||||||
auto expected = Derivation::fromJSON(*store, json); \
|
{ \
|
||||||
auto got = parseDerivation(*store, std::move(encoded), NAME); \
|
this->writeTest( \
|
||||||
EXPECT_EQ(got.toJSON(*store), expected.toJSON(*store)); \
|
NAME ".json", \
|
||||||
EXPECT_EQ(got, expected); \
|
[&]() -> json { \
|
||||||
}); \
|
/* Use DRV file instead of C++ literal as source of truth. */ \
|
||||||
} \
|
auto aterm = readFile(this->goldenMaster(NAME ".drv")); \
|
||||||
\
|
return parseDerivation(*this->store, std::move(aterm), NAME, this->mockXpSettings) \
|
||||||
|
.toJSON(*this->store); \
|
||||||
|
}, \
|
||||||
|
[](const auto & file) { return json::parse(readFile(file)); }, \
|
||||||
|
[](const auto & file, const auto & got) { return writeFile(file, got.dump(2) + "\n"); }); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
TYPED_TEST(DerivationAdvancedAttrsBothTest, Derivation_##STEM##_from_aterm) \
|
||||||
|
{ \
|
||||||
|
this->readTest(NAME ".drv", [&](auto encoded) { \
|
||||||
|
/* Use JSON file instead of C++ literal as source of truth. */ \
|
||||||
|
auto json = json::parse(readFile(this->goldenMaster(NAME ".json"))); \
|
||||||
|
auto expected = Derivation::fromJSON(*this->store, json, this->mockXpSettings); \
|
||||||
|
auto got = parseDerivation(*this->store, std::move(encoded), NAME, this->mockXpSettings); \
|
||||||
|
EXPECT_EQ(got.toJSON(*this->store), expected.toJSON(*this->store)); \
|
||||||
|
EXPECT_EQ(got, expected); \
|
||||||
|
}); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
/* No corresponding write test, because we need to read the drv to write the json file */
|
/* No corresponding write test, because we need to read the drv to write the json file */
|
||||||
|
|
||||||
TEST_ATERM_JSON(advancedAttributes_defaults, "advanced-attributes-defaults");
|
|
||||||
TEST_ATERM_JSON(advancedAttributes, "advanced-attributes-defaults");
|
TEST_ATERM_JSON(advancedAttributes, "advanced-attributes-defaults");
|
||||||
TEST_ATERM_JSON(advancedAttributes_structuredAttrs_defaults, "advanced-attributes-structured-attrs");
|
TEST_ATERM_JSON(advancedAttributes_defaults, "advanced-attributes");
|
||||||
TEST_ATERM_JSON(advancedAttributes_structuredAttrs, "advanced-attributes-structured-attrs-defaults");
|
TEST_ATERM_JSON(advancedAttributes_structuredAttrs, "advanced-attributes-structured-attrs-defaults");
|
||||||
|
TEST_ATERM_JSON(advancedAttributes_structuredAttrs_defaults, "advanced-attributes-structured-attrs");
|
||||||
|
|
||||||
#undef TEST_ATERM_JSON
|
#undef TEST_ATERM_JSON
|
||||||
|
|
||||||
TEST_F(DerivationAdvancedAttrsTest, Derivation_advancedAttributes_defaults)
|
TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes_defaults)
|
||||||
{
|
{
|
||||||
readTest("advanced-attributes-defaults.drv", [&](auto encoded) {
|
this->readTest("advanced-attributes-defaults.drv", [&](auto encoded) {
|
||||||
auto got = parseDerivation(*store, std::move(encoded), "foo");
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
auto drvPath = writeDerivation(*store, got, NoRepair, true);
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
ParsedDerivation parsedDrv(got);
|
ParsedDerivation parsedDrv(got);
|
||||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
@ -101,25 +126,50 @@ TEST_F(DerivationAdvancedAttrsTest, Derivation_advancedAttributes_defaults)
|
||||||
EXPECT_EQ(checksForAllOutputs.disallowedReferences, StringSet{});
|
EXPECT_EQ(checksForAllOutputs.disallowedReferences, StringSet{});
|
||||||
EXPECT_EQ(checksForAllOutputs.disallowedRequisites, StringSet{});
|
EXPECT_EQ(checksForAllOutputs.disallowedRequisites, StringSet{});
|
||||||
}
|
}
|
||||||
EXPECT_EQ(options.getRequiredSystemFeatures(got), StringSet());
|
EXPECT_EQ(options.canBuildLocally(*this->store, got), false);
|
||||||
EXPECT_EQ(options.canBuildLocally(*store, got), false);
|
EXPECT_EQ(options.willBuildLocally(*this->store, got), false);
|
||||||
EXPECT_EQ(options.willBuildLocally(*store, got), false);
|
|
||||||
EXPECT_EQ(options.substitutesAllowed(), true);
|
EXPECT_EQ(options.substitutesAllowed(), true);
|
||||||
EXPECT_EQ(options.useUidRange(got), false);
|
EXPECT_EQ(options.useUidRange(got), false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(DerivationAdvancedAttrsTest, Derivation_advancedAttributes)
|
TEST_F(DerivationAdvancedAttrsTest, advancedAttributes_defaults)
|
||||||
{
|
{
|
||||||
readTest("advanced-attributes.drv", [&](auto encoded) {
|
this->readTest("advanced-attributes-defaults.drv", [&](auto encoded) {
|
||||||
auto got = parseDerivation(*store, std::move(encoded), "foo");
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
auto drvPath = writeDerivation(*store, got, NoRepair, true);
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
ParsedDerivation parsedDrv(got);
|
ParsedDerivation parsedDrv(got);
|
||||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
|
||||||
StringSet systemFeatures{"rainbow", "uid-range"};
|
EXPECT_EQ(options.getRequiredSystemFeatures(got), StringSet{});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(CaDerivationAdvancedAttrsTest, advancedAttributes_defaults)
|
||||||
|
{
|
||||||
|
this->readTest("advanced-attributes-defaults.drv", [&](auto encoded) {
|
||||||
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
|
ParsedDerivation parsedDrv(got);
|
||||||
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
|
||||||
|
EXPECT_EQ(options.getRequiredSystemFeatures(got), StringSet{"ca-derivations"});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes)
|
||||||
|
{
|
||||||
|
this->readTest("advanced-attributes.drv", [&](auto encoded) {
|
||||||
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
|
ParsedDerivation parsedDrv(got);
|
||||||
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
|
||||||
EXPECT_TRUE(!parsedDrv.hasStructuredAttrs());
|
EXPECT_TRUE(!parsedDrv.hasStructuredAttrs());
|
||||||
|
|
||||||
|
@ -128,6 +178,23 @@ TEST_F(DerivationAdvancedAttrsTest, Derivation_advancedAttributes)
|
||||||
EXPECT_EQ(options.impureHostDeps, StringSet{"/usr/bin/ditto"});
|
EXPECT_EQ(options.impureHostDeps, StringSet{"/usr/bin/ditto"});
|
||||||
EXPECT_EQ(options.impureEnvVars, StringSet{"UNICORN"});
|
EXPECT_EQ(options.impureEnvVars, StringSet{"UNICORN"});
|
||||||
EXPECT_EQ(options.allowLocalNetworking, true);
|
EXPECT_EQ(options.allowLocalNetworking, true);
|
||||||
|
EXPECT_EQ(options.canBuildLocally(*this->store, got), false);
|
||||||
|
EXPECT_EQ(options.willBuildLocally(*this->store, got), false);
|
||||||
|
EXPECT_EQ(options.substitutesAllowed(), false);
|
||||||
|
EXPECT_EQ(options.useUidRange(got), true);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(DerivationAdvancedAttrsTest, advancedAttributes)
|
||||||
|
{
|
||||||
|
this->readTest("advanced-attributes.drv", [&](auto encoded) {
|
||||||
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
|
ParsedDerivation parsedDrv(got);
|
||||||
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto * checksForAllOutputs_ = std::get_if<0>(&options.outputChecks);
|
auto * checksForAllOutputs_ = std::get_if<0>(&options.outputChecks);
|
||||||
ASSERT_TRUE(checksForAllOutputs_ != nullptr);
|
ASSERT_TRUE(checksForAllOutputs_ != nullptr);
|
||||||
|
@ -142,20 +209,55 @@ TEST_F(DerivationAdvancedAttrsTest, Derivation_advancedAttributes)
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
checksForAllOutputs.disallowedRequisites, StringSet{"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"});
|
checksForAllOutputs.disallowedRequisites, StringSet{"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringSet systemFeatures{"rainbow", "uid-range"};
|
||||||
|
|
||||||
EXPECT_EQ(options.getRequiredSystemFeatures(got), systemFeatures);
|
EXPECT_EQ(options.getRequiredSystemFeatures(got), systemFeatures);
|
||||||
EXPECT_EQ(options.canBuildLocally(*store, got), false);
|
|
||||||
EXPECT_EQ(options.willBuildLocally(*store, got), false);
|
|
||||||
EXPECT_EQ(options.substitutesAllowed(), false);
|
|
||||||
EXPECT_EQ(options.useUidRange(got), true);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(DerivationAdvancedAttrsTest, Derivation_advancedAttributes_structuredAttrs_defaults)
|
TEST_F(CaDerivationAdvancedAttrsTest, advancedAttributes)
|
||||||
{
|
{
|
||||||
readTest("advanced-attributes-structured-attrs-defaults.drv", [&](auto encoded) {
|
this->readTest("advanced-attributes.drv", [&](auto encoded) {
|
||||||
auto got = parseDerivation(*store, std::move(encoded), "foo");
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
auto drvPath = writeDerivation(*store, got, NoRepair, true);
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
|
ParsedDerivation parsedDrv(got);
|
||||||
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto * checksForAllOutputs_ = std::get_if<0>(&options.outputChecks);
|
||||||
|
ASSERT_TRUE(checksForAllOutputs_ != nullptr);
|
||||||
|
auto & checksForAllOutputs = *checksForAllOutputs_;
|
||||||
|
|
||||||
|
EXPECT_EQ(
|
||||||
|
checksForAllOutputs.allowedReferences,
|
||||||
|
StringSet{"/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8"});
|
||||||
|
EXPECT_EQ(
|
||||||
|
checksForAllOutputs.allowedRequisites,
|
||||||
|
StringSet{"/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8"});
|
||||||
|
EXPECT_EQ(
|
||||||
|
checksForAllOutputs.disallowedReferences,
|
||||||
|
StringSet{"/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99"});
|
||||||
|
EXPECT_EQ(
|
||||||
|
checksForAllOutputs.disallowedRequisites,
|
||||||
|
StringSet{"/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99"});
|
||||||
|
}
|
||||||
|
|
||||||
|
StringSet systemFeatures{"rainbow", "uid-range"};
|
||||||
|
systemFeatures.insert("ca-derivations");
|
||||||
|
|
||||||
|
EXPECT_EQ(options.getRequiredSystemFeatures(got), systemFeatures);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes_structuredAttrs_defaults)
|
||||||
|
{
|
||||||
|
this->readTest("advanced-attributes-structured-attrs-defaults.drv", [&](auto encoded) {
|
||||||
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
ParsedDerivation parsedDrv(got);
|
ParsedDerivation parsedDrv(got);
|
||||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
@ -176,25 +278,50 @@ TEST_F(DerivationAdvancedAttrsTest, Derivation_advancedAttributes_structuredAttr
|
||||||
EXPECT_EQ(checksPerOutput.size(), 0u);
|
EXPECT_EQ(checksPerOutput.size(), 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_EQ(options.getRequiredSystemFeatures(got), StringSet());
|
EXPECT_EQ(options.canBuildLocally(*this->store, got), false);
|
||||||
EXPECT_EQ(options.canBuildLocally(*store, got), false);
|
EXPECT_EQ(options.willBuildLocally(*this->store, got), false);
|
||||||
EXPECT_EQ(options.willBuildLocally(*store, got), false);
|
|
||||||
EXPECT_EQ(options.substitutesAllowed(), true);
|
EXPECT_EQ(options.substitutesAllowed(), true);
|
||||||
EXPECT_EQ(options.useUidRange(got), false);
|
EXPECT_EQ(options.useUidRange(got), false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(DerivationAdvancedAttrsTest, Derivation_advancedAttributes_structuredAttrs)
|
TEST_F(DerivationAdvancedAttrsTest, advancedAttributes_structuredAttrs_defaults)
|
||||||
{
|
{
|
||||||
readTest("advanced-attributes-structured-attrs.drv", [&](auto encoded) {
|
this->readTest("advanced-attributes-structured-attrs-defaults.drv", [&](auto encoded) {
|
||||||
auto got = parseDerivation(*store, std::move(encoded), "foo");
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
auto drvPath = writeDerivation(*store, got, NoRepair, true);
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
ParsedDerivation parsedDrv(got);
|
ParsedDerivation parsedDrv(got);
|
||||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
|
||||||
StringSet systemFeatures{"rainbow", "uid-range"};
|
EXPECT_EQ(options.getRequiredSystemFeatures(got), StringSet{});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(CaDerivationAdvancedAttrsTest, advancedAttributes_structuredAttrs_defaults)
|
||||||
|
{
|
||||||
|
this->readTest("advanced-attributes-structured-attrs-defaults.drv", [&](auto encoded) {
|
||||||
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
|
ParsedDerivation parsedDrv(got);
|
||||||
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
|
||||||
|
EXPECT_EQ(options.getRequiredSystemFeatures(got), StringSet{"ca-derivations"});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes_structuredAttrs)
|
||||||
|
{
|
||||||
|
this->readTest("advanced-attributes-structured-attrs.drv", [&](auto encoded) {
|
||||||
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
|
ParsedDerivation parsedDrv(got);
|
||||||
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
|
||||||
EXPECT_TRUE(parsedDrv.hasStructuredAttrs());
|
EXPECT_TRUE(parsedDrv.hasStructuredAttrs());
|
||||||
|
|
||||||
|
@ -204,6 +331,32 @@ TEST_F(DerivationAdvancedAttrsTest, Derivation_advancedAttributes_structuredAttr
|
||||||
EXPECT_EQ(options.impureEnvVars, StringSet{"UNICORN"});
|
EXPECT_EQ(options.impureEnvVars, StringSet{"UNICORN"});
|
||||||
EXPECT_EQ(options.allowLocalNetworking, true);
|
EXPECT_EQ(options.allowLocalNetworking, true);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto output_ = get(std::get<1>(options.outputChecks), "dev");
|
||||||
|
ASSERT_TRUE(output_);
|
||||||
|
auto & output = *output_;
|
||||||
|
|
||||||
|
EXPECT_EQ(output.maxSize, 789);
|
||||||
|
EXPECT_EQ(output.maxClosureSize, 5909);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(options.canBuildLocally(*this->store, got), false);
|
||||||
|
EXPECT_EQ(options.willBuildLocally(*this->store, got), false);
|
||||||
|
EXPECT_EQ(options.substitutesAllowed(), false);
|
||||||
|
EXPECT_EQ(options.useUidRange(got), true);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(DerivationAdvancedAttrsTest, advancedAttributes_structuredAttrs)
|
||||||
|
{
|
||||||
|
this->readTest("advanced-attributes-structured-attrs.drv", [&](auto encoded) {
|
||||||
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
|
ParsedDerivation parsedDrv(got);
|
||||||
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto output_ = get(std::get<1>(options.outputChecks), "out");
|
auto output_ = get(std::get<1>(options.outputChecks), "out");
|
||||||
|
@ -222,22 +375,50 @@ TEST_F(DerivationAdvancedAttrsTest, Derivation_advancedAttributes_structuredAttr
|
||||||
EXPECT_EQ(output.disallowedReferences, StringSet{"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"});
|
EXPECT_EQ(output.disallowedReferences, StringSet{"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"});
|
||||||
EXPECT_EQ(output.disallowedRequisites, StringSet{"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"});
|
EXPECT_EQ(output.disallowedRequisites, StringSet{"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StringSet systemFeatures{"rainbow", "uid-range"};
|
||||||
|
|
||||||
|
EXPECT_EQ(options.getRequiredSystemFeatures(got), systemFeatures);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(CaDerivationAdvancedAttrsTest, advancedAttributes_structuredAttrs)
|
||||||
|
{
|
||||||
|
this->readTest("advanced-attributes-structured-attrs.drv", [&](auto encoded) {
|
||||||
|
auto got = parseDerivation(*this->store, std::move(encoded), "foo", this->mockXpSettings);
|
||||||
|
|
||||||
|
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||||
|
|
||||||
|
ParsedDerivation parsedDrv(got);
|
||||||
|
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||||
|
|
||||||
|
{
|
||||||
{
|
{
|
||||||
auto output_ = get(std::get<1>(options.outputChecks), "dev");
|
auto output_ = get(std::get<1>(options.outputChecks), "out");
|
||||||
ASSERT_TRUE(output_);
|
ASSERT_TRUE(output_);
|
||||||
auto & output = *output_;
|
auto & output = *output_;
|
||||||
|
|
||||||
EXPECT_EQ(output.maxSize, 789);
|
EXPECT_EQ(output.allowedReferences, StringSet{"/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8"});
|
||||||
EXPECT_EQ(output.maxClosureSize, 5909);
|
EXPECT_EQ(output.allowedRequisites, StringSet{"/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8"});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto output_ = get(std::get<1>(options.outputChecks), "bin");
|
||||||
|
ASSERT_TRUE(output_);
|
||||||
|
auto & output = *output_;
|
||||||
|
|
||||||
|
EXPECT_EQ(
|
||||||
|
output.disallowedReferences, StringSet{"/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99"});
|
||||||
|
EXPECT_EQ(
|
||||||
|
output.disallowedRequisites, StringSet{"/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringSet systemFeatures{"rainbow", "uid-range"};
|
||||||
|
systemFeatures.insert("ca-derivations");
|
||||||
|
|
||||||
EXPECT_EQ(options.getRequiredSystemFeatures(got), systemFeatures);
|
EXPECT_EQ(options.getRequiredSystemFeatures(got), systemFeatures);
|
||||||
EXPECT_EQ(options.canBuildLocally(*store, got), false);
|
|
||||||
EXPECT_EQ(options.willBuildLocally(*store, got), false);
|
|
||||||
EXPECT_EQ(options.substitutesAllowed(), false);
|
|
||||||
EXPECT_EQ(options.useUidRange(got), true);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1355,7 +1355,7 @@ Derivation Derivation::fromJSON(
|
||||||
for (auto & [outputName, output] : outputs) {
|
for (auto & [outputName, output] : outputs) {
|
||||||
res.outputs.insert_or_assign(
|
res.outputs.insert_or_assign(
|
||||||
outputName,
|
outputName,
|
||||||
DerivationOutput::fromJSON(store, res.name, outputName, output));
|
DerivationOutput::fromJSON(store, res.name, outputName, output, xpSettings));
|
||||||
}
|
}
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace({}, "while reading key 'outputs'");
|
e.addTrace({}, "while reading key 'outputs'");
|
||||||
|
|
6
tests/functional/ca/derivation-advanced-attributes.sh
Executable file
6
tests/functional/ca/derivation-advanced-attributes.sh
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
source derivation-advanced-attributes.sh
|
|
@ -8,10 +8,11 @@ suites += {
|
||||||
'name': 'ca',
|
'name': 'ca',
|
||||||
'deps': [],
|
'deps': [],
|
||||||
'tests': [
|
'tests': [
|
||||||
|
'build-cache.sh',
|
||||||
'build-with-garbage-path.sh',
|
'build-with-garbage-path.sh',
|
||||||
'build.sh',
|
'build.sh',
|
||||||
'build-cache.sh',
|
|
||||||
'concurrent-builds.sh',
|
'concurrent-builds.sh',
|
||||||
|
'derivation-advanced-attributes.sh',
|
||||||
'derivation-json.sh',
|
'derivation-json.sh',
|
||||||
'duplicate-realisation-in-closure.sh',
|
'duplicate-realisation-in-closure.sh',
|
||||||
'eval-store.sh',
|
'eval-store.sh',
|
||||||
|
|
|
@ -12,11 +12,19 @@ badExitCode=0
|
||||||
|
|
||||||
store="$TEST_ROOT/store"
|
store="$TEST_ROOT/store"
|
||||||
|
|
||||||
|
if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||||
|
drvDir=ia
|
||||||
|
flags=(--arg contentAddress false)
|
||||||
|
else
|
||||||
|
drvDir=ca
|
||||||
|
flags=(--arg contentAddress true --extra-experimental-features ca-derivations)
|
||||||
|
fi
|
||||||
|
|
||||||
for nixFile in derivation/*.nix; do
|
for nixFile in derivation/*.nix; do
|
||||||
drvPath=$(env -u NIX_STORE nix-instantiate --store "$store" --pure-eval --expr "$(< "$nixFile")")
|
drvPath=$(env -u NIX_STORE nix-instantiate --store "$store" --pure-eval "${flags[@]}" --expr "$(< "$nixFile")")
|
||||||
testName=$(basename "$nixFile" .nix)
|
testName=$(basename "$nixFile" .nix)
|
||||||
got="${store}${drvPath}"
|
got="${store}${drvPath}"
|
||||||
expected="derivation/$testName.drv"
|
expected="derivation/${drvDir}/${testName}.drv"
|
||||||
diffAndAcceptInner "$testName" "$got" "$expected"
|
diffAndAcceptInner "$testName" "$got" "$expected"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,24 @@
|
||||||
derivation {
|
{ contentAddress }:
|
||||||
name = "advanced-attributes-defaults";
|
|
||||||
|
let
|
||||||
|
caArgs =
|
||||||
|
if contentAddress then
|
||||||
|
{
|
||||||
|
__contentAddressed = true;
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ };
|
||||||
|
|
||||||
|
derivation' = args: derivation (caArgs // args);
|
||||||
|
|
||||||
system = "my-system";
|
system = "my-system";
|
||||||
|
|
||||||
|
in
|
||||||
|
derivation' {
|
||||||
|
inherit system;
|
||||||
|
name = "advanced-attributes-defaults";
|
||||||
builder = "/bin/bash";
|
builder = "/bin/bash";
|
||||||
args = [
|
args = [
|
||||||
"-c"
|
"-c"
|
||||||
|
|
|
@ -1,6 +1,24 @@
|
||||||
derivation {
|
{ contentAddress }:
|
||||||
name = "advanced-attributes-structured-attrs-defaults";
|
|
||||||
|
let
|
||||||
|
caArgs =
|
||||||
|
if contentAddress then
|
||||||
|
{
|
||||||
|
__contentAddressed = true;
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ };
|
||||||
|
|
||||||
|
derivation' = args: derivation (caArgs // args);
|
||||||
|
|
||||||
system = "my-system";
|
system = "my-system";
|
||||||
|
|
||||||
|
in
|
||||||
|
derivation' {
|
||||||
|
inherit system;
|
||||||
|
name = "advanced-attributes-structured-attrs-defaults";
|
||||||
builder = "/bin/bash";
|
builder = "/bin/bash";
|
||||||
args = [
|
args = [
|
||||||
"-c"
|
"-c"
|
||||||
|
|
|
@ -1,6 +1,21 @@
|
||||||
|
{ contentAddress }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
caArgs =
|
||||||
|
if contentAddress then
|
||||||
|
{
|
||||||
|
__contentAddressed = true;
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ };
|
||||||
|
|
||||||
|
derivation' = args: derivation (caArgs // args);
|
||||||
|
|
||||||
system = "my-system";
|
system = "my-system";
|
||||||
foo = derivation {
|
|
||||||
|
foo = derivation' {
|
||||||
inherit system;
|
inherit system;
|
||||||
name = "foo";
|
name = "foo";
|
||||||
builder = "/bin/bash";
|
builder = "/bin/bash";
|
||||||
|
@ -9,7 +24,8 @@ let
|
||||||
"echo foo > $out"
|
"echo foo > $out"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
bar = derivation {
|
|
||||||
|
bar = derivation' {
|
||||||
inherit system;
|
inherit system;
|
||||||
name = "bar";
|
name = "bar";
|
||||||
builder = "/bin/bash";
|
builder = "/bin/bash";
|
||||||
|
@ -18,8 +34,9 @@ let
|
||||||
"echo bar > $out"
|
"echo bar > $out"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
derivation {
|
derivation' {
|
||||||
inherit system;
|
inherit system;
|
||||||
name = "advanced-attributes-structured-attrs";
|
name = "advanced-attributes-structured-attrs";
|
||||||
builder = "/bin/bash";
|
builder = "/bin/bash";
|
||||||
|
|
|
@ -1,6 +1,21 @@
|
||||||
|
{ contentAddress }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
caArgs =
|
||||||
|
if contentAddress then
|
||||||
|
{
|
||||||
|
__contentAddressed = true;
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ };
|
||||||
|
|
||||||
|
derivation' = args: derivation (caArgs // args);
|
||||||
|
|
||||||
system = "my-system";
|
system = "my-system";
|
||||||
foo = derivation {
|
|
||||||
|
foo = derivation' {
|
||||||
inherit system;
|
inherit system;
|
||||||
name = "foo";
|
name = "foo";
|
||||||
builder = "/bin/bash";
|
builder = "/bin/bash";
|
||||||
|
@ -9,7 +24,8 @@ let
|
||||||
"echo foo > $out"
|
"echo foo > $out"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
bar = derivation {
|
|
||||||
|
bar = derivation' {
|
||||||
inherit system;
|
inherit system;
|
||||||
name = "bar";
|
name = "bar";
|
||||||
builder = "/bin/bash";
|
builder = "/bin/bash";
|
||||||
|
@ -18,8 +34,9 @@ let
|
||||||
"echo bar > $out"
|
"echo bar > $out"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
derivation {
|
derivation' {
|
||||||
inherit system;
|
inherit system;
|
||||||
name = "advanced-attributes";
|
name = "advanced-attributes";
|
||||||
builder = "/bin/bash";
|
builder = "/bin/bash";
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Derive([("out","","r:sha256","")],[],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("builder","/bin/bash"),("name","advanced-attributes-defaults"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9"),("outputHashAlgo","sha256"),("outputHashMode","recursive"),("system","my-system")])
|
|
@ -0,0 +1 @@
|
||||||
|
Derive([("dev","","r:sha256",""),("out","","r:sha256","")],[],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"builder\":\"/bin/bash\",\"name\":\"advanced-attributes-structured-attrs-defaults\",\"outputHashAlgo\":\"sha256\",\"outputHashMode\":\"recursive\",\"outputs\":[\"out\",\"dev\"],\"system\":\"my-system\"}"),("dev","/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9")])
|
|
@ -0,0 +1 @@
|
||||||
|
Derive([("bin","","r:sha256",""),("dev","","r:sha256",""),("out","","r:sha256","")],[("/nix/store/spfzlnkwb1v8s62yvh8vj1apd1kwjr5f-foo.drv",["out"]),("/nix/store/x1vpzav565aqr7ccmkn0wv0svkm1qrbl-bar.drv",["out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99\"],\"disallowedRequisites\":[\"/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8\"],\"allowedRequisites\":[\"/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8\"]}},\"outputHashAlgo\":\"sha256\",\"outputHashMode\":\"recursive\",\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}"),("bin","/04f3da1kmbr67m3gzxikmsl4vjz5zf777sv6m14ahv22r65aac9m"),("dev","/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9")])
|
1
tests/functional/derivation/ca/advanced-attributes.drv
Normal file
1
tests/functional/derivation/ca/advanced-attributes.drv
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Derive([("out","","r:sha256","")],[("/nix/store/spfzlnkwb1v8s62yvh8vj1apd1kwjr5f-foo.drv",["out"]),("/nix/store/x1vpzav565aqr7ccmkn0wv0svkm1qrbl-bar.drv",["out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__darwinAllowLocalNetworking","1"),("__impureHostDeps","/usr/bin/ditto"),("__noChroot","1"),("__sandboxProfile","sandcastle"),("allowSubstitutes",""),("allowedReferences","/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8"),("allowedRequisites","/08cr1k2yfw44g21w1h850285vqhsciy7y3siqjdzz1m9yvwlqfm8"),("builder","/bin/bash"),("disallowedReferences","/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99"),("disallowedRequisites","/05pdic30acaypbz73ivw4wlsi9whq08jxsimml2h0inwqya2hn99"),("impureEnvVars","UNICORN"),("name","advanced-attributes"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9"),("outputHashAlgo","sha256"),("outputHashMode","recursive"),("preferLocalBuild","1"),("requiredSystemFeatures","rainbow uid-range"),("system","my-system")])
|
Loading…
Add table
Add a link
Reference in a new issue