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,38 +1,17 @@
# 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> {} {
pkgs = import <nixpkgs> {};
# Global configuration that all packages are called with. depot = import <depot> {};
config = self: {
inherit self;
pkgs = import <nixpkgs> {};
depot = import <depot> {};
briefcase = import <briefcase> {}; briefcase = import <briefcase> {};
}; };
in {
readTree' = import <depot/nix/readTree> {}; nixos = readTree ./nixos;
blog = readTree ./blog;
# TODO: Find a better way to expose entire monorepo without introducing lisp = readTree ./lisp;
# "infinite recursion". gopkgs = readTree ./gopkgs;
localPkgs = readTree: { monzo_ynab = readTree ./monzo_ynab;
nixos = readTree ./nixos; third_party = readTree ./third_party;
blog = readTree ./blog; tools = readTree ./tools;
lisp = readTree ./lisp;
gopkgs = readTree ./gopkgs;
monzo_ynab = readTree ./monzo_ynab;
third_party = readTree ./third_party;
tools = readTree ./tools;
};
in fix(self: {
config = config self;
} }
# Add local packages as structured by readTree
// (localPkgs (readTree' (self.config // { inherit (self) lib; })))
)