Commit graph

14 commits

Author SHA1 Message Date
Vincent Ambo
c7bc8aac49 docs(yants): Update josh cloning instructions
Change-Id: I4e9e31488f91465df6b2c6800a3940118107524b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5315
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: tazjin <tazjin@tvl.su>
2022-02-19 11:37:00 +00:00
Vincent Ambo
aa122cbae7 style: format entire depot with nixpkgs-fmt
This CL can be used to compare the style of nixpkgs-fmt against other
formatters (nixpkgs, alejandra).

Change-Id: I87c6abff6bcb546b02ead15ad0405f81e01b6d9e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4397
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Reviewed-by: wpcarro <wpcarro@gmail.com>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Reviewed-by: cynthia <cynthia@tvl.fyi>
Reviewed-by: edef <edef@edef.eu>
Reviewed-by: eta <tvl@eta.st>
Reviewed-by: grfn <grfn@gws.fyi>
2022-01-31 16:11:53 +00:00
zseri
00adb6e8f3 feat(nix/yants): improve error message for errornous predicate
while trying to yantsify `mkSecrets` in https://cl.tvl.fyi/c/depot/+/4688,
I(zseri) needed to debug a failing evaluation which boiled down
to a result.ok containing something which wasn't boolean,
but the error message didn't indicate where that value came from.

I debugged yants and found that the only place which didn't
simply combine boolean values or use functions which always
return booleans, I managed to isolate the error to the
`pred v` expression. To avoid the necessity to debug yants
to find this, I improve the error message for this case
to mention that
- a restriction predicate is invalid
- what's the name of the failing restriction
- the unexpected predicate return value

Change-Id: I6c570a33ccc5afc445f208e2e8855c49fb37abaf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4698
Tested-by: BuildkiteCI
Reviewed-by: zseri <zseri.devel@ytrizja.de>
Reviewed-by: tazjin <mail@tazj.in>
Autosubmit: zseri <zseri.devel@ytrizja.de>
2021-12-27 08:20:58 +00:00
sterni
690994a28c fix(nix/yants): make (typedef …).checkType return a result set
Previously, for types defined using typedef (like all primitive types)
type.checkType would return a boolean. This is largely fine since in
most places `type.checkToBool (type.checkType x)` or similar is used.
However, some functions actually take type.checkType up on the promise
that it returns a set of the form:

  {
    ok = <bool>;
    err = <option string>;
  }

This is the case for restrict which has checkToBool = v: v.ok; and will
generate a proper set except if `t.checkToBool (t.checkType v) == false`
in which case it will return t.checkType v. If t was a primitive type or
defined using typedef, previously `t.checkType v` would be a boolean
which meant as soon as (restrict …).checkToBool was called on a restrict
checkType result in cases where the wrapped type didn't match, an
unrelated error would be thrown:

  nix-repl> with nix.yants; restrict "foo" (_: true) int "lol"
  error: value is a boolean while a set was expected, at /home/lukas/src/depot/nix/yants/default.nix:38:39

This is fixed by making typedef return a proper set from checkType and
adjusting its checkToBool accordingly.

Unfortunately I don't think we can easily add test cases for this except
by using recursive nix or VM tests as there is no way to introspect
error messages.

Change-Id: I96a7be065630f04ca33358f21809284911ec14fe
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2536
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-19 16:14:55 +00:00
sterni
7bd43d15d9 feat(nix/yants/tests): test drv type
By using an extremely trivial derivation we can ensure that it will not
throw if evaluated using deepSeq. When using stdenv.mkDerivation or
similar at some point something will most likely throw or generate some
kind of error which is alright in the context of nixpkgs, but makes
testing yants harder than you'd think it should be.

Change-Id: I61ff7dc01a00a4815ef39066e4e223123356ddd5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2507
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-02-12 21:52:36 +00:00
sterni
58020730cd feat(nix/yants/tests): port to runTestsuite
Port existing tests to runTestsuite and add some obvious additional
tests that wouldn't be possible before (using assertThrows and
assertEq).

Change-Id: Ibe950a7a0cda3e23ebb226bdff35f52cdfec5ddf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2479
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: tazjin <mail@tazj.in>
2021-02-09 21:57:56 +00:00
Profpatsch
4af195c5f2 feat(nix/yants): add restrict
`restrict` uses a predicate function to restrict a type, giving the
restricting a descriptive name in the process.

First, the wrapped type definition is checked (e.g. int) and then the
value is checked with the predicate, so the predicate can already
depend on the value being of the wrapped type.

Change-Id: Ic3edde45a8f34c31bc164414580d0a1aa5a821d5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2312
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: tazjin <mail@tazj.in>
2021-01-03 15:53:18 +00:00
Profpatsch
e2c7e38934 feat(nix/yants): add unit type
Has one less value than bool.

Change-Id: I2f2db07b1eb1f49172942bc1d8c6ceb30d987d84
Reviewed-on: https://cl.tvl.fyi/c/depot/+/661
Reviewed-by: tazjin <mail@tazj.in>
2020-06-27 20:48:15 +00:00
Vincent Ambo
6e7006c061 docs(nix/yants): Mention Yants subtree split in README
This subtree split makes it possible for people to clone only
yants (similar to the kontemplate and journaldriver branches).

The subtree continues the history of the old git repository.
2020-05-16 12:37:12 +01:00
Vincent Ambo
4bbbb58cb5 chore: Rename pkgs->depot in all Nix file headers 2020-02-21 13:54:53 +00:00
Vincent Ambo
ddc9ee4dcd docs(nix/yants): Fix screenshot URLs
The URLs served on the /about page are relative to the path's dirname,
which is tree/nix not tree/nix/yants.
2020-02-07 19:11:55 +00:00
Vincent Ambo
9885036eec chore(yants): Move tests into subfolder & add to CI builds 2019-12-20 21:53:19 +00:00
Vincent Ambo
902500c4ea fix(yants): Allow extra import arguments
Required for readTree compatibility.
2019-12-20 21:49:00 +00:00
Vincent Ambo
210893ce09 chore(yants): Prepare for depot-merge
Yants is being integrated at //depot/nix/yants
2019-12-20 21:46:59 +00:00