Commit graph

16759 commits

Author SHA1 Message Date
Vincent Ambo
d28d30477a Note that or works for nested attribute access 2020-11-25 13:41:38 +01:00
Vincent Ambo
3236b7ff28 Add small section about or expressions 2020-11-25 13:40:19 +01:00
William Carroll
9549dbb266 Update BFS impls
I've subtly been implementing breadth-first traversals in graphs
incorrectly. The change is subtle, but updating `seen` needs to happen
immediately after queuing an item.

The results will remain the same, but the runtimes will differ dramatically. I
didn't notice this until I attempted to complete LeetCode's "count islands"
challenge, and LeetCode rejected my solution because it could not finish before
timing out. After looking at other candidates' solutions and comparing them to
mine, I couldn't see any difference... except for this subtle difference.

This SO answer provides a helpful explanation:
https://stackoverflow.com/questions/45623722/marking-node-as-visited-on-bfs-when-dequeuing

The take-away lesson here is to always call `seen.add(..)` immediately after
enqueuing.
2020-11-23 23:21:20 +00:00
multi
c56f402383 feat(users/multi/home): add readline configuration and nix-shell handling to bashrc.
This adds my standard inputrc to my home-manager configuration, via the
latter's readline module, and adds nix-shell detection to my bash prompt
string.

Additionally, nix-shell is wrapped in a shell function, so that entering
a nix-shell environment automatically runs bash as a subprocess where
appropriate, as the default environment spawned by nix-shell is not to
my liking.

Change-Id: Id5b1b9415a185ad9920f268c66de32d6ccc0b452
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2146
Reviewed-by: multi <depot@in-addr.xyz>
Tested-by: BuildkiteCI
2020-11-23 18:41:29 +00:00
Griffin Smith
f49c86139f fix(gs/home): Don't override alacritty version
This was only done to get an upgraded version, which is no longer
necessary with the nixpkgs bump but was also causing incompatibilities
with opengl

Change-Id: Ic398b4ac6caf24a1d40b7a4917b5053fba12d97a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2145
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
2020-11-23 16:12:09 +00:00
Vincent Ambo
3d1b116f7f feat(tazjin/rlox): Implement single-character scanning
... still not that interesting, but at this point slightly divergent
from the book:

The book embraces mutability for interpreter state, initially for
tracking whether an error condition has occured.

I avoid this by instead defining an error type and collecting the
error values, to be handled later on.

Notes: So far nothing special, but this is just the beginning of the
book. I like the style it is written in and it has pointed to some
interesting resources, such as a 1965 paper titled "The Next 700
Languages".

Change-Id: I030b38438fec9eb55372bf547af225138908230a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2144
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-11-23 01:15:57 +00:00
Vincent Ambo
9d2b001c4c feat(tazjin/rlox): Add basic program structure
... as well as a Nix derivation, because why not.

Change-Id: Iaf2591ab72676fe0732c3f807b3aa0cff13fb4ef
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2143
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-11-23 01:15:57 +00:00
Vincent Ambo
0618ff11cc feat(tazjin/rlox): Bootstrap program
This is going to be the first of two interpreters from "Crafting
Interpreters".

Change-Id: I354ddd2357444648d0245f35d92176dd176525d8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2142
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-11-23 01:15:57 +00:00
Vincent Ambo
312d76acba feat(tazjin/emacs): Enable midnight.el
Change-Id: I22bedd80c6e99ccefefa7840ec37496360937842
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2137
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-11-22 23:26:57 +00:00
Griffin Smith
24f9354d5b feat(tvix): Support a --quiet argument to nix-build
This is passed by some third-party tools, notably home-manager. At some
point we should fully revamp argument parsing and log verbosity setting,
but for now this gets us to more of a working state

Fixes: b/78
Change-Id: I4134b17315e30145fd43d3659f407d7121ce8876
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2136
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 23:17:23 +00:00
Griffin Smith
9e3f541546 fix(tvix): Add endlines to build log messages
Change-Id: Id6e871a2b7fbb24fb5c8e84e1638bfe94e363b57
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2135
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 23:17:23 +00:00
Griffin Smith
9945bd1746 feat(tvix): Convert some DLOGs to VLOGs
It seems like the amount of logging is causing things to move a little
slower - even if that's not really the case, it gets in the way of
debugging things.

