mirror of
https://github.com/NixOS/nix
synced 2025-07-07 18:31:49 +02:00
Format .nix files
This does not include any automation for the release branch, but is based on the configuration of https://github.com/NixOS/nix/pull/12349 pre-commit run -a nixfmt-rfc-style
This commit is contained in:
parent
42b22fe3de
commit
2f1b70a529
259 changed files with 7729 additions and 5286 deletions
|
@ -3,16 +3,23 @@ let
|
|||
name = "fail";
|
||||
builder = "/bin/false";
|
||||
system = "x86_64-linux";
|
||||
outputs = [ "out" "foo" ];
|
||||
outputs = [
|
||||
"out"
|
||||
"foo"
|
||||
];
|
||||
};
|
||||
|
||||
drv1 = derivation {
|
||||
name = "fail-2";
|
||||
builder = "/bin/false";
|
||||
system = "x86_64-linux";
|
||||
outputs = [ "out" "foo" ];
|
||||
outputs = [
|
||||
"out"
|
||||
"foo"
|
||||
];
|
||||
};
|
||||
|
||||
combo-path = "${drv0.drvPath}${drv1.drvPath}";
|
||||
|
||||
in builtins.addDrvOutputDependencies combo-path
|
||||
in
|
||||
builtins.addDrvOutputDependencies combo-path
|
||||
|
|
|
@ -3,7 +3,11 @@ let
|
|||
name = "fail";
|
||||
builder = "/bin/false";
|
||||
system = "x86_64-linux";
|
||||
outputs = [ "out" "foo" ];
|
||||
outputs = [
|
||||
"out"
|
||||
"foo"
|
||||
];
|
||||
};
|
||||
|
||||
in builtins.addDrvOutputDependencies drv.outPath
|
||||
in
|
||||
builtins.addDrvOutputDependencies drv.outPath
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
let
|
||||
countDown = n:
|
||||
if n == 0
|
||||
then throw "kaboom"
|
||||
countDown =
|
||||
n:
|
||||
if n == 0 then
|
||||
throw "kaboom"
|
||||
else
|
||||
builtins.addErrorContext
|
||||
"while counting down; n = ${toString n}"
|
||||
("x" + countDown (n - 1));
|
||||
in countDown 10
|
||||
builtins.addErrorContext "while counting down; n = ${toString n}" ("x" + countDown (n - 1));
|
||||
in
|
||||
countDown 10
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
assert { a = true; } == { a = true; b = true; };
|
||||
assert
|
||||
{
|
||||
a = true;
|
||||
} == {
|
||||
a = true;
|
||||
b = true;
|
||||
};
|
||||
throw "unreachable"
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
assert { a = true; b = true; } == { a = true; };
|
||||
assert
|
||||
{
|
||||
a = true;
|
||||
b = true;
|
||||
} == {
|
||||
a = true;
|
||||
};
|
||||
throw "unreachable"
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
assert
|
||||
{ foo = { type = "derivation"; outPath = "/nix/store/0"; }; }
|
||||
==
|
||||
{ foo = { type = "derivation"; outPath = "/nix/store/1"; devious = true; }; };
|
||||
throw "unreachable"
|
||||
{
|
||||
foo = {
|
||||
type = "derivation";
|
||||
outPath = "/nix/store/0";
|
||||
};
|
||||
} == {
|
||||
foo = {
|
||||
type = "derivation";
|
||||
outPath = "/nix/store/1";
|
||||
devious = true;
|
||||
};
|
||||
};
|
||||
throw "unreachable"
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
assert
|
||||
{ foo = { type = "derivation"; outPath = "/nix/store/0"; ignored = abort "not ignored"; }; }
|
||||
==
|
||||
{ foo = { type = "derivation"; outPath = "/nix/store/1"; ignored = abort "not ignored"; }; };
|
||||
throw "unreachable"
|
||||
{
|
||||
foo = {
|
||||
type = "derivation";
|
||||
outPath = "/nix/store/0";
|
||||
ignored = abort "not ignored";
|
||||
};
|
||||
} == {
|
||||
foo = {
|
||||
type = "derivation";
|
||||
outPath = "/nix/store/1";
|
||||
ignored = abort "not ignored";
|
||||
};
|
||||
};
|
||||
throw "unreachable"
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
# Note: functions in nested structures, e.g. attributes, may be optimized away by pointer identity optimization.
|
||||
# This only compares a direct comparison and makes no claims about functions in nested structures.
|
||||
assert
|
||||
(x: x)
|
||||
==
|
||||
(x: x);
|
||||
abort "unreachable"
|
||||
assert (x: x) == (x: x);
|
||||
abort "unreachable"
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
assert [ 1 0 ] == [ 10 ];
|
||||
throw "unreachable"
|
||||
assert
|
||||
[
|
||||
1
|
||||
0
|
||||
] == [ 10 ];
|
||||
throw "unreachable"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
assert ./foo == ./bar;
|
||||
throw "unreachable"
|
||||
throw "unreachable"
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
assert
|
||||
{ a.b = [ { c.d = true; } ]; }
|
||||
==
|
||||
{ a.b = [ { c.d = false; } ]; };
|
||||
assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
|
||||
|
||||
abort "unreachable"
|
||||
abort "unreachable"
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
let {
|
||||
x = arg: assert arg == "y"; 123;
|
||||
x =
|
||||
arg:
|
||||
assert arg == "y";
|
||||
123;
|
||||
|
||||
body = x "x";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
let
|
||||
attrs = {
|
||||
puppy.doggy = {};
|
||||
puppy.doggy = { };
|
||||
};
|
||||
key = 1;
|
||||
in
|
||||
attrs.puppy.${key}
|
||||
attrs.puppy.${key}
|
||||
|
|
|
@ -1 +1,8 @@
|
|||
{ a.b = 1; a = rec { c = d + 2; d = 3; }; }.c
|
||||
{
|
||||
a.b = 1;
|
||||
a = rec {
|
||||
c = d + 2;
|
||||
d = 3;
|
||||
};
|
||||
}
|
||||
.c
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
let
|
||||
# Basically a "billion laughs" attack, but toned down to simulated `pkgs`.
|
||||
ha = x: y: { a = x y; b = x y; c = x y; d = x y; e = x y; f = x y; g = x y; h = x y; j = x y; };
|
||||
ha = x: y: {
|
||||
a = x y;
|
||||
b = x y;
|
||||
c = x y;
|
||||
d = x y;
|
||||
e = x y;
|
||||
f = x y;
|
||||
g = x y;
|
||||
h = x y;
|
||||
j = x y;
|
||||
};
|
||||
has = ha (ha (ha (ha (x: x)))) "ha";
|
||||
# A large structure that has already been evaluated.
|
||||
pkgs = builtins.deepSeq has has;
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
set = { "${"" + "b"}" = 1; };
|
||||
set = { "${"b" + ""}" = 2; };
|
||||
set = {
|
||||
"${"" + "b"}" = 1;
|
||||
};
|
||||
set = {
|
||||
"${"b" + ""}" = 2;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
# Check that we only omit duplicate stack traces when there's a bunch of them.
|
||||
# Here, there's only a couple duplicate entries, so we output them all.
|
||||
let
|
||||
throwAfter = n:
|
||||
if n > 0
|
||||
then throwAfter (n - 1)
|
||||
else throw "Uh oh!";
|
||||
throwAfter = n: if n > 0 then throwAfter (n - 1) else throw "Uh oh!";
|
||||
in
|
||||
throwAfter 2
|
||||
throwAfter 2
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# foo
|
||||
# foo
|
||||
invalid
|
||||
# bar
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
builtins.fetchurl { url = "https://example.com/foo.tar.gz"; name = "~wobble~"; }
|
||||
builtins.fetchurl {
|
||||
url = "https://example.com/foo.tar.gz";
|
||||
name = "~wobble~";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Tests that the result of applying op is forced even if the value is never used
|
||||
builtins.foldl'
|
||||
(_: f: f null)
|
||||
null
|
||||
[ (_: throw "Not the final value, but is still forced!") (_: 23) ]
|
||||
builtins.foldl' (_: f: f null) null [
|
||||
(_: throw "Not the final value, but is still forced!")
|
||||
(_: 23)
|
||||
]
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
let
|
||||
paths = [ ./this-file-is-definitely-not-there-7392097 "/and/neither/is/this/37293620" ];
|
||||
paths = [
|
||||
./this-file-is-definitely-not-there-7392097
|
||||
"/and/neither/is/this/37293620"
|
||||
];
|
||||
in
|
||||
toString (builtins.concatLists (map (hash: map (builtins.hashFile hash) paths) ["md5" "sha1" "sha256" "sha512"]))
|
||||
|
||||
toString (
|
||||
builtins.concatLists (
|
||||
map (hash: map (builtins.hashFile hash) paths) [
|
||||
"md5"
|
||||
"sha1"
|
||||
"sha256"
|
||||
"sha512"
|
||||
]
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1 +1 @@
|
|||
8++1
|
||||
8 ++ 1
|
||||
|
|
|
@ -1 +1,12 @@
|
|||
({x, y, z}: x + y + z) {x = "foo"; z = "bar";}
|
||||
(
|
||||
{
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
}:
|
||||
x + y + z
|
||||
)
|
||||
{
|
||||
x = "foo";
|
||||
z = "bar";
|
||||
}
|
||||
|
|
|
@ -19,18 +19,22 @@
|
|||
# - a few frames of A (skip the rest)
|
||||
# - a few frames of B (skip the rest, _and_ skip the remaining frames of A)
|
||||
let
|
||||
throwAfterB = recurse: n:
|
||||
if n > 0
|
||||
then throwAfterB recurse (n - 1)
|
||||
else if recurse
|
||||
then throwAfterA false 10
|
||||
else throw "Uh oh!";
|
||||
throwAfterB =
|
||||
recurse: n:
|
||||
if n > 0 then
|
||||
throwAfterB recurse (n - 1)
|
||||
else if recurse then
|
||||
throwAfterA false 10
|
||||
else
|
||||
throw "Uh oh!";
|
||||
|
||||
throwAfterA = recurse: n:
|
||||
if n > 0
|
||||
then throwAfterA recurse (n - 1)
|
||||
else if recurse
|
||||
then throwAfterB true 10
|
||||
else throw "Uh oh!";
|
||||
throwAfterA =
|
||||
recurse: n:
|
||||
if n > 0 then
|
||||
throwAfterA recurse (n - 1)
|
||||
else if recurse then
|
||||
throwAfterB true 10
|
||||
else
|
||||
throw "Uh oh!";
|
||||
in
|
||||
throwAfterA true 10
|
||||
throwAfterA true 10
|
||||
|
|
|
@ -8,4 +8,27 @@
|
|||
#
|
||||
# error: cannot coerce a list to a string: [ [ 1 2 3 4 5 6 7 8 ] [ 1 «4294967290 items elided» ] ]
|
||||
|
||||
"" + (let v = [ [ 1 2 3 4 5 6 7 8 ] [1 2 3 4]]; in builtins.deepSeq v v)
|
||||
""
|
||||
+ (
|
||||
let
|
||||
v = [
|
||||
[
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
]
|
||||
[
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
]
|
||||
];
|
||||
in
|
||||
builtins.deepSeq v v
|
||||
)
|
||||
|
|
|
@ -1 +1 @@
|
|||
! (throw "uh oh!")
|
||||
!(throw "uh oh!")
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
let a = {} // a; in a.foo
|
||||
let
|
||||
a = { } // a;
|
||||
in
|
||||
a.foo
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
let {
|
||||
attrs = {x = 123; y = 456;};
|
||||
attrs = {
|
||||
x = 123;
|
||||
y = 456;
|
||||
};
|
||||
|
||||
body = (removeAttrs attrs ["x"]).x;
|
||||
}
|
||||
body = (removeAttrs attrs [ "x" ]).x;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,13 @@ let {
|
|||
x = "a";
|
||||
y = "b";
|
||||
|
||||
f = {x ? y, y ? x}: x + y;
|
||||
f =
|
||||
{
|
||||
x ? y,
|
||||
y ? x,
|
||||
}:
|
||||
x + y;
|
||||
|
||||
body = f {};
|
||||
body = f { };
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
8.x
|
||||
8. x
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
({x, z}: x + z) {x = "foo"; y = "bla"; z = "bar";}
|
||||
({ x, z }: x + z) {
|
||||
x = "foo";
|
||||
y = "bla";
|
||||
z = "bar";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
let
|
||||
attr = {foo = "bar";};
|
||||
key = {};
|
||||
attr = {
|
||||
foo = "bar";
|
||||
};
|
||||
key = { };
|
||||
in
|
||||
attr.${key}
|
||||
attr.${key}
|
||||
|
|
|
@ -1,11 +1,34 @@
|
|||
with builtins;
|
||||
|
||||
[ (any (x: x == 1) [])
|
||||
(any (x: x == 1) [2 3 4])
|
||||
(any (x: x == 1) [1 2 3 4])
|
||||
(any (x: x == 1) [4 3 2 1])
|
||||
(all (x: x == 1) [])
|
||||
(all (x: x == 1) [1])
|
||||
(all (x: x == 1) [1 2 3])
|
||||
(all (x: x == 1) [1 1 1])
|
||||
[
|
||||
(any (x: x == 1) [ ])
|
||||
(any (x: x == 1) [
|
||||
2
|
||||
3
|
||||
4
|
||||
])
|
||||
(any (x: x == 1) [
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
])
|
||||
(any (x: x == 1) [
|
||||
4
|
||||
3
|
||||
2
|
||||
1
|
||||
])
|
||||
(all (x: x == 1) [ ])
|
||||
(all (x: x == 1) [ 1 ])
|
||||
(all (x: x == 1) [
|
||||
1
|
||||
2
|
||||
3
|
||||
])
|
||||
(all (x: x == 1) [
|
||||
1
|
||||
1
|
||||
1
|
||||
])
|
||||
]
|
||||
|
|
|
@ -2,58 +2,59 @@ with import ./lib.nix;
|
|||
|
||||
let {
|
||||
|
||||
/* Supposedly tail recursive version:
|
||||
/*
|
||||
Supposedly tail recursive version:
|
||||
|
||||
range_ = accum: first: last:
|
||||
if first == last then ([first] ++ accum)
|
||||
else range_ ([first] ++ accum) (builtins.add first 1) last;
|
||||
range_ = accum: first: last:
|
||||
if first == last then ([first] ++ accum)
|
||||
else range_ ([first] ++ accum) (builtins.add first 1) last;
|
||||
|
||||
range = range_ [];
|
||||
range = range_ [];
|
||||
*/
|
||||
|
||||
x = 12;
|
||||
|
||||
err = abort "urgh";
|
||||
|
||||
body = sum
|
||||
[ (sum (range 1 50))
|
||||
(123 + 456)
|
||||
(0 + -10 + -(-11) + -x)
|
||||
(10 - 7 - -2)
|
||||
(10 - (6 - -1))
|
||||
(10 - 1 + 2)
|
||||
(3 * 4 * 5)
|
||||
(56088 / 123 / 2)
|
||||
(3 + 4 * const 5 0 - 6 / id 2)
|
||||
body = sum [
|
||||
(sum (range 1 50))
|
||||
(123 + 456)
|
||||
(0 + -10 + -(-11) + -x)
|
||||
(10 - 7 - -2)
|
||||
(10 - (6 - -1))
|
||||
(10 - 1 + 2)
|
||||
(3 * 4 * 5)
|
||||
(56088 / 123 / 2)
|
||||
(3 + 4 * const 5 0 - 6 / id 2)
|
||||
|
||||
(builtins.bitAnd 12 10) # 0b1100 & 0b1010 = 8
|
||||
(builtins.bitOr 12 10) # 0b1100 | 0b1010 = 14
|
||||
(builtins.bitXor 12 10) # 0b1100 ^ 0b1010 = 6
|
||||
(builtins.bitAnd 12 10) # 0b1100 & 0b1010 = 8
|
||||
(builtins.bitOr 12 10) # 0b1100 | 0b1010 = 14
|
||||
(builtins.bitXor 12 10) # 0b1100 ^ 0b1010 = 6
|
||||
|
||||
(if 3 < 7 then 1 else err)
|
||||
(if 7 < 3 then err else 1)
|
||||
(if 3 < 3 then err else 1)
|
||||
(if 3 < 7 then 1 else err)
|
||||
(if 7 < 3 then err else 1)
|
||||
(if 3 < 3 then err else 1)
|
||||
|
||||
(if 3 <= 7 then 1 else err)
|
||||
(if 7 <= 3 then err else 1)
|
||||
(if 3 <= 3 then 1 else err)
|
||||
(if 3 <= 7 then 1 else err)
|
||||
(if 7 <= 3 then err else 1)
|
||||
(if 3 <= 3 then 1 else err)
|
||||
|
||||
(if 3 > 7 then err else 1)
|
||||
(if 7 > 3 then 1 else err)
|
||||
(if 3 > 3 then err else 1)
|
||||
(if 3 > 7 then err else 1)
|
||||
(if 7 > 3 then 1 else err)
|
||||
(if 3 > 3 then err else 1)
|
||||
|
||||
(if 3 >= 7 then err else 1)
|
||||
(if 7 >= 3 then 1 else err)
|
||||
(if 3 >= 3 then 1 else err)
|
||||
(if 3 >= 7 then err else 1)
|
||||
(if 7 >= 3 then 1 else err)
|
||||
(if 3 >= 3 then 1 else err)
|
||||
|
||||
(if 2 > 1 == 1 < 2 then 1 else err)
|
||||
(if 1 + 2 * 3 >= 7 then 1 else err)
|
||||
(if 1 + 2 * 3 < 7 then err else 1)
|
||||
(if 2 > 1 == 1 < 2 then 1 else err)
|
||||
(if 1 + 2 * 3 >= 7 then 1 else err)
|
||||
(if 1 + 2 * 3 < 7 then err else 1)
|
||||
|
||||
# Not integer, but so what.
|
||||
(if "aa" < "ab" then 1 else err)
|
||||
(if "aa" < "aa" then err else 1)
|
||||
(if "foo" < "foobar" then 1 else err)
|
||||
];
|
||||
# Not integer, but so what.
|
||||
(if "aa" < "ab" then 1 else err)
|
||||
(if "aa" < "aa" then err else 1)
|
||||
(if "foo" < "foobar" then 1 else err)
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -2,10 +2,21 @@ with import ./lib.nix;
|
|||
|
||||
let
|
||||
|
||||
attrs = {y = "y"; x = "x"; foo = "foo";} // rec {x = "newx"; bar = x;};
|
||||
attrs =
|
||||
{
|
||||
y = "y";
|
||||
x = "x";
|
||||
foo = "foo";
|
||||
}
|
||||
// rec {
|
||||
x = "newx";
|
||||
bar = x;
|
||||
};
|
||||
|
||||
names = builtins.attrNames attrs;
|
||||
|
||||
values = map (name: builtins.getAttr name attrs) names;
|
||||
|
||||
in assert values == builtins.attrValues attrs; concat values
|
||||
in
|
||||
assert values == builtins.attrValues attrs;
|
||||
concat values
|
||||
|
|
|
@ -1,5 +1,20 @@
|
|||
let {
|
||||
as = { x = 123; y = 456; } // { z = 789; } // { z = 987; };
|
||||
as =
|
||||
{
|
||||
x = 123;
|
||||
y = 456;
|
||||
}
|
||||
// {
|
||||
z = 789;
|
||||
}
|
||||
// {
|
||||
z = 987;
|
||||
};
|
||||
|
||||
body = if as ? a then as.a else assert as ? z; as.z;
|
||||
body =
|
||||
if as ? a then
|
||||
as.a
|
||||
else
|
||||
assert as ? z;
|
||||
as.z;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
let {
|
||||
as = { x = 123; y = 456; } // { z = 789; } // { z = 987; };
|
||||
as =
|
||||
{
|
||||
x = 123;
|
||||
y = 456;
|
||||
}
|
||||
// {
|
||||
z = 789;
|
||||
}
|
||||
// {
|
||||
z = 987;
|
||||
};
|
||||
|
||||
A = "a";
|
||||
Z = "z";
|
||||
|
||||
body = if builtins.hasAttr A as
|
||||
then builtins.getAttr A as
|
||||
else assert builtins.hasAttr Z as; builtins.getAttr Z as;
|
||||
body =
|
||||
if builtins.hasAttr A as then
|
||||
builtins.getAttr A as
|
||||
else
|
||||
assert builtins.hasAttr Z as;
|
||||
builtins.getAttr Z as;
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
let
|
||||
|
||||
config =
|
||||
{
|
||||
services.sshd.enable = true;
|
||||
services.sshd.port = 22;
|
||||
services.httpd.port = 80;
|
||||
hostName = "itchy";
|
||||
a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z = "x";
|
||||
foo = {
|
||||
a = "a";
|
||||
b.c = "c";
|
||||
};
|
||||
config = {
|
||||
services.sshd.enable = true;
|
||||
services.sshd.port = 22;
|
||||
services.httpd.port = 80;
|
||||
hostName = "itchy";
|
||||
a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z = "x";
|
||||
foo = {
|
||||
a = "a";
|
||||
b.c = "c";
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
if config.services.sshd.enable
|
||||
then "foo ${toString config.services.sshd.port} ${toString config.services.httpd.port} ${config.hostName}"
|
||||
+ "${config.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z}"
|
||||
+ "${config.foo.a}"
|
||||
+ "${config.foo.b.c}"
|
||||
else "bar"
|
||||
if config.services.sshd.enable then
|
||||
"foo ${toString config.services.sshd.port} ${toString config.services.httpd.port} ${config.hostName}"
|
||||
+ "${config.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z}"
|
||||
+ "${config.foo.a}"
|
||||
+ "${config.foo.b.c}"
|
||||
else
|
||||
"bar"
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
let
|
||||
|
||||
as = { x.y.z = 123; a.b.c = 456; };
|
||||
as = {
|
||||
x.y.z = 123;
|
||||
a.b.c = 456;
|
||||
};
|
||||
|
||||
bs = null;
|
||||
|
||||
in [ (as ? x) (as ? y) (as ? x.y.z) (as ? x.y.z.a) (as ? x.y.a) (as ? a.b.c) (bs ? x) (bs ? x.y.z) ]
|
||||
in
|
||||
[
|
||||
(as ? x)
|
||||
(as ? y)
|
||||
(as ? x.y.z)
|
||||
(as ? x.y.z.a)
|
||||
(as ? x.y.a)
|
||||
(as ? a.b.c)
|
||||
(bs ? x)
|
||||
(bs ? x.y.z)
|
||||
]
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
rec {
|
||||
"${"foo"}" = "bar";
|
||||
__overrides = { bar = "qux"; };
|
||||
__overrides = {
|
||||
bar = "qux";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,12 +4,17 @@ let
|
|||
|
||||
in
|
||||
|
||||
{ xyzzy2 ? xyzzy # mutually recursive args
|
||||
, xyzzy ? "blaat" # will be overridden by --argstr
|
||||
, fb ? foobar
|
||||
, lib # will be set by --arg
|
||||
{
|
||||
xyzzy2 ? xyzzy, # mutually recursive args
|
||||
xyzzy ? "blaat", # will be overridden by --argstr
|
||||
fb ? foobar,
|
||||
lib, # will be set by --arg
|
||||
}:
|
||||
|
||||
{
|
||||
result = lib.concat [xyzzy xyzzy2 fb];
|
||||
result = lib.concat [
|
||||
xyzzy
|
||||
xyzzy2
|
||||
fb
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
''a''\
|
||||
b''
|
||||
''
|
||||
a''\
|
||||
b''
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[
|
||||
(builtins.add 2 3)
|
||||
(builtins.add 2 2)
|
||||
(builtins.typeOf (builtins.add 2 2))
|
||||
("t" + "t")
|
||||
(builtins.typeOf (builtins.add 2.0 2))
|
||||
(builtins.add 2.0 2)
|
||||
(builtins.add 2 3)
|
||||
(builtins.add 2 2)
|
||||
(builtins.typeOf (builtins.add 2 2))
|
||||
("t" + "t")
|
||||
(builtins.typeOf (builtins.add 2.0 2))
|
||||
(builtins.add 2.0 2)
|
||||
]
|
||||
|
|
|
@ -8,5 +8,5 @@ let {
|
|||
y = if builtins ? fnord then builtins.fnord "foo" else "";
|
||||
|
||||
body = x + y;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1,10 @@
|
|||
({ __functor = self: x: self.foo && x; foo = false; } // { foo = true; }) true
|
||||
(
|
||||
{
|
||||
__functor = self: x: self.foo && x;
|
||||
foo = false;
|
||||
}
|
||||
// {
|
||||
foo = true;
|
||||
}
|
||||
)
|
||||
true
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
builtins.catAttrs "a" [ { a = 1; } { b = 0; } { a = 2; } ]
|
||||
builtins.catAttrs "a" [
|
||||
{ a = 1; }
|
||||
{ b = 0; }
|
||||
{ a = 2; }
|
||||
]
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
let
|
||||
|
||||
closure = builtins.genericClosure {
|
||||
startSet = [{key = 80;}];
|
||||
operator = {key, foo ? false}:
|
||||
if builtins.lessThan key 0
|
||||
then []
|
||||
else [{key = builtins.sub key 9;} {key = builtins.sub key 13; foo = true;}];
|
||||
startSet = [ { key = 80; } ];
|
||||
operator =
|
||||
{
|
||||
key,
|
||||
foo ? false,
|
||||
}:
|
||||
if builtins.lessThan key 0 then
|
||||
[ ]
|
||||
else
|
||||
[
|
||||
{ key = builtins.sub key 9; }
|
||||
{
|
||||
key = builtins.sub key 13;
|
||||
foo = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
sort = (import ./lib.nix).sortBy (a: b: builtins.lessThan a.key b.key);
|
||||
|
||||
in sort closure
|
||||
in
|
||||
sort closure
|
||||
|
|
|
@ -1,59 +1,120 @@
|
|||
# A simple comment
|
||||
"a"+ # And another
|
||||
## A double comment
|
||||
"b"+ ## And another
|
||||
# Nested # comments #
|
||||
"c"+ # and # some # other #
|
||||
# An empty line, following here:
|
||||
"a"
|
||||
# And another
|
||||
+
|
||||
## A double comment
|
||||
"b"
|
||||
# # And another
|
||||
+
|
||||
# Nested # comments #
|
||||
"c"
|
||||
# and # some # other #
|
||||
+
|
||||
# An empty line, following here:
|
||||
|
||||
"d"+ # and a comment not starting the line !
|
||||
"d"
|
||||
# and a comment not starting the line !
|
||||
+
|
||||
|
||||
"e"+
|
||||
/* multiline comments */
|
||||
"f" +
|
||||
/* multiline
|
||||
comments,
|
||||
on
|
||||
multiple
|
||||
lines
|
||||
*/
|
||||
"g" +
|
||||
# Small, tricky comments
|
||||
/**/ "h"+ /*/*/ "i"+ /***/ "j"+ /* /*/ "k"+ /*/* /*/ "l"+
|
||||
# Comments with an even number of ending '*' used to fail:
|
||||
"m"+
|
||||
/* */ /* **/ /* ***/ /* ****/ "n"+
|
||||
/* */ /** */ /*** */ /**** */ "o"+
|
||||
/** **/ /*** ***/ /**** ****/ "p"+
|
||||
/* * ** *** **** ***** */ "q"+
|
||||
# Random comments
|
||||
/* ***** ////// * / * / /* */ "r"+
|
||||
# Mixed comments
|
||||
/* # */
|
||||
"s"+
|
||||
# /* #
|
||||
"t"+
|
||||
# /* # */
|
||||
"u"+
|
||||
# /*********/
|
||||
"v"+
|
||||
## */*
|
||||
"w"+
|
||||
/*
|
||||
* Multiline, decorated comments
|
||||
* # This ain't a nest'd comm'nt
|
||||
*/
|
||||
"x"+
|
||||
''${/** with **/"y"
|
||||
"e"
|
||||
+
|
||||
# multiline comments
|
||||
"f"
|
||||
+
|
||||
/*
|
||||
multiline
|
||||
comments,
|
||||
on
|
||||
multiple
|
||||
lines
|
||||
*/
|
||||
"g"
|
||||
+
|
||||
# Small, tricky comments
|
||||
"h"
|
||||
# /
|
||||
+ "i"
|
||||
+ "j"
|
||||
# /
|
||||
+ "k"
|
||||
# /* /
|
||||
+ "l"
|
||||
+
|
||||
# Comments with an even number of ending '*' used to fail:
|
||||
"m"
|
||||
+
|
||||
# *
|
||||
# **
|
||||
# ***
|
||||
"n"
|
||||
+
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
**
|
||||
*/
|
||||
"o"
|
||||
+
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* **
|
||||
*/
|
||||
/**
|
||||
** ***
|
||||
*/
|
||||
"p"
|
||||
+
|
||||
# * ** *** **** *****
|
||||
"q"
|
||||
+
|
||||
# Random comments
|
||||
# ***** ////// * / * / /*
|
||||
"r"
|
||||
+
|
||||
# Mixed comments
|
||||
# #
|
||||
"s"
|
||||
+
|
||||
# /* #
|
||||
"t"
|
||||
+
|
||||
# /* # */
|
||||
"u"
|
||||
+
|
||||
# /*********/
|
||||
"v"
|
||||
+
|
||||
## */*
|
||||
"w"
|
||||
+
|
||||
/*
|
||||
Multiline, decorated comments
|
||||
# This ain't a nest'd comm'nt
|
||||
*/
|
||||
"x"
|
||||
+ ''${
|
||||
/**
|
||||
with *
|
||||
*/
|
||||
"y"
|
||||
# real
|
||||
/* comments
|
||||
inside ! # */
|
||||
/*
|
||||
comments
|
||||
inside ! #
|
||||
*/
|
||||
|
||||
# (and empty lines)
|
||||
|
||||
}''+ /* And a multiline comment,
|
||||
on the same line,
|
||||
after some spaces
|
||||
*/ # followed by a one-line comment
|
||||
"z"
|
||||
/* EOF */
|
||||
}''
|
||||
+
|
||||
/*
|
||||
And a multiline comment,
|
||||
on the same line,
|
||||
after some spaces
|
||||
*/
|
||||
# followed by a one-line comment
|
||||
"z"
|
||||
# EOF
|
||||
|
|
|
@ -1 +1,15 @@
|
|||
[1 2 3] ++ [4 5 6] ++ [7 8 9]
|
||||
[
|
||||
1
|
||||
2
|
||||
3
|
||||
]
|
||||
++ [
|
||||
4
|
||||
5
|
||||
6
|
||||
]
|
||||
++ [
|
||||
7
|
||||
8
|
||||
9
|
||||
]
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
[ (builtins.concatMap (x: if x / 2 * 2 == x then [] else [ x ]) (range 0 10))
|
||||
(builtins.concatMap (x: [x] ++ ["z"]) ["a" "b"])
|
||||
[
|
||||
(builtins.concatMap (x: if x / 2 * 2 == x then [ ] else [ x ]) (range 0 10))
|
||||
(builtins.concatMap (x: [ x ] ++ [ "z" ]) [
|
||||
"a"
|
||||
"b"
|
||||
])
|
||||
]
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
with builtins;
|
||||
|
||||
[ (concatStringsSep "" [])
|
||||
(concatStringsSep "" ["foo" "bar" "xyzzy"])
|
||||
(concatStringsSep ", " ["foo" "bar" "xyzzy"])
|
||||
(concatStringsSep ", " ["foo"])
|
||||
(concatStringsSep ", " [])
|
||||
[
|
||||
(concatStringsSep "" [ ])
|
||||
(concatStringsSep "" [
|
||||
"foo"
|
||||
"bar"
|
||||
"xyzzy"
|
||||
])
|
||||
(concatStringsSep ", " [
|
||||
"foo"
|
||||
"bar"
|
||||
"xyzzy"
|
||||
])
|
||||
(concatStringsSep ", " [ "foo" ])
|
||||
(concatStringsSep ", " [ ])
|
||||
]
|
||||
|
|
|
@ -3,7 +3,10 @@ let
|
|||
name = "fail";
|
||||
builder = "/bin/false";
|
||||
system = "x86_64-linux";
|
||||
outputs = [ "out" "foo" ];
|
||||
outputs = [
|
||||
"out"
|
||||
"foo"
|
||||
];
|
||||
};
|
||||
|
||||
path = "${./eval-okay-context-introspection.nix}";
|
||||
|
@ -13,7 +16,10 @@ let
|
|||
path = true;
|
||||
};
|
||||
"${builtins.unsafeDiscardStringContext drv.drvPath}" = {
|
||||
outputs = [ "foo" "out" ];
|
||||
outputs = [
|
||||
"foo"
|
||||
"out"
|
||||
];
|
||||
allOutputs = true;
|
||||
};
|
||||
};
|
||||
|
@ -21,25 +27,22 @@ let
|
|||
combo-path = "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
|
||||
legit-context = builtins.getContext combo-path;
|
||||
|
||||
reconstructed-path = builtins.appendContext
|
||||
(builtins.unsafeDiscardStringContext combo-path)
|
||||
desired-context;
|
||||
reconstructed-path = builtins.appendContext (builtins.unsafeDiscardStringContext combo-path) desired-context;
|
||||
|
||||
# Eta rule for strings with context.
|
||||
etaRule = str:
|
||||
str == builtins.appendContext
|
||||
(builtins.unsafeDiscardStringContext str)
|
||||
(builtins.getContext str);
|
||||
etaRule =
|
||||
str:
|
||||
str == builtins.appendContext (builtins.unsafeDiscardStringContext str) (builtins.getContext str);
|
||||
|
||||
# Only holds true if string context contains both a `DrvDeep` and
|
||||
# `Opaque` element.
|
||||
almostEtaRule = str:
|
||||
str == builtins.addDrvOutputDependencies
|
||||
(builtins.unsafeDiscardOutputDependency str);
|
||||
almostEtaRule =
|
||||
str: str == builtins.addDrvOutputDependencies (builtins.unsafeDiscardOutputDependency str);
|
||||
|
||||
addDrvOutputDependencies_idempotent = str:
|
||||
builtins.addDrvOutputDependencies str ==
|
||||
builtins.addDrvOutputDependencies (builtins.addDrvOutputDependencies str);
|
||||
addDrvOutputDependencies_idempotent =
|
||||
str:
|
||||
builtins.addDrvOutputDependencies str
|
||||
== builtins.addDrvOutputDependencies (builtins.addDrvOutputDependencies str);
|
||||
|
||||
rules = str: [
|
||||
(etaRule str)
|
||||
|
@ -47,12 +50,14 @@ let
|
|||
(addDrvOutputDependencies_idempotent str)
|
||||
];
|
||||
|
||||
in [
|
||||
in
|
||||
[
|
||||
(legit-context == desired-context)
|
||||
(reconstructed-path == combo-path)
|
||||
(etaRule "foo")
|
||||
(etaRule drv.foo.outPath)
|
||||
] ++ builtins.concatMap rules [
|
||||
]
|
||||
++ builtins.concatMap rules [
|
||||
drv.drvPath
|
||||
(builtins.addDrvOutputDependencies drv.drvPath)
|
||||
(builtins.unsafeDiscardOutputDependency drv.drvPath)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
let s = "foo ${builtins.substring 33 100 (baseNameOf "${./eval-okay-context.nix}")} bar";
|
||||
let
|
||||
s = "foo ${builtins.substring 33 100 (baseNameOf "${./eval-okay-context.nix}")} bar";
|
||||
in
|
||||
if s != "foo eval-okay-context.nix bar"
|
||||
then abort "context not discarded"
|
||||
else builtins.unsafeDiscardStringContext s
|
||||
|
||||
if s != "foo eval-okay-context.nix bar" then
|
||||
abort "context not discarded"
|
||||
else
|
||||
builtins.unsafeDiscardStringContext s
|
||||
|
|
|
@ -1,33 +1,131 @@
|
|||
let
|
||||
hashAlgos = [ "md5" "md5" "md5" "sha1" "sha1" "sha1" "sha256" "sha256" "sha256" "sha512" "sha512" "sha512" ];
|
||||
hashAlgos = [
|
||||
"md5"
|
||||
"md5"
|
||||
"md5"
|
||||
"sha1"
|
||||
"sha1"
|
||||
"sha1"
|
||||
"sha256"
|
||||
"sha256"
|
||||
"sha256"
|
||||
"sha512"
|
||||
"sha512"
|
||||
"sha512"
|
||||
];
|
||||
hashesBase16 = import ./eval-okay-hashstring.exp;
|
||||
map2 = f: { fsts, snds }: if fsts == [ ] then [ ] else [ (f (builtins.head fsts) (builtins.head snds)) ] ++ map2 f { fsts = builtins.tail fsts; snds = builtins.tail snds; };
|
||||
map2' = f: fsts: snds: map2 f { inherit fsts snds; };
|
||||
map2 =
|
||||
f:
|
||||
{ fsts, snds }:
|
||||
if fsts == [ ] then
|
||||
[ ]
|
||||
else
|
||||
[ (f (builtins.head fsts) (builtins.head snds)) ]
|
||||
++ map2 f {
|
||||
fsts = builtins.tail fsts;
|
||||
snds = builtins.tail snds;
|
||||
};
|
||||
map2' =
|
||||
f: fsts: snds:
|
||||
map2 f { inherit fsts snds; };
|
||||
getOutputHashes = hashes: {
|
||||
hashesBase16 = map2' (hashAlgo: hash: builtins.convertHash { inherit hash hashAlgo; toHashFormat = "base16";}) hashAlgos hashes;
|
||||
hashesNix32 = map2' (hashAlgo: hash: builtins.convertHash { inherit hash hashAlgo; toHashFormat = "nix32";}) hashAlgos hashes;
|
||||
hashesBase32 = map2' (hashAlgo: hash: builtins.convertHash { inherit hash hashAlgo; toHashFormat = "base32";}) hashAlgos hashes;
|
||||
hashesBase64 = map2' (hashAlgo: hash: builtins.convertHash { inherit hash hashAlgo; toHashFormat = "base64";}) hashAlgos hashes;
|
||||
hashesSRI = map2' (hashAlgo: hash: builtins.convertHash { inherit hash hashAlgo; toHashFormat = "sri" ;}) hashAlgos hashes;
|
||||
hashesBase16 = map2' (
|
||||
hashAlgo: hash:
|
||||
builtins.convertHash {
|
||||
inherit hash hashAlgo;
|
||||
toHashFormat = "base16";
|
||||
}
|
||||
) hashAlgos hashes;
|
||||
hashesNix32 = map2' (
|
||||
hashAlgo: hash:
|
||||
builtins.convertHash {
|
||||
inherit hash hashAlgo;
|
||||
toHashFormat = "nix32";
|
||||
}
|
||||
) hashAlgos hashes;
|
||||
hashesBase32 = map2' (
|
||||
hashAlgo: hash:
|
||||
builtins.convertHash {
|
||||
inherit hash hashAlgo;
|
||||
toHashFormat = "base32";
|
||||
}
|
||||
) hashAlgos hashes;
|
||||
hashesBase64 = map2' (
|
||||
hashAlgo: hash:
|
||||
builtins.convertHash {
|
||||
inherit hash hashAlgo;
|
||||
toHashFormat = "base64";
|
||||
}
|
||||
) hashAlgos hashes;
|
||||
hashesSRI = map2' (
|
||||
hashAlgo: hash:
|
||||
builtins.convertHash {
|
||||
inherit hash hashAlgo;
|
||||
toHashFormat = "sri";
|
||||
}
|
||||
) hashAlgos hashes;
|
||||
};
|
||||
getOutputHashesColon = hashes: {
|
||||
hashesBase16 = map2' (hashAlgo: hashBody: builtins.convertHash { hash = hashAlgo + ":" + hashBody; toHashFormat = "base16";}) hashAlgos hashes;
|
||||
hashesNix32 = map2' (hashAlgo: hashBody: builtins.convertHash { hash = hashAlgo + ":" + hashBody; toHashFormat = "nix32";}) hashAlgos hashes;
|
||||
hashesBase32 = map2' (hashAlgo: hashBody: builtins.convertHash { hash = hashAlgo + ":" + hashBody; toHashFormat = "base32";}) hashAlgos hashes;
|
||||
hashesBase64 = map2' (hashAlgo: hashBody: builtins.convertHash { hash = hashAlgo + ":" + hashBody; toHashFormat = "base64";}) hashAlgos hashes;
|
||||
hashesSRI = map2' (hashAlgo: hashBody: builtins.convertHash { hash = hashAlgo + ":" + hashBody; toHashFormat = "sri" ;}) hashAlgos hashes;
|
||||
hashesBase16 = map2' (
|
||||
hashAlgo: hashBody:
|
||||
builtins.convertHash {
|
||||
hash = hashAlgo + ":" + hashBody;
|
||||
toHashFormat = "base16";
|
||||
}
|
||||
) hashAlgos hashes;
|
||||
hashesNix32 = map2' (
|
||||
hashAlgo: hashBody:
|
||||
builtins.convertHash {
|
||||
hash = hashAlgo + ":" + hashBody;
|
||||
toHashFormat = "nix32";
|
||||
}
|
||||
) hashAlgos hashes;
|
||||
hashesBase32 = map2' (
|
||||
hashAlgo: hashBody:
|
||||
builtins.convertHash {
|
||||
hash = hashAlgo + ":" + hashBody;
|
||||
toHashFormat = "base32";
|
||||
}
|
||||
) hashAlgos hashes;
|
||||
hashesBase64 = map2' (
|
||||
hashAlgo: hashBody:
|
||||
builtins.convertHash {
|
||||
hash = hashAlgo + ":" + hashBody;
|
||||
toHashFormat = "base64";
|
||||
}
|
||||
) hashAlgos hashes;
|
||||
hashesSRI = map2' (
|
||||
hashAlgo: hashBody:
|
||||
builtins.convertHash {
|
||||
hash = hashAlgo + ":" + hashBody;
|
||||
toHashFormat = "sri";
|
||||
}
|
||||
) hashAlgos hashes;
|
||||
};
|
||||
outputHashes = getOutputHashes hashesBase16;
|
||||
in
|
||||
# map2'`
|
||||
assert map2' (s1: s2: s1 + s2) [ "a" "b" ] [ "c" "d" ] == [ "ac" "bd" ];
|
||||
assert
|
||||
map2' (s1: s2: s1 + s2) [ "a" "b" ] [ "c" "d" ] == [
|
||||
"ac"
|
||||
"bd"
|
||||
];
|
||||
# hashesBase16
|
||||
assert outputHashes.hashesBase16 == hashesBase16;
|
||||
# standard SRI hashes
|
||||
assert outputHashes.hashesSRI == (map2' (hashAlgo: hashBody: hashAlgo + "-" + hashBody) hashAlgos outputHashes.hashesBase64);
|
||||
assert
|
||||
outputHashes.hashesSRI
|
||||
== (map2' (hashAlgo: hashBody: hashAlgo + "-" + hashBody) hashAlgos outputHashes.hashesBase64);
|
||||
# without prefix
|
||||
assert builtins.all (x: getOutputHashes x == outputHashes) (builtins.attrValues outputHashes);
|
||||
# colon-separated.
|
||||
# Note that colon prefix must not be applied to the standard SRI. e.g. "sha256:sha256-..." is illegal.
|
||||
assert builtins.all (x: getOutputHashesColon x == outputHashes) (with outputHashes; [ hashesBase16 hashesBase32 hashesBase64 ]);
|
||||
assert builtins.all (x: getOutputHashesColon x == outputHashes) (
|
||||
with outputHashes;
|
||||
[
|
||||
hashesBase16
|
||||
hashesBase32
|
||||
hashesBase64
|
||||
]
|
||||
);
|
||||
outputHashes
|
||||
|
|
|
@ -1 +1,9 @@
|
|||
builtins.deepSeq (let as = { x = 123; y = as; }; in as) 456
|
||||
builtins.deepSeq (
|
||||
let
|
||||
as = {
|
||||
x = 123;
|
||||
y = as;
|
||||
};
|
||||
in
|
||||
as
|
||||
) 456
|
||||
|
|
|
@ -4,7 +4,10 @@ let
|
|||
name = "a";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
args = [
|
||||
"-c"
|
||||
"touch $out"
|
||||
];
|
||||
inherit b;
|
||||
};
|
||||
|
||||
|
@ -16,9 +19,13 @@ let
|
|||
name = "b-overridden";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
args = [
|
||||
"-c"
|
||||
"touch $out"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
pkgs = pkgs_ // (packageOverrides pkgs_);
|
||||
in pkgs.a.b.name
|
||||
in
|
||||
pkgs.a.b.name
|
||||
|
|
|
@ -5,7 +5,10 @@ let
|
|||
name = "a";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
args = [
|
||||
"-c"
|
||||
"touch $out"
|
||||
];
|
||||
inherit b;
|
||||
};
|
||||
|
||||
|
@ -13,17 +16,22 @@ let
|
|||
name = "b";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
args = [
|
||||
"-c"
|
||||
"touch $out"
|
||||
];
|
||||
inherit a;
|
||||
};
|
||||
|
||||
c = b;
|
||||
};
|
||||
|
||||
packageOverrides = pkgs: with pkgs; {
|
||||
b = derivation (b.drvAttrs // { name = "${b.name}-overridden"; });
|
||||
};
|
||||
packageOverrides =
|
||||
pkgs: with pkgs; {
|
||||
b = derivation (b.drvAttrs // { name = "${b.name}-overridden"; });
|
||||
};
|
||||
|
||||
pkgs = pkgs_ // (packageOverrides pkgs_);
|
||||
|
||||
in "${pkgs.a.b.name} ${pkgs.c.name} ${pkgs.b.a.name}"
|
||||
in
|
||||
"${pkgs.a.b.name} ${pkgs.c.name} ${pkgs.b.a.name}"
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
{ a."${"b"}" = true; a."${"c"}" = false; }.a.b
|
||||
{
|
||||
a."${"b"}" = true;
|
||||
a."${"c"}" = false;
|
||||
}
|
||||
.a.b
|
||||
|
|
|
@ -2,7 +2,8 @@ let
|
|||
aString = "a";
|
||||
|
||||
bString = "b";
|
||||
in {
|
||||
in
|
||||
{
|
||||
hasAttrs = { a.b = null; } ? ${aString}.b;
|
||||
|
||||
selectAttrs = { a.b = true; }.a.${bString};
|
||||
|
@ -11,7 +12,17 @@ in {
|
|||
|
||||
binds = { ${aString}."${bString}c" = true; }.a.bc;
|
||||
|
||||
recBinds = rec { ${bString} = a; a = true; }.b;
|
||||
recBinds =
|
||||
rec {
|
||||
${bString} = a;
|
||||
a = true;
|
||||
}
|
||||
.b;
|
||||
|
||||
multiAttrs = { ${aString} = true; ${bString} = false; }.a;
|
||||
multiAttrs =
|
||||
{
|
||||
${aString} = true;
|
||||
${bString} = false;
|
||||
}
|
||||
.a;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@ let
|
|||
aString = "a";
|
||||
|
||||
bString = "b";
|
||||
in {
|
||||
in
|
||||
{
|
||||
hasAttrs = { a.b = null; } ? "${aString}".b;
|
||||
|
||||
selectAttrs = { a.b = true; }.a."${bString}";
|
||||
|
@ -11,7 +12,17 @@ in {
|
|||
|
||||
binds = { "${aString}"."${bString}c" = true; }.a.bc;
|
||||
|
||||
recBinds = rec { "${bString}" = a; a = true; }.b;
|
||||
recBinds =
|
||||
rec {
|
||||
"${bString}" = a;
|
||||
a = true;
|
||||
}
|
||||
.b;
|
||||
|
||||
multiAttrs = { "${aString}" = true; "${bString}" = false; }.a;
|
||||
multiAttrs =
|
||||
{
|
||||
"${aString}" = true;
|
||||
"${bString}" = false;
|
||||
}
|
||||
.a;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
let xs = range 10 40; in
|
||||
|
||||
[ (builtins.elem 23 xs) (builtins.elem 42 xs) (builtins.elemAt xs 20) ]
|
||||
let
|
||||
xs = range 10 40;
|
||||
in
|
||||
|
||||
[
|
||||
(builtins.elem 23 xs)
|
||||
(builtins.elem 42 xs)
|
||||
(builtins.elemAt xs 20)
|
||||
]
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
({}: {x,y,}: "${x}${y}") {} {x = "a"; y = "b";}
|
||||
({ }: { x, y }: "${x}${y}") { } {
|
||||
x = "a";
|
||||
y = "b";
|
||||
}
|
||||
|
|
|
@ -1,10 +1,40 @@
|
|||
let
|
||||
|
||||
drvA1 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; };
|
||||
drvA2 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; };
|
||||
drvA3 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; } // { dummy = 1; };
|
||||
|
||||
drvC1 = derivation { name = "c"; builder = "/foo"; system = "i686-linux"; };
|
||||
drvC2 = derivation { name = "c"; builder = "/bar"; system = "i686-linux"; };
|
||||
drvA1 = derivation {
|
||||
name = "a";
|
||||
builder = "/foo";
|
||||
system = "i686-linux";
|
||||
};
|
||||
drvA2 = derivation {
|
||||
name = "a";
|
||||
builder = "/foo";
|
||||
system = "i686-linux";
|
||||
};
|
||||
drvA3 =
|
||||
derivation {
|
||||
name = "a";
|
||||
builder = "/foo";
|
||||
system = "i686-linux";
|
||||
}
|
||||
// {
|
||||
dummy = 1;
|
||||
};
|
||||
|
||||
in [ (drvA1 == drvA1) (drvA1 == drvA2) (drvA1 == drvA3) (drvC1 == drvC2) ]
|
||||
drvC1 = derivation {
|
||||
name = "c";
|
||||
builder = "/foo";
|
||||
system = "i686-linux";
|
||||
};
|
||||
drvC2 = derivation {
|
||||
name = "c";
|
||||
builder = "/bar";
|
||||
system = "i686-linux";
|
||||
};
|
||||
|
||||
in
|
||||
[
|
||||
(drvA1 == drvA1)
|
||||
(drvA1 == drvA2)
|
||||
(drvA1 == drvA3)
|
||||
(drvC1 == drvC2)
|
||||
]
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
["foobar" (rec {x = 1; y = x;})]
|
||||
==
|
||||
[("foo" + "bar") ({x = 1; y = 1;})]
|
||||
[
|
||||
"foobar"
|
||||
(rec {
|
||||
x = 1;
|
||||
y = x;
|
||||
})
|
||||
] == [
|
||||
("foo" + "bar")
|
||||
({
|
||||
x = 1;
|
||||
y = 1;
|
||||
})
|
||||
]
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
builtins.filter
|
||||
(x: x / 2 * 2 == x)
|
||||
(builtins.concatLists [ (range 0 10) (range 100 110) ])
|
||||
builtins.filter (x: x / 2 * 2 == x) (
|
||||
builtins.concatLists [
|
||||
(range 0 10)
|
||||
(range 100 110)
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
builtins.flakeRefToString {
|
||||
type = "github";
|
||||
type = "github";
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs";
|
||||
ref = "23.05";
|
||||
dir = "lib";
|
||||
repo = "nixpkgs";
|
||||
ref = "23.05";
|
||||
dir = "lib";
|
||||
}
|
||||
|
|
|
@ -2,7 +2,19 @@ with import ./lib.nix;
|
|||
|
||||
let {
|
||||
|
||||
l = ["1" "2" ["3" ["4"] ["5" "6"]] "7"];
|
||||
l = [
|
||||
"1"
|
||||
"2"
|
||||
[
|
||||
"3"
|
||||
[ "4" ]
|
||||
[
|
||||
"5"
|
||||
"6"
|
||||
]
|
||||
]
|
||||
"7"
|
||||
];
|
||||
|
||||
body = concat (flatten l);
|
||||
}
|
||||
|
|
|
@ -6,4 +6,11 @@ let
|
|||
n3 = builtins.floor 23;
|
||||
n4 = builtins.ceil 23;
|
||||
in
|
||||
builtins.concatStringsSep ";" (map toString [ n1 n2 n3 n4 ])
|
||||
builtins.concatStringsSep ";" (
|
||||
map toString [
|
||||
n1
|
||||
n2
|
||||
n3
|
||||
n4
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
# Tests that the rhs argument of op is not forced unconditionally
|
||||
let
|
||||
lst = builtins.foldl'
|
||||
(acc: x: acc ++ [ x ])
|
||||
[ ]
|
||||
[ 42 (throw "this shouldn't be evaluated") ];
|
||||
lst = builtins.foldl' (acc: x: acc ++ [ x ]) [ ] [ 42 (throw "this shouldn't be evaluated") ];
|
||||
in
|
||||
|
||||
builtins.head lst
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Checks that the nul value for the accumulator is not forced unconditionally.
|
||||
# Some languages provide a foldl' that is strict in this argument, but Nix does not.
|
||||
builtins.foldl'
|
||||
(_: x: x)
|
||||
(throw "This is never forced")
|
||||
[ "but the results of applying op are" 42 ]
|
||||
builtins.foldl' (_: x: x) (throw "This is never forced") [
|
||||
"but the results of applying op are"
|
||||
42
|
||||
]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# This string contains all supported escapes in a JSON string, per json.org
|
||||
# \b and \f are not supported by Nix
|
||||
builtins.fromJSON ''"quote \" reverse solidus \\ solidus \/ backspace \b formfeed \f newline \n carriage return \r horizontal tab \t 1 char unicode encoded backspace \u0008 1 char unicode encoded e with accent \u00e9 2 char unicode encoded s with caron \u0161 3 char unicode encoded rightwards arrow \u2192"''
|
||||
builtins.fromJSON
|
||||
''"quote \" reverse solidus \\ solidus \/ backspace \b formfeed \f newline \n carriage return \r horizontal tab \t 1 char unicode encoded backspace \u0008 1 char unicode encoded e with accent \u00e9 2 char unicode encoded s with caron \u0161 3 char unicode encoded rightwards arrow \u2192"''
|
||||
|
|
|
@ -1,41 +1,55 @@
|
|||
builtins.fromJSON
|
||||
''
|
||||
{
|
||||
"Video": {
|
||||
"Title": "The Penguin Chronicles",
|
||||
"Width": 1920,
|
||||
"Height": 1080,
|
||||
"EmbeddedData": [3.14159, 23493,null, true ,false, -10],
|
||||
"Thumb": {
|
||||
"Url": "http://www.example.com/video/5678931",
|
||||
"Width": 200,
|
||||
"Height": 250
|
||||
},
|
||||
"Animated" : false,
|
||||
"IDs": [116, 943, 234, 38793, true ,false,null, -100],
|
||||
"Escapes": "\"\\\/\t\n\r\t",
|
||||
"Subtitle" : false,
|
||||
"Latitude": 37.7668,
|
||||
"Longitude": -122.3959
|
||||
}
|
||||
}
|
||||
''
|
||||
==
|
||||
{ Video =
|
||||
{ Title = "The Penguin Chronicles";
|
||||
Width = 1920;
|
||||
Height = 1080;
|
||||
EmbeddedData = [ 3.14159 23493 null true false (0-10) ];
|
||||
Thumb =
|
||||
{ Url = "http://www.example.com/video/5678931";
|
||||
Width = 200;
|
||||
Height = 250;
|
||||
};
|
||||
Animated = false;
|
||||
IDs = [ 116 943 234 38793 true false null (0-100) ];
|
||||
Escapes = "\"\\\/\t\n\r\t"; # supported in JSON but not Nix: \b\f
|
||||
Subtitle = false;
|
||||
Latitude = 37.7668;
|
||||
Longitude = -122.3959;
|
||||
};
|
||||
builtins.fromJSON ''
|
||||
{
|
||||
"Video": {
|
||||
"Title": "The Penguin Chronicles",
|
||||
"Width": 1920,
|
||||
"Height": 1080,
|
||||
"EmbeddedData": [3.14159, 23493,null, true ,false, -10],
|
||||
"Thumb": {
|
||||
"Url": "http://www.example.com/video/5678931",
|
||||
"Width": 200,
|
||||
"Height": 250
|
||||
},
|
||||
"Animated" : false,
|
||||
"IDs": [116, 943, 234, 38793, true ,false,null, -100],
|
||||
"Escapes": "\"\\\/\t\n\r\t",
|
||||
"Subtitle" : false,
|
||||
"Latitude": 37.7668,
|
||||
"Longitude": -122.3959
|
||||
}
|
||||
}
|
||||
'' == {
|
||||
Video = {
|
||||
Title = "The Penguin Chronicles";
|
||||
Width = 1920;
|
||||
Height = 1080;
|
||||
EmbeddedData = [
|
||||
3.14159
|
||||
23493
|
||||
null
|
||||
true
|
||||
false
|
||||
(0 - 10)
|
||||
];
|
||||
Thumb = {
|
||||
Url = "http://www.example.com/video/5678931";
|
||||
Width = 200;
|
||||
Height = 250;
|
||||
};
|
||||
Animated = false;
|
||||
IDs = [
|
||||
116
|
||||
943
|
||||
234
|
||||
38793
|
||||
true
|
||||
false
|
||||
null
|
||||
(0 - 100)
|
||||
];
|
||||
Escapes = "\"\\\/\t\n\r\t"; # supported in JSON but not Nix: \b\f
|
||||
Subtitle = false;
|
||||
Latitude = 37.7668;
|
||||
Longitude = -122.3959;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,29 +1,74 @@
|
|||
let
|
||||
|
||||
stdenvFun = { }: { name = "stdenv"; };
|
||||
stdenv2Fun = { }: { name = "stdenv2"; };
|
||||
fetchurlFun = { stdenv }: assert stdenv.name == "stdenv"; { name = "fetchurl"; };
|
||||
atermFun = { stdenv, fetchurl }: { name = "aterm-${stdenv.name}"; };
|
||||
aterm2Fun = { stdenv, fetchurl }: { name = "aterm2-${stdenv.name}"; };
|
||||
nixFun = { stdenv, fetchurl, aterm }: { name = "nix-${stdenv.name}-${aterm.name}"; };
|
||||
|
||||
stdenvFun =
|
||||
{ }:
|
||||
{
|
||||
name = "stdenv";
|
||||
};
|
||||
stdenv2Fun =
|
||||
{ }:
|
||||
{
|
||||
name = "stdenv2";
|
||||
};
|
||||
fetchurlFun =
|
||||
{ stdenv }:
|
||||
assert stdenv.name == "stdenv";
|
||||
{
|
||||
name = "fetchurl";
|
||||
};
|
||||
atermFun =
|
||||
{ stdenv, fetchurl }:
|
||||
{
|
||||
name = "aterm-${stdenv.name}";
|
||||
};
|
||||
aterm2Fun =
|
||||
{ stdenv, fetchurl }:
|
||||
{
|
||||
name = "aterm2-${stdenv.name}";
|
||||
};
|
||||
nixFun =
|
||||
{
|
||||
stdenv,
|
||||
fetchurl,
|
||||
aterm,
|
||||
}:
|
||||
{
|
||||
name = "nix-${stdenv.name}-${aterm.name}";
|
||||
};
|
||||
|
||||
mplayerFun =
|
||||
{ stdenv, fetchurl, enableX11 ? false, xorg ? null, enableFoo ? true, foo ? null }:
|
||||
{
|
||||
stdenv,
|
||||
fetchurl,
|
||||
enableX11 ? false,
|
||||
xorg ? null,
|
||||
enableFoo ? true,
|
||||
foo ? null,
|
||||
}:
|
||||
assert stdenv.name == "stdenv2";
|
||||
assert enableX11 -> xorg.libXv.name == "libXv";
|
||||
assert enableFoo -> foo != null;
|
||||
{ name = "mplayer-${stdenv.name}.${xorg.libXv.name}-${xorg.libX11.name}"; };
|
||||
{
|
||||
name = "mplayer-${stdenv.name}.${xorg.libXv.name}-${xorg.libX11.name}";
|
||||
};
|
||||
|
||||
makeOverridable = f: origArgs: f origArgs //
|
||||
{ override = newArgs:
|
||||
makeOverridable =
|
||||
f: origArgs:
|
||||
f origArgs
|
||||
// {
|
||||
override =
|
||||
newArgs:
|
||||
makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs));
|
||||
};
|
||||
|
||||
callPackage_ = pkgs: f: args:
|
||||
|
||||
callPackage_ =
|
||||
pkgs: f: args:
|
||||
makeOverridable f ((builtins.intersectAttrs (builtins.functionArgs f) pkgs) // args);
|
||||
|
||||
allPackages =
|
||||
{ overrides ? (pkgs: pkgsPrev: { }) }:
|
||||
{
|
||||
overrides ? (pkgs: pkgsPrev: { }),
|
||||
}:
|
||||
let
|
||||
callPackage = callPackage_ pkgs;
|
||||
pkgs = pkgsStd // (overrides pkgs pkgsStd);
|
||||
|
@ -34,18 +79,40 @@ let
|
|||
fetchurl = callPackage fetchurlFun { };
|
||||
aterm = callPackage atermFun { };
|
||||
xorg = callPackage xorgFun { };
|
||||
mplayer = callPackage mplayerFun { stdenv = pkgs.stdenv2; enableFoo = false; };
|
||||
mplayer = callPackage mplayerFun {
|
||||
stdenv = pkgs.stdenv2;
|
||||
enableFoo = false;
|
||||
};
|
||||
nix = callPackage nixFun { };
|
||||
};
|
||||
in pkgs;
|
||||
in
|
||||
pkgs;
|
||||
|
||||
libX11Fun =
|
||||
{ stdenv, fetchurl }:
|
||||
{
|
||||
name = "libX11";
|
||||
};
|
||||
libX11_2Fun =
|
||||
{ stdenv, fetchurl }:
|
||||
{
|
||||
name = "libX11_2";
|
||||
};
|
||||
libXvFun =
|
||||
{
|
||||
stdenv,
|
||||
fetchurl,
|
||||
libX11,
|
||||
}:
|
||||
{
|
||||
name = "libXv";
|
||||
};
|
||||
|
||||
libX11Fun = { stdenv, fetchurl }: { name = "libX11"; };
|
||||
libX11_2Fun = { stdenv, fetchurl }: { name = "libX11_2"; };
|
||||
libXvFun = { stdenv, fetchurl, libX11 }: { name = "libXv"; };
|
||||
|
||||
xorgFun =
|
||||
{ pkgs }:
|
||||
let callPackage = callPackage_ (pkgs // pkgs.xorg); in
|
||||
let
|
||||
callPackage = callPackage_ (pkgs // pkgs.xorg);
|
||||
in
|
||||
{
|
||||
libX11 = callPackage libX11Fun { };
|
||||
libXv = callPackage libXvFun { };
|
||||
|
@ -56,25 +123,28 @@ in
|
|||
let
|
||||
|
||||
pkgs = allPackages { };
|
||||
|
||||
|
||||
pkgs2 = allPackages {
|
||||
overrides = pkgs: pkgsPrev: {
|
||||
stdenv = pkgs.stdenv2;
|
||||
nix = pkgsPrev.nix.override { aterm = aterm2Fun { inherit (pkgs) stdenv fetchurl; }; };
|
||||
xorg = pkgsPrev.xorg // { libX11 = libX11_2Fun { inherit (pkgs) stdenv fetchurl; }; };
|
||||
xorg = pkgsPrev.xorg // {
|
||||
libX11 = libX11_2Fun { inherit (pkgs) stdenv fetchurl; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
in
|
||||
|
||||
[ pkgs.stdenv.name
|
||||
pkgs.fetchurl.name
|
||||
pkgs.aterm.name
|
||||
pkgs2.aterm.name
|
||||
pkgs.xorg.libX11.name
|
||||
pkgs.xorg.libXv.name
|
||||
pkgs.mplayer.name
|
||||
pkgs2.mplayer.name
|
||||
pkgs.nix.name
|
||||
pkgs2.nix.name
|
||||
]
|
||||
[
|
||||
pkgs.stdenv.name
|
||||
pkgs.fetchurl.name
|
||||
pkgs.aterm.name
|
||||
pkgs2.aterm.name
|
||||
pkgs.xorg.libX11.name
|
||||
pkgs.xorg.libXv.name
|
||||
pkgs.mplayer.name
|
||||
pkgs2.mplayer.name
|
||||
pkgs.nix.name
|
||||
pkgs2.nix.name
|
||||
]
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
let
|
||||
fun = { foo }: {};
|
||||
fun = { foo }: { };
|
||||
pos = builtins.unsafeGetAttrPos "foo" (builtins.functionArgs fun);
|
||||
in { inherit (pos) column line; file = baseNameOf pos.file; }
|
||||
in
|
||||
{
|
||||
inherit (pos) column line;
|
||||
file = baseNameOf pos.file;
|
||||
}
|
||||
|
|
|
@ -3,4 +3,8 @@ let
|
|||
foo = "bar";
|
||||
};
|
||||
pos = builtins.unsafeGetAttrPos "foo" as;
|
||||
in { inherit (pos) column line; file = baseNameOf pos.file; }
|
||||
in
|
||||
{
|
||||
inherit (pos) column line;
|
||||
file = baseNameOf pos.file;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
builtins.groupBy (n:
|
||||
builtins.substring 0 1 (builtins.hashString "sha256" (toString n))
|
||||
) (range 0 31)
|
||||
builtins.groupBy (n: builtins.substring 0 1 (builtins.hashString "sha256" (toString n))) (
|
||||
range 0 31
|
||||
)
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
let
|
||||
paths = [ ./data ./binary-data ];
|
||||
paths = [
|
||||
./data
|
||||
./binary-data
|
||||
];
|
||||
in
|
||||
builtins.concatLists (map (hash: map (builtins.hashFile hash) paths) ["md5" "sha1" "sha256" "sha512"])
|
||||
builtins.concatLists (
|
||||
map (hash: map (builtins.hashFile hash) paths) [
|
||||
"md5"
|
||||
"sha1"
|
||||
"sha256"
|
||||
"sha512"
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,4 +1,15 @@
|
|||
let
|
||||
strings = [ "" "text 1" "text 2" ];
|
||||
strings = [
|
||||
""
|
||||
"text 1"
|
||||
"text 2"
|
||||
];
|
||||
in
|
||||
builtins.concatLists (map (hash: map (builtins.hashString hash) strings) ["md5" "sha1" "sha256" "sha512"])
|
||||
builtins.concatLists (
|
||||
map (hash: map (builtins.hashString hash) strings) [
|
||||
"md5"
|
||||
"sha1"
|
||||
"sha256"
|
||||
"sha512"
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
if "foo" != "f" + "oo" then 1 else if false then 2 else 3
|
||||
if "foo" != "f" + "oo" then
|
||||
1
|
||||
else if false then
|
||||
2
|
||||
else
|
||||
3
|
||||
|
|
|
@ -8,4 +8,5 @@ let
|
|||
builtins = builtins // overrides;
|
||||
} // import ./lib.nix;
|
||||
|
||||
in scopedImport overrides ./imported.nix
|
||||
in
|
||||
scopedImport overrides ./imported.nix
|
||||
|
|
|
@ -16,16 +16,17 @@ let
|
|||
it doesn't matter).
|
||||
'';
|
||||
|
||||
s2 = '' If the string starts with whitespace
|
||||
followed by a newline, it's stripped, but
|
||||
that's not the case here. Two spaces are
|
||||
stripped because of the " " at the start.
|
||||
s2 = ''
|
||||
If the string starts with whitespace
|
||||
followed by a newline, it's stripped, but
|
||||
that's not the case here. Two spaces are
|
||||
stripped because of the " " at the start.
|
||||
'';
|
||||
|
||||
s3 = ''
|
||||
This line is indented
|
||||
a bit further.
|
||||
''; # indentation of last line doesn't count if it's empty
|
||||
This line is indented
|
||||
a bit further.
|
||||
''; # indentation of last line doesn't count if it's empty
|
||||
|
||||
s4 = ''
|
||||
Anti-quotations, like ${if true then "so" else "not so"}, are
|
||||
|
@ -40,11 +41,11 @@ let
|
|||
If you want them, use anti-quotations: ${"''"}, ${"\${"}.
|
||||
'';
|
||||
|
||||
s6 = ''
|
||||
Tabs are not interpreted as whitespace (since we can't guess
|
||||
what tab settings are intended), so don't use them.
|
||||
This line starts with a space and a tab, so only one
|
||||
space will be stripped from each line.
|
||||
s6 = ''
|
||||
Tabs are not interpreted as whitespace (since we can't guess
|
||||
what tab settings are intended), so don't use them.
|
||||
This line starts with a space and a tab, so only one
|
||||
space will be stripped from each line.
|
||||
'';
|
||||
|
||||
s7 = ''
|
||||
|
@ -52,36 +53,38 @@ let
|
|||
consists only of whitespace, it's ignored. But here there is
|
||||
some non-whitespace stuff, so the line isn't removed. '';
|
||||
|
||||
s8 = '' ${""}
|
||||
s8 = ''
|
||||
${""}
|
||||
This shows a hacky way to preserve an empty line after the start.
|
||||
But there's no reason to do so: you could just repeat the empty
|
||||
line.
|
||||
'';
|
||||
|
||||
s9 = ''
|
||||
${""} Similarly you can force an indentation level,
|
||||
in this case to 2 spaces. This works because the anti-quote
|
||||
is significant (not whitespace).
|
||||
${""} Similarly you can force an indentation level,
|
||||
in this case to 2 spaces. This works because the anti-quote
|
||||
is significant (not whitespace).
|
||||
'';
|
||||
|
||||
s10 = ''
|
||||
'';
|
||||
s10 = '''';
|
||||
|
||||
s11 = '''';
|
||||
|
||||
s12 = '' '';
|
||||
s12 = '''';
|
||||
|
||||
s13 = ''
|
||||
start on network-interfaces
|
||||
|
||||
start script
|
||||
|
||||
|
||||
rm -f /var/run/opengl-driver
|
||||
${if true
|
||||
then "ln -sf 123 /var/run/opengl-driver"
|
||||
else if true
|
||||
then "ln -sf 456 /var/run/opengl-driver"
|
||||
else ""
|
||||
${
|
||||
if true then
|
||||
"ln -sf 123 /var/run/opengl-driver"
|
||||
else if true then
|
||||
"ln -sf 456 /var/run/opengl-driver"
|
||||
else
|
||||
""
|
||||
}
|
||||
|
||||
rm -f /var/log/slim.log
|
||||
|
@ -94,11 +97,13 @@ let
|
|||
env XKB_BINDIR=${"foo"}/bin # Needed for the Xkb extension.
|
||||
env LD_LIBRARY_PATH=${"libX11"}/lib:${"libXext"}/lib:/usr/lib/ # related to xorg-sys-opengl - needed to load libglx for (AI)GLX support (for compiz)
|
||||
|
||||
${if true
|
||||
then "env XORG_DRI_DRIVER_PATH=${"nvidiaDrivers"}/X11R6/lib/modules/drivers/"
|
||||
else if true
|
||||
then "env XORG_DRI_DRIVER_PATH=${"mesa"}/lib/modules/dri"
|
||||
else ""
|
||||
${
|
||||
if true then
|
||||
"env XORG_DRI_DRIVER_PATH=${"nvidiaDrivers"}/X11R6/lib/modules/drivers/"
|
||||
else if true then
|
||||
"env XORG_DRI_DRIVER_PATH=${"mesa"}/lib/modules/dri"
|
||||
else
|
||||
""
|
||||
}
|
||||
|
||||
exec ${"slim"}/bin/slim
|
||||
|
@ -111,18 +116,23 @@ let
|
|||
'';
|
||||
|
||||
# Regression test: string interpolation in '${x}' should work, but didn't.
|
||||
s15 = let x = "bla"; in ''
|
||||
foo
|
||||
'${x}'
|
||||
bar
|
||||
'';
|
||||
s15 =
|
||||
let
|
||||
x = "bla";
|
||||
in
|
||||
''
|
||||
foo
|
||||
'${x}'
|
||||
bar
|
||||
'';
|
||||
|
||||
# Regression test: accept $'.
|
||||
s16 = ''
|
||||
cut -d $'\t' -f 1
|
||||
'';
|
||||
|
||||
# Accept dollars at end of strings
|
||||
# Accept dollars at end of strings
|
||||
s17 = ''ending dollar $'' + ''$'' + "\n";
|
||||
|
||||
in s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12 + s13 + s14 + s15 + s16 + s17
|
||||
in
|
||||
s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12 + s13 + s14 + s15 + s16 + s17
|
||||
|
|
|
@ -4,9 +4,9 @@ let
|
|||
y = { inherit d x; };
|
||||
z = { inherit (y) d x; };
|
||||
in
|
||||
[
|
||||
(builtins.unsafeGetAttrPos "d" y)
|
||||
(builtins.unsafeGetAttrPos "x" y)
|
||||
(builtins.unsafeGetAttrPos "d" z)
|
||||
(builtins.unsafeGetAttrPos "x" z)
|
||||
]
|
||||
[
|
||||
(builtins.unsafeGetAttrPos "d" y)
|
||||
(builtins.unsafeGetAttrPos "x" y)
|
||||
(builtins.unsafeGetAttrPos "d" z)
|
||||
(builtins.unsafeGetAttrPos "x" z)
|
||||
]
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
let
|
||||
inherit (builtins.trace "used" { a = 1; b = 2; }) a b;
|
||||
inherit
|
||||
(builtins.trace "used" {
|
||||
a = 1;
|
||||
b = 2;
|
||||
})
|
||||
a
|
||||
b
|
||||
;
|
||||
x.c = 3;
|
||||
y.d = 4;
|
||||
|
||||
|
@ -13,4 +20,14 @@ let
|
|||
};
|
||||
};
|
||||
in
|
||||
[ a b rec { x.c = []; inherit (x) c; inherit (y) d; __overrides.y.d = []; } merged ]
|
||||
[
|
||||
a
|
||||
b
|
||||
rec {
|
||||
x.c = [ ];
|
||||
inherit (x) c;
|
||||
inherit (y) d;
|
||||
__overrides.y.d = [ ];
|
||||
}
|
||||
merged
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
let
|
||||
alphabet =
|
||||
{ a = "a";
|
||||
alphabet = {
|
||||
a = "a";
|
||||
b = "b";
|
||||
c = "c";
|
||||
d = "d";
|
||||
|
@ -28,23 +28,46 @@ let
|
|||
z = "z";
|
||||
};
|
||||
foo = {
|
||||
inherit (alphabet) f o b a r z q u x;
|
||||
inherit (alphabet)
|
||||
f
|
||||
o
|
||||
b
|
||||
a
|
||||
r
|
||||
z
|
||||
q
|
||||
u
|
||||
x
|
||||
;
|
||||
aa = throw "aa";
|
||||
};
|
||||
alphabetFail = builtins.mapAttrs throw alphabet;
|
||||
in
|
||||
[ (builtins.intersectAttrs { a = abort "l1"; } { b = abort "r1"; })
|
||||
[
|
||||
(builtins.intersectAttrs { a = abort "l1"; } { b = abort "r1"; })
|
||||
(builtins.intersectAttrs { a = abort "l2"; } { a = 1; })
|
||||
(builtins.intersectAttrs alphabetFail { a = 1; })
|
||||
(builtins.intersectAttrs { a = abort "laa"; } alphabet)
|
||||
(builtins.intersectAttrs { a = abort "laa"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { m = 1; })
|
||||
(builtins.intersectAttrs { m = abort "lam"; } alphabet)
|
||||
(builtins.intersectAttrs { m = abort "lam"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { n = 1; })
|
||||
(builtins.intersectAttrs { n = abort "lan"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { n = 1; p = 2; })
|
||||
(builtins.intersectAttrs { n = abort "lan2"; p = abort "lap"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail { n = 1; p = 2; })
|
||||
(builtins.intersectAttrs { n = abort "lan2"; p = abort "lap"; } alphabet)
|
||||
(builtins.intersectAttrs { n = abort "lan"; } alphabet)
|
||||
(builtins.intersectAttrs alphabetFail {
|
||||
n = 1;
|
||||
p = 2;
|
||||
})
|
||||
(builtins.intersectAttrs {
|
||||
n = abort "lan2";
|
||||
p = abort "lap";
|
||||
} alphabet)
|
||||
(builtins.intersectAttrs alphabetFail {
|
||||
n = 1;
|
||||
p = 2;
|
||||
})
|
||||
(builtins.intersectAttrs {
|
||||
n = abort "lan2";
|
||||
p = abort "lap";
|
||||
} alphabet)
|
||||
(builtins.intersectAttrs alphabetFail alphabet)
|
||||
(builtins.intersectAttrs alphabet foo == builtins.intersectAttrs foo alphabet)
|
||||
]
|
||||
|
|
|
@ -2,6 +2,11 @@ with import ./lib.nix;
|
|||
|
||||
let {
|
||||
|
||||
body = concat ["foo" "bar" "bla" "test"];
|
||||
|
||||
}
|
||||
body = concat [
|
||||
"foo"
|
||||
"bar"
|
||||
"bla"
|
||||
"test"
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
# this test shows how to use listToAttrs and that evaluation is still lazy (throw isn't called)
|
||||
with import ./lib.nix;
|
||||
|
||||
let
|
||||
asi = name: value : { inherit name value; };
|
||||
list = [ ( asi "a" "A" ) ( asi "b" "B" ) ];
|
||||
let
|
||||
asi = name: value: { inherit name value; };
|
||||
list = [
|
||||
(asi "a" "A")
|
||||
(asi "b" "B")
|
||||
];
|
||||
a = builtins.listToAttrs list;
|
||||
b = builtins.listToAttrs ( list ++ list );
|
||||
r = builtins.listToAttrs [ (asi "result" [ a b ]) ( asi "throw" (throw "this should not be thrown")) ];
|
||||
x = builtins.listToAttrs [ (asi "foo" "bar") (asi "foo" "bla") ];
|
||||
in concat (map (x: x.a) r.result) + x.foo
|
||||
b = builtins.listToAttrs (list ++ list);
|
||||
r = builtins.listToAttrs [
|
||||
(asi "result" [
|
||||
a
|
||||
b
|
||||
])
|
||||
(asi "throw" (throw "this should not be thrown"))
|
||||
];
|
||||
x = builtins.listToAttrs [
|
||||
(asi "foo" "bar")
|
||||
(asi "foo" "bla")
|
||||
];
|
||||
in
|
||||
concat (map (x: x.a) r.result) + x.foo
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
assert !false && (true || false) -> true; 1
|
||||
assert !false && (true || false) -> true;
|
||||
1
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
concat (map (x: x + "bar") [ "foo" "bla" "xyzzy" ])
|
||||
concat (
|
||||
map (x: x + "bar") [
|
||||
"foo"
|
||||
"bla"
|
||||
"xyzzy"
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
builtins.mapAttrs (name: value: name + "-" + value) { x = "foo"; y = "bar"; }
|
||||
builtins.mapAttrs (name: value: name + "-" + value) {
|
||||
x = "foo";
|
||||
y = "bar";
|
||||
}
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
{
|
||||
set1 = { a = 1; };
|
||||
set1 = { "${"b" + ""}" = 2; };
|
||||
set1 = {
|
||||
a = 1;
|
||||
};
|
||||
set1 = {
|
||||
"${"b" + ""}" = 2;
|
||||
};
|
||||
|
||||
set2 = { "${"b" + ""}" = 2; };
|
||||
set2 = { a = 1; };
|
||||
set2 = {
|
||||
"${"b" + ""}" = 2;
|
||||
};
|
||||
set2 = {
|
||||
a = 1;
|
||||
};
|
||||
|
||||
set3.a = 1;
|
||||
set3."${"b" + ""}" = 2;
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
with { x = 1; };
|
||||
with { x = 2; };
|
||||
x
|
||||
with { x = 1; }; with { x = 2; }; x
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
let
|
||||
|
||||
f = z:
|
||||
f =
|
||||
z:
|
||||
|
||||
let
|
||||
x = "foo";
|
||||
y = "bar";
|
||||
body = 1; # compat test
|
||||
in
|
||||
z + x + y;
|
||||
z + x + y;
|
||||
|
||||
arg = "xyzzy";
|
||||
|
||||
in f arg
|
||||
in
|
||||
f arg
|
||||
|
|
|
@ -1 +1 @@
|
|||
{ ${null} = true; } == {}
|
||||
{ ${null} = true; } == { }
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
let
|
||||
|
||||
overrides = { a = 2; b = 3; };
|
||||
overrides = {
|
||||
a = 2;
|
||||
b = 3;
|
||||
};
|
||||
|
||||
in (rec {
|
||||
in
|
||||
(rec {
|
||||
__overrides = overrides;
|
||||
x = a;
|
||||
a = 1;
|
||||
|
|
|
@ -1 +1 @@
|
|||
builtins.parseFlakeRef "github:NixOS/nixpkgs/23.05?dir=lib"
|
||||
builtins.parseFlakeRef "github:NixOS/nixpkgs/23.05?dir=lib"
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
builtins.partition
|
||||
(x: x / 2 * 2 == x)
|
||||
(builtins.concatLists [ (range 0 10) (range 100 110) ])
|
||||
builtins.partition (x: x / 2 * 2 == x) (
|
||||
builtins.concatLists [
|
||||
(range 0 10)
|
||||
(range 100 110)
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
[
|
||||
(builtins.path
|
||||
{ path = ./.;
|
||||
filter = path: _: baseNameOf path == "data";
|
||||
recursive = true;
|
||||
sha256 = "1yhm3gwvg5a41yylymgblsclk95fs6jy72w0wv925mmidlhcq4sw";
|
||||
name = "output";
|
||||
})
|
||||
(builtins.path
|
||||
{ path = ./data;
|
||||
recursive = false;
|
||||
sha256 = "0k4lwj58f2w5yh92ilrwy9917pycipbrdrr13vbb3yd02j09vfxm";
|
||||
name = "output";
|
||||
})
|
||||
(builtins.path {
|
||||
path = ./.;
|
||||
filter = path: _: baseNameOf path == "data";
|
||||
recursive = true;
|
||||
sha256 = "1yhm3gwvg5a41yylymgblsclk95fs6jy72w0wv925mmidlhcq4sw";
|
||||
name = "output";
|
||||
})
|
||||
(builtins.path {
|
||||
path = ./data;
|
||||
recursive = false;
|
||||
sha256 = "0k4lwj58f2w5yh92ilrwy9917pycipbrdrr13vbb3yd02j09vfxm";
|
||||
name = "output";
|
||||
})
|
||||
]
|
||||
|
|
|
@ -1,16 +1,59 @@
|
|||
let
|
||||
|
||||
f = args@{x, y, z}: x + args.y + z;
|
||||
f =
|
||||
args@{
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
}:
|
||||
x + args.y + z;
|
||||
|
||||
g = {x, y, z}@args: f args;
|
||||
g =
|
||||
{
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
}@args:
|
||||
f args;
|
||||
|
||||
h = {x ? "d", y ? x, z ? args.x}@args: x + y + z;
|
||||
h =
|
||||
{
|
||||
x ? "d",
|
||||
y ? x,
|
||||
z ? args.x,
|
||||
}@args:
|
||||
x + y + z;
|
||||
|
||||
j = {x, y, z, ...}: x + y + z;
|
||||
j =
|
||||
{
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
...
|
||||
}:
|
||||
x + y + z;
|
||||
|
||||
in
|
||||
f {x = "a"; y = "b"; z = "c";} +
|
||||
g {x = "x"; y = "y"; z = "z";} +
|
||||
h {x = "D";} +
|
||||
h {x = "D"; y = "E"; z = "F";} +
|
||||
j {x = "i"; y = "j"; z = "k"; bla = "bla"; foo = "bar";}
|
||||
f {
|
||||
x = "a";
|
||||
y = "b";
|
||||
z = "c";
|
||||
}
|
||||
+ g {
|
||||
x = "x";
|
||||
y = "y";
|
||||
z = "z";
|
||||
}
|
||||
+ h { x = "D"; }
|
||||
+ h {
|
||||
x = "D";
|
||||
y = "E";
|
||||
z = "F";
|
||||
}
|
||||
+ j {
|
||||
x = "i";
|
||||
y = "j";
|
||||
z = "k";
|
||||
bla = "bla";
|
||||
foo = "bar";
|
||||
}
|
||||
|
|
|
@ -1 +1,15 @@
|
|||
with builtins; trace [(1+1)] [ null toString (deepSeq "x") (a: a) (let x=[x]; in x) ]
|
||||
with builtins;
|
||||
trace
|
||||
[ (1 + 1) ]
|
||||
[
|
||||
null
|
||||
toString
|
||||
(deepSeq "x")
|
||||
(a: a)
|
||||
(
|
||||
let
|
||||
x = [ x ];
|
||||
in
|
||||
x
|
||||
)
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
bar = builtins.readFileType ./readDir/bar;
|
||||
foo = builtins.readFileType ./readDir/foo;
|
||||
bar = builtins.readFileType ./readDir/bar;
|
||||
foo = builtins.readFileType ./readDir/foo;
|
||||
linked = builtins.readFileType ./readDir/linked;
|
||||
ldir = builtins.readFileType ./readDir/ldir;
|
||||
ldir = builtins.readFileType ./readDir/ldir;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue