Simpify top-level nix expression

When I first created the monorepo, I borrowed @tazjin's monorepo's. I adapted
his depot/default.nix, replacing some of his paths with my paths. This worked
for me until recently.

I attemped to include <briefcase/monzo_ynab/job> as a systemd unit for my NixOS
machine, socrates. NixOS failed to build my changes, and I didn't fully
understand my default.nix since I borrowed most of it from @tazjin. I spent the
past week looking at the `fix` function. I realized that I didn't fully
understand how fixed-point recursion worked. This sent me down a rabbit hole
terminating with me studying the Y and Z combinators.

Ironically, after understanding the `fix` function, I realized that I didn't
need to use it where I was consuming it. I ended up pruning most of my
configuration, which resulted in this commit.

Yours truly,
lambda f: (lambda x: f(x(x)))(lambda x: f(x(x)))
This commit is contained in:
William Carroll 2020-03-01 22:16:07 +00:00
parent b4689761d9
commit 42c6ad3bb4

View file

@ -1,26 +1,12 @@
# At the time of this writing, this configuration was taken from @tazjin's { ... }:
# default.nix from his depot. I've added, changed, and removed that parts that I
# don't need, and this is what remains.
{ ... }@args:
with builtins;
let let
fix = f: let x = f x; in x; readTree = import <depot/nix/readTree> {} {
# Global configuration that all packages are called with.
config = self: {
inherit self;
pkgs = import <nixpkgs> {}; pkgs = import <nixpkgs> {};
depot = import <depot> {}; depot = import <depot> {};
briefcase = import <briefcase> {}; briefcase = import <briefcase> {};
}; };
in {
readTree' = import <depot/nix/readTree> {};
# TODO: Find a better way to expose entire monorepo without introducing
# "infinite recursion".
localPkgs = readTree: {
nixos = readTree ./nixos; nixos = readTree ./nixos;
blog = readTree ./blog; blog = readTree ./blog;
lisp = readTree ./lisp; lisp = readTree ./lisp;
@ -28,11 +14,4 @@ let
monzo_ynab = readTree ./monzo_ynab; monzo_ynab = readTree ./monzo_ynab;
third_party = readTree ./third_party; third_party = readTree ./third_party;
tools = readTree ./tools; tools = readTree ./tools;
};
in fix(self: {
config = config self;
} }
# Add local packages as structured by readTree
// (localPkgs (readTree' (self.config // { inherit (self) lib; })))
)