Refs: b/76
Change-Id: I9ea99a3b16e3307a0b0371bad22d03b0e2175af6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2134
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 23:17:23 +00:00
Griffin Smith
64ef09c475 feat(whitby): Move wigglydonke.rs to whitby
Mugwump is too unstable for such an important internet service

Change-Id: Ic714200ce5ce51f366777f538b4a6f443f010960
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2124
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 22:55:49 +00:00
Griffin Smith
9a24294b8a feat(tvix): Add a pos field to more expr classes
To aid in both debugging and (eventually) printing stacktraces, add a
Pos member to a few more Expr variants.

Change-Id: Ic1d2a056fc7e6c07bc3e79fa38845cb4a5da5ca5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2133
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 21:59:58 +00:00
Griffin Smith
9f4d37e5df feat(ops/nixos): Give all nixoses a config.depot
Add the depot.nix module and a depot config option to all nixos system
derivations that're build through the `bin/rebuild-system` machinery.
I can't imagine a scenario where we wouldn't want this level of
integration.

Change-Id: Ieeb98db2eee23919256adb4654bc45d540e055ec
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2128
Tested-by: BuildkiteCI
Reviewed-by: lukegb <lukegb@tvl.fyi>
2020-11-22 21:59:58 +00:00
Griffin Smith
58efa6df5b fix(panettone): Prefix all IRC messages with a ZWSP
Prefix all IRC notifications from panettone with a unicode
zero-width-space so that they don't get picked up by other IRC
bots (notably bslsk05).

Change-Id: I350fd1b6d2145e496c22a8f56ba3530fc9f1a978
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2127
Tested-by: BuildkiteCI
Reviewed-by: lukegb <lukegb@tvl.fyi>
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 21:59:58 +00:00
Griffin Smith
92a1f72f41 feat(panettone): Send notifications when issues are closed
Send an irc notification when issues are marked closed, in a similar
format to the notifications sent when new issues are created.

Change-Id: I2fdde33f0dedc223a5c2265eed778161938f8e9a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2126
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 21:59:58 +00:00
multi
96eac23250 fix(users/multi/home): re-add overridden htop package to home-manager configuration.
I previously removed my local package set from my HM config while the
latter was being made readTree compatible. Now that both the HM config
and the local package set can be built with readTree, I can re-enable
the locally-overridden htop package.

Change-Id: I77e20248c010bc7027e0b0a3164ec48d6ec29f31
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2132
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 20:29:47 +00:00
multi
a5ee01a827 refactor(user/multi/pkgs): make my local package set readTree-compatible.
This adds readTree configuration for accessing my local package set,
and also adds these packages to the CI configuration.

Change-Id: Icd2d16e85859343902e73a466f3c6ba8d781537f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2131
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 20:29:47 +00:00
multi
ba9fb4e112 fix(users/multi/home): use local depot checkout.
This reverts 1478317d149539d74fa4bad8414658fb7119ea07.

Using depot.depotPath in my home-manager configuration results in my
NIX_PATH and home-manager config file path being pointed at a copy of
the depot in the nix store, which makes building from my local depot
checkout a bit cumbersome.

Change-Id: Ib687d3e8147cb32df071d3c19a5300294ea62c0c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2130
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 20:29:47 +00:00
multi
7ff2142f19 refactor(users/multi): migrate whitby home-manager config to readTree-compatible version.
Add a new home-manager-compatible configuration file which loads the
common config attrset used by the readTree machinery into a structure
which the home-manager command line tool understands.

Garbage-collect the old home-manager configuration file used on whitby,
and update the HOME_MANAGER_CONFIG path to point at the new shim config.

Instead of having a per-environment HM configuration (not that I have
more than one environment), there's now a single configuration which
evaluates to an attrset of configurations, which can be loaded and built
using "home-manager build -A $attr".

