Skip to content

Commit

Permalink
Merge #1100 nuke submodule, add testsuite, upd dev-env nixpkgs-unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton-Latukha authored Nov 21, 2023
2 parents c8b753e + 5ea330c commit 61a049b
Show file tree
Hide file tree
Showing 261 changed files with 2,231 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Optional-Nix-dev-env-macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:


env:
rev: "272fad732d39b24c4549c475176e0d8cbc8c897a"
rev: "c757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad"
cachixAccount: "hnix"
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}
doCheck: "false"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Optional-Nix-dev-env-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
### and the other part of keys explained in `build.sh`, since those address external procedures aound the builds.
### Additional documentation is in Nixpkgs Haskell.lib: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/lib.nix
###
rev: "272fad732d39b24c4549c475176e0d8cbc8c897a"
rev: "c757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad"
cachixAccount: "hnix"
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}
allowInconsistentDependencies: "false"
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "data/nix"]
path = data/nix
url = https://github.com/haskell-nix/nix
5 changes: 1 addition & 4 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Tooling is WIP, `nix-shell` and `nix-store` are still used for their purpose, so
### Git clone

```shell
git clone --recursive 'https://github.com/haskell-nix/hnix.git' && cd hnix
git clone 'https://github.com/haskell-nix/hnix.git' && cd hnix
```


Expand Down Expand Up @@ -300,9 +300,6 @@ hnix \

```shell
cabal v2-test

# If forgot to clone recursively, run:
# git submodule update --init --recursive
```

Please, check that all default tests that were passing prior are still passing. It's OK if no new tests are passing.
Expand Down
1 change: 0 additions & 1 deletion data/nix
Submodule nix deleted from 315702
5 changes: 5 additions & 0 deletions data/nix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Extracted from https://github.com/NixOS/nix (GPLv2)
commit 6c2af1f201a925c2aa632737765685c72b642847
Date: Mon Nov 8 14:13:42 202

Keep only `tests/lang` which are required by `hnix`es testsuite.
Binary file added data/nix/tests/lang/binary-data
Binary file not shown.
1 change: 1 addition & 0 deletions data/nix/tests/lang/data
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
1 change: 1 addition & 0 deletions data/nix/tests/lang/dir1/a.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"a"
1 change: 1 addition & 0 deletions data/nix/tests/lang/dir2/a.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"X"
1 change: 1 addition & 0 deletions data/nix/tests/lang/dir2/b.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"b"
1 change: 1 addition & 0 deletions data/nix/tests/lang/dir3/a.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"X"
1 change: 1 addition & 0 deletions data/nix/tests/lang/dir3/b.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"X"
1 change: 1 addition & 0 deletions data/nix/tests/lang/dir3/c.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"c"
1 change: 1 addition & 0 deletions data/nix/tests/lang/dir4/a.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"X"
1 change: 1 addition & 0 deletions data/nix/tests/lang/dir4/c.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"X"
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-fail-abort.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
if true then abort "this should fail" else 1
5 changes: 5 additions & 0 deletions data/nix/tests/lang/eval-fail-assert.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let {
x = arg: assert arg == "y"; 123;

body = x "x";
}
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-fail-bad-antiquote-1.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"${x: x}"
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-fail-bad-antiquote-2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"${./fnord}"
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-fail-bad-antiquote-3.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
''${x: x}''
5 changes: 5 additions & 0 deletions data/nix/tests/lang/eval-fail-blackhole.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let {
body = x;
x = y;
y = x;
}
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-fail-deepseq.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
builtins.deepSeq { x = abort "foo"; } 456
5 changes: 5 additions & 0 deletions data/nix/tests/lang/eval-fail-hashfile-missing.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let
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"]))

1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-fail-missing-arg.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
({x, y, z}: x + y + z) {x = "foo"; z = "bar";}
4 changes: 4 additions & 0 deletions data/nix/tests/lang/eval-fail-nonexist-path.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This must fail to evaluate, since ./fnord doesn't exist. If it did
# exist, it would produce "/nix/store/<hash>-fnord/xyzzy" (with an
# appropriate context).
"${./fnord}/xyzzy"
6 changes: 6 additions & 0 deletions data/nix/tests/lang/eval-fail-path-slash.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Trailing slashes in paths are not allowed.
# This restriction could be lifted sometime,
# for example if we make '/' a path concatenation operator.
# See https://github.com/NixOS/nix/issues/1138
# and https://nixos.org/nix-dev/2016-June/020829.html
/nix/store/
5 changes: 5 additions & 0 deletions data/nix/tests/lang/eval-fail-remove.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let {
attrs = {x = 123; y = 456;};

body = (removeAttrs attrs ["x"]).x;
}
10 changes: 10 additions & 0 deletions data/nix/tests/lang/eval-fail-scope-5.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let {

x = "a";
y = "b";

f = {x ? y, y ? x}: x + y;

body = f {};

}
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-fail-seq.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
builtins.seq (abort "foo") 2
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-fail-substring.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
builtins.substring (builtins.sub 0 1) 1 "x"
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-fail-to-path.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
builtins.toPath "foo/bar"
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-fail-undeclared-arg.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
({x, z}: x + z) {x = "foo"; y = "bla"; z = "bar";}
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-any-all.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ false false true true true true false true ]
11 changes: 11 additions & 0 deletions data/nix/tests/lang/eval-okay-any-all.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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])
]
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-arithmetic.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2216
59 changes: 59 additions & 0 deletions data/nix/tests/lang/eval-okay-arithmetic.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
with import ./lib.nix;

