about summary refs log tree commit diff
path: root/nix/readTree (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-02-19 r/2224 feat(nix/readTree): give better error message when not a functionProfpatsch4-1/+27
When a file is added to the depot tree that is picked up by read-tree, but it’s not a function like ({...}: {}), `readTree` will fail on the function application, leading to a bad error message. We can do slightly better, by checking the type and throwing a nicer trace message. `assertMsg` is copied from `nixpkgs/lib/assert.nix`, since at this point we don’t have a reference to the lib. There is another evaluation failure that can happen, which is when the function we try to call does not have dots; however, nix does not provide any inflection capabilies for checking whether a function attrset is open (`builtins.functionArgs` only tells us the attrs it mentions explicitly). Maybe the locality of the error could be improved somehow. Change-Id: Ibe38ce78bb56902075f7c31f2eeeb93485b34be3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2469 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2021-02-18 r/2218 fix(nix/readTree): make nixFileName only match .nix extensionssterni1-1/+1
Nix unfortunately has terrible escaping syntax: If something is an escape sequence it does not know, like \0, it just swallows the backslash and returns the second character (byte) as is (yes, "\0" == "0" is true). This created the following bug in nixFileName which should have resulted in at least a parse error: "(.*)\.nix" is the same as "(.*).nix" which meant that nixFileName matched anything that is at least 4 characters long and ends in "nix". This lead to readTree creating double attributes when directories are involved or attributes for non-nix files. Change-Id: Ibf3be2bd189d48881c82ee795c50151bfb365627 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2535 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-01-30 r/2165 feat(nix/readTree): add tests of the traversal logic in READMEProfpatsch15-1/+95
This should closely match the documented behaviour. It might still be missing some edge cases of course. Change-Id: I5c75fa045d5f3be8cf5eab787a02644500c14522 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2466 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-01-30 r/2164 feat(nix/readTree): add tests of the README exampleProfpatsch7-0/+47
First step to slowly giving readTree some coverage, so we can do refactoring without breaking functionality. Change-Id: If25a8c0fa9c4ac7472c0473372f10a9326cccaf7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2465 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-01-30 r/2163 chore(nix/readTree): move function into __functorProfpatsch1-12/+13
We are going to export some tests under `nix.readTree.tests`, so in order to do that and still have `nix.readTree` be a function, let’s move it to `__functor`. This requires wiring the `args` and `initPath` arguments through explicitly. Change-Id: Ife7956b85d35e59c22174b42dcb7cca83ed868ea Reviewed-on: https://cl.tvl.fyi/c/depot/+/2464 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-08-31 r/1742 feat(readTree): Use tree location as the value of `__readTree`Vincent Ambo1-2/+8
Change-Id: I6a087279b5d819db475f2179cb77c0f55cbd0ac6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1860 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: lukegb <lukegb@tvl.fyi>
2020-08-26 r/1719 fix(readTree): Add __readTree attribute to foldersVincent Ambo1-1/+1
This is required to automatically walk the tree (see subsequent commits). Note: Lisp packages are removed from the CI builds in this commit because the attrValues of third_party.lisp will contain an element that is simply `true`, which causes a type error. These packages are re-added when CI refactoring is complete. Change-Id: I21e2b719e6c7161c23d2867a216f4daa1c6c8394 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1848 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-08-04 r/1586 feat(nix/readTree): allow arguments to depend on tree locationedef1-3/+3
This accepts a function for args, and passes it an attrset containing the locatedAt parameter. Change-Id: I3c0f8ca00605e02a787fda88f32b06f5ef9998f2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1639 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2020-06-13 r/939 fix(nix/readTree): Ignore hidden files and directoriesedef1-3/+14
This skips any directory entries starting with a dot. Change-Id: I95767f3d35bcb2ed9b3d6e772f3924dd57612711 Reviewed-on: https://cl.tvl.fyi/c/depot/+/123 Reviewed-by: tazjin <mail@tazj.in>
2019-12-21 r/280 docs(nix/readTree): Add a very descriptive README for readTreeVincent Ambo1-0/+81
2019-12-21 r/279 refactor(nix/readTree): Move readTree to its own subfolderVincent Ambo1-0/+63