Update the tvix cli's -I option so that it aligns more closely with
nix's behavior: prepending entries to the list of lookup paths provided
by the NIX_PATH environment variable. Before this commit, using the -I
option would instead override and ignore the NIX_PATH variable.
Additionally, update the option's long name and help text to match the
new behavior.
While the tvix cli's interface does not appear to be attempting to mimic
nix exactly, I think this particular case of the -I option's diverging
behavior will inevitably surprise users because it's name, presumably
short for "include" and being similar to gcc's flag, evokes additivity.
The prior implementation hinted at this difference with the help text
and the long name, --nix-search-path, but I still suspect users will be
confused on first usage (at least I was). If we're willing to pay the
maintenance costs of additional code, we can avoid this and provide a
slightly smoother user experience.
Changes were tested by buiding the tvix cli, adding it to the PATH, and
executing simple tests as in the following bash script
mg build //tvix/cli
PATH="$PWD/result/bin:$PATH"
one=$(mktemp) && echo "=> $one :: path" > "$one"
two=$(mktemp) && echo "=> $two :: path" > "$two"
dir1=$(mktemp -d) && file1="$dir1/file1" && echo "=> $file1 :: path" > "$file1"
dir2=$(mktemp -d) && file2="$dir2/file2" && echo "=> $file2 :: path" > "$file2"
# NIX_PATH works with a single non-prefixed lookup path.
NIX_PATH="$dir1" tvix -E "<file1>" | cmp - "$file1"
# NIX_PATH works with multiple non-prefixed lookup paths.
NIX_PATH="$dir1:$dir2" tvix -E "<file2>" | cmp - "$file2"
# NIX_PATH works with a single prefixed lookup path.
NIX_PATH="one=$one" tvix -E "<one>" | cmp - "$one"
# NIX_PATH works with multiple prefixed lookup paths.
NIX_PATH="one=$one:two=$two" tvix -E "<one>" | cmp - "$one"
NIX_PATH="one=$one:two=$two" tvix -E "<two>" | cmp - "$two"
# NIX_PATH first entry takes precedence.
NIX_PATH="one=$one:one=$two" tvix -E "<one>" | cmp - "$one"
# The -I option works with a single non-prefixed lookup path.
tvix -I "$dir1" -E "<file1>" | cmp - "$file1"
# The -I option works with multiple non-prefixed lookup paths.
tvix -I "$dir1" -I "$dir2" -E "<file2>" | cmp - "$file2"
# The -I option works with a single prefixed lookup path.
tvix -I "one=$one" -E "<one>" | cmp - "$one"
# The --extra-nix-path option works with a single prefixed lookup path.
tvix --extra-nix-path "one=$one" -E "<one>" | cmp - "$one"
# The -I options works when passed multiple times with prefixed lookup paths.
tvix -I "one=$one" -I "two=$two" -E "<one>" | cmp - "$one"
tvix -I "one=$one" -I "two=$two" -E "<two>" | cmp - "$two"
# The first -I option takes precedence.
tvix -I "one=$one" -I "one=$two" -E "<one>" | cmp - "$one"
# Both NIX_PATH and the -I option work together and are additive.
NIX_PATH="one=$one" tvix -I "two=$two" -E "<one>" | cmp - "$one"
NIX_PATH="one=$one" tvix -I "two=$two" -E "<two>" | cmp - "$two"
# The -I option takes precedence over NIX_PATH.
NIX_PATH="one=$one" tvix -I "one=$two" -E "<one>" | cmp - "$two"
rm "$one"
rm "$two"
rm "$file1" && rmdir "$dir1"
rm "$file2" && rmdir "$dir2"
The above script assumes it's being run from inside the depot.
Change-Id: I153e6de57939c0eeca1f9e479d807862ab69b2de
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13189
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
|
||
|---|---|---|
| .gcroots | ||
| .nixery | ||
| corp | ||
| docs | ||
| fun | ||
| lisp | ||
| net | ||
| nix | ||
| ops | ||
| third_party | ||
| tools | ||
| tvix | ||
| users | ||
| views | ||
| web | ||
| .envrc | ||
| .git-blame-ignore-revs | ||
| .gitignore | ||
| .gitreview | ||
| .hgignore | ||
| .mailmap | ||
| .rgignore | ||
| buf.gen.yaml | ||
| buf.yaml | ||
| default.nix | ||
| LICENSE | ||
| OWNERS | ||
| README.md | ||
| RULES | ||
| rustfmt.toml | ||
depot
This repository is the monorepo for the community around The Virus Lounge, containing our personal tools and infrastructure. Everything in here is built using Nix.
A large portion of the software here is very self-referential, meaning that it exists to sustain the operation of the repository. This is the case because we partially see this as an experiment in tooling for monorepos.
Highlights
Services
-
Source code can be viewed primarily via
cgit-pinkon code.tvl.fyi, with code search being available through Livegrep on grep.tvl.fyi.The repository can be cloned using
gitfromhttps://cl.tvl.fyi/depot. -
All code in the depot, with the exception of code that is checked in to individual
//usersfolders, needs to be reviewed. We use Gerrit on cl.tvl.fyi for this. -
Issues are tracked via our own issue tracker on b.tvl.fyi. Its source code lives at
//web/panettone/. -
Smaller todo-list entries which do not warrant a separate issue are listed at todo.tvl.fyi.
-
We use Buildkite for CI. Recent builds are listed on tvl.fyi/builds and pipelines are configured dynamically via
//ops/pipelines. -
A search service that makes TVL services available via textual shortcuts is available: atward
All services that we host are deployed on NixOS machines that we manage. Their
configuration is tracked in //ops/{modules,machines}.
Nix
//nix/readTreecontains the Nix code which automatically registers projects in our Nix attribute hierarchy based on their in-tree location//tools/nixerycontains the source code of Nixery, a container registry that can build images ad-hoc from Nix packages//nix/yantscontains Yet Another Nix Type System, which we use for a variety of things throughout the repository//nix/buildGoimplements a Nix library that can build Go software in the style of Bazel'srules_go. Go programs in this repository are built using this library.//nix/buildLispimplements a Nix library that can build Common Lisp software. Currently only SBCL is supported. Lisp programs in this repository are built using this library.//web/blogand//web/atom-feed: A Nix-based static site generator which generates the web page and Atom feed for tazj.in (//users/tazjin/homepage) and tvl.fyi (//web/tvl)//web/bubblegumcontains a CGI-based web framework written in Nix.//nix/nint: A shebang-compatible interpreter wrapper for Nix.//tvixcontains initial work towards a modular architecture for Nix.
We have a variety of other tools and libraries in the //nix folder which may
be of interest.
Packages / Libraries
//net/alcoholic_jwtcontains an easy-to-use JWT-validation library for Rust//net/crimpcontains a high-level HTTP client using cURL for Rust//tools/emacs-pkgscontains various useful Emacs libraries, for example:dottime.elprovides dottime in the Emacs modelinenix-util.elprovides editing utilities for Nix filesterm-switcher.elis an ivy-function for switching between vterm bufferstvl.elprovides helper functions for interacting with the TVL monorepo
//lisp/klatreprovides a grab-bag utility library for Common Lisp
User packages
Contributors to the repository have user directories under
//users, which can be used for
personal or experimental code that does not require review.
Some examples:
//users/aspen/xanthous: A (WIP) TUI RPG, written in Haskell.//users/tazjin/emacs: tazjin's Emacs & EXWM configuration//users/tazjin/finito: A persistent finite-state machine library for Rust.
Licensing
Unless otherwise stated in a subdirectory, all code is licensed under the MIT license. See LICENSE for details.
Contributing
If you'd like to contribute to any of the tools in here, please check out the contribution guidelines and our code of conduct.
IRC users can find us in #tvl on hackint, which is also
reachable via XMPP at #tvl@irc.hackint.org (sic!).
Hackint also provide a web chat.