Change-Id: Id8b35dc89aabffedf1a4dadfa0d3d4b914e4e2e7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2129
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 20:29:47 +00:00
multi
69244064da refactor(users/multi): make my user directory CI-compatible.
My home-manager config is not currently readTree compatible, which means
that it's not built by CI. This constructs a house of cards around
home-manager to make this buildable in CI.

Change-Id: I80480f24ff47347f46d708edbbf34d59fa76adac
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2123
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 19:48:15 +00:00
multi
9d6d945f52 refactor(users/multi/whitby): use the depot's own source location attribute.
The depot knows where it is, not because it knows where it isn't, but
because it does an "import ./." at the top level and then makes this
path value available in the attrset passed to the rest of the tree.

My home-manager config on whitby previously involved manual
specification of the depot checkout location on whitby, however this
isn't necessary when the depot can already magically tell us where it
is.

Change-Id: I68577c8ef2cda6ba5bc46cf8f4821aac021c8066
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2122
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 19:48:15 +00:00
Griffin Smith
1e43982c92 feat(panettone): Bring back + fix irccat issue creation announcement
This reverts commit e1067b1497.

The original issue here was misusing ISSUE-ID instead of ID, but also
the associated username for the message should've been CN instead of DN

Change-Id: I1629c0cb7597ff2ee2867f27870378eecdafe126
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2125
Tested-by: BuildkiteCI
Reviewed-by: eta <eta@theta.eu.org>
2020-11-22 18:57:44 +00:00
multi
7dcd518c35 fix(users/multi/whitby): fix home-manager configuration on whitby.
"let pkgs = import <nixpkgs> {}; in pkgs.home-manager.src" evaluates to
the source derivation for home-manager, however home-manager's configuration
machinery expects to be passed the store path of this derivation instead of the
derivation object itself.

Change-Id: I6b0ba3efaff9d080900349529576443192b058e9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2121
Reviewed-by: multi <depot@in-addr.xyz>
Tested-by: BuildkiteCI
2020-11-21 23:42:34 +00:00
Vincent Ambo
5a00e58904 chore(3p): Bump nixpkgs to nixos-unstable from 2020-11-21
Included fixes for random breakage:

