mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 17:16:15 +02:00
parent
d385c13202
commit
95cfd50d25
3 changed files with 13 additions and 11 deletions
|
@ -21,7 +21,8 @@ bool OutputsSpec::contains(const std::string & outputName) const
|
||||||
|
|
||||||
std::optional<OutputsSpec> OutputsSpec::parseOpt(std::string_view s)
|
std::optional<OutputsSpec> OutputsSpec::parseOpt(std::string_view s)
|
||||||
{
|
{
|
||||||
static std::regex regex(R"((\*)|([a-z]+(,[a-z]+)*))");
|
// See checkName() for valid output name characters.
|
||||||
|
static std::regex regex(R"((\*)|([a-zA-Z\+\-\._\?=]+(,[a-zA-Z\+\-\._\?=]+)*))");
|
||||||
|
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
std::string s2 { s }; // until some improves std::regex
|
std::string s2 { s }; // until some improves std::regex
|
||||||
|
@ -42,7 +43,7 @@ OutputsSpec OutputsSpec::parse(std::string_view s)
|
||||||
{
|
{
|
||||||
std::optional spec = parseOpt(s);
|
std::optional spec = parseOpt(s);
|
||||||
if (!spec)
|
if (!spec)
|
||||||
throw Error("Invalid outputs specifier: '%s'", s);
|
throw Error("invalid outputs specifier '%s'", s);
|
||||||
return *spec;
|
return *spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ std::pair<std::string_view, ExtendedOutputsSpec> ExtendedOutputsSpec::parse(std:
|
||||||
{
|
{
|
||||||
std::optional spec = parseOpt(s);
|
std::optional spec = parseOpt(s);
|
||||||
if (!spec)
|
if (!spec)
|
||||||
throw Error("Invalid extended outputs specifier: '%s'", s);
|
throw Error("invalid extended outputs specifier '%s'", s);
|
||||||
return *spec;
|
return *spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,20 +42,21 @@ nix build -f multiple-outputs.nix --json 'a^*' --no-link | jq --exit-status '
|
||||||
nix build -f multiple-outputs.nix --json e --no-link | jq --exit-status '
|
nix build -f multiple-outputs.nix --json e --no-link | jq --exit-status '
|
||||||
(.[0] |
|
(.[0] |
|
||||||
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
||||||
(.outputs | keys == ["a", "b"]))
|
(.outputs | keys == ["a_a", "b"]))
|
||||||
'
|
'
|
||||||
|
|
||||||
# But not when it's overriden.
|
# But not when it's overriden.
|
||||||
nix build -f multiple-outputs.nix --json e^a --no-link | jq --exit-status '
|
nix build -f multiple-outputs.nix --json e^a_a --no-link
|
||||||
|
nix build -f multiple-outputs.nix --json e^a_a --no-link | jq --exit-status '
|
||||||
(.[0] |
|
(.[0] |
|
||||||
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
||||||
(.outputs | keys == ["a"]))
|
(.outputs | keys == ["a_a"]))
|
||||||
'
|
'
|
||||||
|
|
||||||
nix build -f multiple-outputs.nix --json 'e^*' --no-link | jq --exit-status '
|
nix build -f multiple-outputs.nix --json 'e^*' --no-link | jq --exit-status '
|
||||||
(.[0] |
|
(.[0] |
|
||||||
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
||||||
(.outputs | keys == ["a", "b", "c"]))
|
(.outputs | keys == ["a_a", "b", "c"]))
|
||||||
'
|
'
|
||||||
|
|
||||||
# Test building from raw store path to drv not expression.
|
# Test building from raw store path to drv not expression.
|
||||||
|
@ -104,7 +105,7 @@ nix build "$drv^*" --no-link --json | jq --exit-status '
|
||||||
nix build --impure -f multiple-outputs.nix --json e --no-link | jq --exit-status '
|
nix build --impure -f multiple-outputs.nix --json e --no-link | jq --exit-status '
|
||||||
(.[0] |
|
(.[0] |
|
||||||
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
||||||
(.outputs | keys == ["a", "b"]))
|
(.outputs | keys == ["a_a", "b"]))
|
||||||
'
|
'
|
||||||
|
|
||||||
testNormalization () {
|
testNormalization () {
|
||||||
|
|
|
@ -91,9 +91,9 @@ rec {
|
||||||
|
|
||||||
e = mkDerivation {
|
e = mkDerivation {
|
||||||
name = "multiple-outputs-e";
|
name = "multiple-outputs-e";
|
||||||
outputs = [ "a" "b" "c" ];
|
outputs = [ "a_a" "b" "c" ];
|
||||||
meta.outputsToInstall = [ "a" "b" ];
|
meta.outputsToInstall = [ "a_a" "b" ];
|
||||||
buildCommand = "mkdir $a $b $c";
|
buildCommand = "mkdir $a_a $b $c";
|
||||||
};
|
};
|
||||||
|
|
||||||
independent = mkDerivation {
|
independent = mkDerivation {
|
||||||
|
|
Loading…
Reference in a new issue