let {

/* Supposedly tail recursive version:
range_ = accum: first: last:
if first == last then ([first] ++ accum)
else range_ ([first] ++ accum) (builtins.add first 1) last;
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)

(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 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 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)

# 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)
];

}
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-attrnames.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"newxfoonewxy"
11 changes: 11 additions & 0 deletions data/nix/tests/lang/eval-okay-attrnames.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
with import ./lib.nix;

let

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
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-attrs.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
987
5 changes: 5 additions & 0 deletions data/nix/tests/lang/eval-okay-attrs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let {
as = { x = 123; y = 456; } // { z = 789; } // { z = 987; };

body = if as ? a then as.a else assert as ? z; as.z;
}
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-attrs2.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
987
10 changes: 10 additions & 0 deletions data/nix/tests/lang/eval-okay-attrs2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let {
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;
}
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-attrs3.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"foo 22 80 itchyxac"
22 changes: 22 additions & 0 deletions data/nix/tests/lang/eval-okay-attrs3.nix
Original file line number Diff line number Diff line change
@@ -0,0 +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";
};
};

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"
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-attrs4.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ true false true false false true false false ]
7 changes: 7 additions & 0 deletions data/nix/tests/lang/eval-okay-attrs4.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let

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) ]
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-attrs5.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ 123 "foo" 456 456 "foo" "xyzzy" "xyzzy" true ]
21 changes: 21 additions & 0 deletions data/nix/tests/lang/eval-okay-attrs5.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
with import ./lib.nix;

let

as = { x.y.z = 123; a.b.c = 456; };

bs = { f-o-o.bar = "foo"; };

or = x: y: x || y;

in
[ as.x.y.z
as.foo or "foo"
as.x.y.bla or as.a.b.c
as.a.b.c or as.x.y.z
as.x.y.bla or bs.f-o-o.bar or "xyzzy"
as.x.y.bla or bs.bar.foo or "xyzzy"
(123).bla or null.foo or "xyzzy"
# Backwards compatibility test.
(fold or [] [true false false])
]
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-attrs6.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ __overrides = { bar = "qux"; }; bar = "qux"; foo = "bar"; }
4 changes: 4 additions & 0 deletions data/nix/tests/lang/eval-okay-attrs6.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rec {
"${"foo"}" = "bar";
__overrides = { bar = "qux"; };
}
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-autoargs.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"xyzzy!xyzzy!foobar"
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-autoargs.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--arg lib import(lang/lib.nix) --argstr xyzzy xyzzy! -A result
15 changes: 15 additions & 0 deletions data/nix/tests/lang/eval-okay-autoargs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let

foobar = "foobar";

in

{ 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];
}
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-backslash-newline-1.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"a\nb"
2 changes: 2 additions & 0 deletions data/nix/tests/lang/eval-okay-backslash-newline-1.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"a\
b"
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-backslash-newline-2.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"a\nb"
2 changes: 2 additions & 0 deletions data/nix/tests/lang/eval-okay-backslash-newline-2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
''a''\
b''
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-builtins-add.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ 5 4 "int" "tt" "float" 4 ]
8 changes: 8 additions & 0 deletions data/nix/tests/lang/eval-okay-builtins-add.nix
Original file line number Diff line number Diff line change
@@ -0,0 +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)
]
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-builtins.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/foo
12 changes: 12 additions & 0 deletions data/nix/tests/lang/eval-okay-builtins.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
assert builtins ? currentSystem;
assert !builtins ? __currentSystem;

let {

x = if builtins ? dirOf then builtins.dirOf /foo/bar else "";

y = if builtins ? fnord then builtins.fnord "foo" else "";

body = x + y;

}
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-callable-attrs.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-callable-attrs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
({ __functor = self: x: self.foo && x; foo = false; } // { foo = true; }) true
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-catattrs.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ 1 2 ]
1 change: 1 addition & 0 deletions data/nix/tests/lang/eval-okay-catattrs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
builtins.catAttrs "a" [ { a = 1; } { b = 0; } { a = 2; } ]
Loading

0 comments on commit 61a049b

Please sign in to comment.