* 3p/awscli: pick from the stable channel; it is broken on unstable
* 3p/googletest: bumped version & removed patches that nixpkgs applies
* 3p/lisp/cffi: bumped library version for SBCL compat
* 3p/nix: fix libsystemd attribute
* 3p/nix: reformatted (clang-format handling of ternaries changed)
* glittershark/home: Use home-manager from nixkpgs
* glittershark/kernel: bumped linux-ck patch hash
* glittershark/kernel: removed "patch patch"
* multi/whitby: Use home-manager from nixpkgs
* tazjin/frog: drop Sourcetrail (it doesn't build currently)

Note that in addition to these changes, some previous CLs updated the
versions of git and cgit which was necessary for this channel bump,
but which could not be done in the same commit due to the nature of
the subtree merges.

Change-Id: If2563e8a68e2750c4b913a976ff7b93b42e8b7f3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2110
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
Reviewed-by: glittershark <grfn@gws.fyi>
2020-11-21 23:18:27 +00:00
Vincent Ambo
e908882610 fix(glittershark/kernel): Ensure kernel changes cachebust linux-ck
Previously changed kernel versions would not cachebust the patch
download, because it would still be using the same SHA hash.

Forcing a different store path (by adding the version to the name)
also forces a redownload of the patch (and in turn cause the hash to
mismatch), avoiding this as a silent cause of failures in channel
updates.

Change-Id: I81a136ee2401126795cf042b0aadf2a1e7a707b4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2114
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
2020-11-21 23:18:27 +00:00
Vincent Ambo
cd652b3b22 fix(3p/cgit): Rename remaining 'sha1' references to 'oid'
This changed upstream & upstream-upstream, but was still used in our
patches.

Change-Id: Id33f868a4f188deb3348425276bc5b4c4b36aff9
2020-11-21 20:09:42 +01:00
Vincent Ambo
1e81ce6622 merge(3p/cgit): subtree merge at adcc4f82
Change-Id: I16941629a17a2f39b9324cb85dc0cec6b104dfe4
2020-11-21 20:09:33 +01:00
Vincent Ambo
f4609b896f merge(3p/git): Merge git subtree at v2.29.2
This also bumps the stable nixpkgs to 20.09 as of 2020-11-21, because
there is some breakage in the git build related to the netrc
credentials helper which someone has taken care of in nixpkgs.

The stable channel is not used for anything other than git, so this
should be fine.

Change-Id: I3575a19dab09e1e9556cf8231d717de9890484fb
2020-11-21 19:45:56 +01:00
William Carroll
c00eed469c Solve "cafe order checker" (again)
Perhaps my fifth iteration of solving this problem.
2020-11-21 16:31:53 +00:00
William Carroll
6ccdb06717 Solve "permutation palindrome" (again)
Python's `collections` library really shines for this problem.
2020-11-21 16:24:14 +00:00
William Carroll
60d7ea5b91 Implement a queue using two stacks
The space cost is O(n). The runtime cost of enqueue is O(1); the runtime cost of
dequeue is O(n). Using the "accounting method", the cost of an item in the
system is O(1). Here's why:

+------------+----------------------------+------+
| enqueue    | push onto lhs              | O(1) |
+------------+----------------------------+------+
| lhs -> rhs | pop off lhs; push onto rhs | O(1) |
+------------+----------------------------+------+
| dequeue    | pop off rhs                | O(1) |
+------------+----------------------------+------+
2020-11-21 16:15:43 +00:00
Vincent Ambo
082c006c04 merge(3p/absl): subtree merge of Abseil up to e19260f
... notably, this includes Abseil's own StatusOr type, which
conflicted with our implementation (that was taken from TensorFlow).

Change-Id: Ie7d6764b64055caaeb8dc7b6b9d066291e6b538f
2020-11-21 15:48:57 +01:00
William Carroll
417d3b5fff Implement a bottom-up fibonacci
The bottom-up solution run in O(n) time instead of O(2^n) time, which the
recursive solution runs as:

```
def fib(n):
    return fib(n - 2) + fib(n - 1)
```

Remember that exponential algorithms are usually recursive algorithms with
multiple sibling calls to itself.
2020-11-21 14:48:12 +00:00
William Carroll
70e74a4027 Solve "linked-list-cycles"
Write a predicate for checking if a linked-list contains a cycle. For additional
practice, I also implemented a function that accepts a linked-list containing a
cycle and returns the first element of that cycle.
2020-11-21 14:47:18 +00:00
Vincent Ambo
cc27324d02 chore(tvix): Use StatusOr API available in Abseil's version
The Abseil version of `StatusOr` does not come with the status macros
or the `Consume*` family of functions.

This change modifies the existing code to use the common denominator
of the API that is available between Abseil's own implementation of
`StatusOr` and the one from Tensorflow that we are currently using.

Change-Id: I5c37f68636a1fd54d153f95d7303ab8644abb774
2020-11-21 15:26:02 +01:00
William Carroll
cbdac30643 Reimplement bst-checker
Practice makes perfect. See the previous commit for a more details about this
solution.
2020-11-21 14:21:05 +00:00
William Carroll
2b5bbb98ca Refactor existing bst-checker implementation
I believe the previous solution is invalid. This solution works and it should be
more time and space efficient.

Space-wise our stack grows proportionate to the depth of our tree, which for a
"balanced" BST should be log(n). Doing a BFT on a BST results in memory usage of
n because when we encounter the leaf nodes at the final level in the tree, they
will be 1/2 * n for a balanced BST.
2020-11-21 14:14:50 +00:00
William Carroll
1dc6695a47 Solve merge-sorted-arrays (again)
InterviewCake.com has a section on Facebook's interview, so I'm attempting to
solve all of the problems on there even if that means I'm resolving
problems. The more practice, the better. Right?

URL: interviewcake.com/facebook-interview-questions
2020-11-21 13:41:33 +00:00
William Carroll
0ccaa22032 Solve "find duplicate" using a graph
This problem is unusually difficult, but the solution is elegant.
2020-11-21 13:35:05 +00:00
Vincent Ambo
cce0ad1bcd chore(tazjin/emacs): Minor cleanup of unused modes and config
Change-Id: I38c6a32339bf7606b733a938b4e55df2506a13a7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2107
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-11-21 13:27:20 +00:00
William Carroll
847aad2a14 Implement the Levenstein "edit distance" algorithm
This is the mother of dynamic programming algorithms in my opinion. It computes
the minimal "edit distance" between two input strings where an edit is
considered one of:
  - inserting a character into `a`
  - deleting a character from `a`
  - substituting a character in `a` with a character from `b`

It took me awhile to grok the algorithm, but I implemented this from my
understanding of something that I read ~3 nights prior, so I must've understood
what I read. Good news!
2020-11-20 21:59:18 +00:00
William Carroll
f652ea0be6 Solve "count islands" problem
This morning, I attended the "Interview Club" and was asked this question by the
interviewer in front of ~20 FTEs. While I struggled to fully solve it during the
abridged (i.e. 20 minute) timeslot, I completed the problem afterwards.

Here is my solution.
2020-11-20 21:32:22 +00:00
William Carroll
fa717e8a6f Re-implement suffix_tree function
Create a suffix tree from an input string. This implementation uses a stack to
control the flow of the program.

I expected this attempt to be easier than my first attempt, but surprisingly, it
was similarly difficult. It took me ~30-45 minutes to successfully implement
this function, and I'm still not pleased with the final result.
2020-11-19 21:12:36 +00:00
William Carroll
1088e4143d Implement a suffix tree
While it took me awhile to implement, this exercise was definitely worth
doing. I think there should be a more elegant way to construct the tree using
maybe a stack, but I couldn't find it.

All of this was part of a larger effort to search a string for a variety of
patterns. The solution is to compile the string into a suffix tree and then
search the suffix tree for each of the patterns.

I'm glad I didn't gloss over this exercise.
2020-11-19 00:35:23 +00:00
Griffin Smith
8d24a975f1 fix(tvix): Use copy constructor to add strings to protos
Passing a string directly to add_paths like this causes the proto class
to take ownership over the string, meaning when it is destructed it
will *explicitly* free the string. When the string's actual owner (the
derivation struct) then goes out of scope it'll get freed again, causing
a double-free. This fixes that to instead use the copy constructor to
assign to a pointer to a new path, and covers the whole to_proto method
with a rapidcheck test.

Fixes: b/64
Change-Id: I84235bed9104ff430a0acf686d4a96f1e2e9a897
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2106
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-11-19 00:29:42 +00:00
Griffin Smith
20e206a3f6 fix(tvix): Use mutable field for assigning proto fields
This was accidentally using the proto arena API to assign the derivation
field of a BuildDerivationRequest. We *thought* this was causing a
double free, but even with this change that's still happening. That
said, this change is probably still a good idea since it's using the
proto API as intended.

References: b/64
Change-Id: I950a4eafb214e9113639ea54d2dfd4659b7be931
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2104
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-19 00:29:42 +00:00
glittershark
e1067b1497 revert(panettone): announce newly created issues using irccat
This reverts commit 2e2bdf9c6c.

Reason for revert: this is not working, and is resulting in newly created issues just showing a blank page (b/74)

Change-Id: I3f06afc52d6c5289269402fc75bb32ad9c376bf4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2082
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-19 00:29:28 +00:00
multi
4331bc8da7 chore(users/multi): Update htop derivation for new upstream.
- htop has moved upstreams, which has been producing new releases, so
  update the derivation to pull from the new repository on GitHub.

- All of the patches I have locally have been merged upstream, so drop
  them from the depot.

- Pull from a reasonably recent git commit instead of from a numbered
  release, as the ZFS ARC stats and CPU meter columnation patches
  haven't made it into a release yet.

Change-Id: I66ad4c035df07709abf4f75a9d4e1486920091d0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2105
Reviewed-by: multi <depot@in-addr.xyz>
Tested-by: BuildkiteCI
2020-11-18 00:29:58 +00:00