1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# The top-level package set of this repository.
#
# This is Profpatsch's home-repo, extracted from the TVL depot.
#
# The layout is governed by two rules (see //README.md):
#
# 1. `<dir>/default.nix` -- this directory IS a package. It is a function
# taking `{ depot, pkgs, lib, ... }`.
# 2. `<dir>/packages.nix` -- this directory is a NAMESPACE. It names its
# contents explicitly.
#
# A directory that no `packages.nix` names is not part of the package tree.
# There is no filesystem traversal: to find out where an attribute comes from,
# follow the `import`s starting here.
{ nixpkgsBisectPath ? null
, nixpkgsConfig ? { }
, localSystem ? builtins.currentSystem
, crossSystem ? null
# The nixpkgs to build the depot against, passed as `nixpkgsSrc`.
#
# `flake.nix` passes its own `nixpkgs` input, so that a flake-based
# evaluation uses exactly one nixpkgs. The default below resolves the very
# same revision out of `flake.lock`, so that a plain `import ./. { }` (and
# thus `nix-build -A …`, `nix-shell`, …) agrees with the flake instead of
# silently using a second, independently pinned package set.
, ...
}@args:
let
# Resolve nixpkgs from the flake lock file, which is the single source of
# truth for which revision this repository is built against.
nixpkgsSrc = args.nixpkgsSrc or (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
node = lock.nodes.${lock.nodes.${lock.root}.inputs.nixpkgs}.locked;
in
builtins.fetchTree { inherit (node) type owner repo rev narHash; }
);
fix = f: let x = f x; in x;
# The arguments every package in this repository is called with.
depotArgsFor = self: {
inherit localSystem crossSystem nixpkgsSrc;
depot = self;
# Pass third_party as 'pkgs' (for compatibility with external
# imports for certain subdirectories)
pkgs = self.third_party.nixpkgs;
# Expose lib attribute to packages.
lib = self.third_party.nixpkgs.lib;
# Pass arguments passed to the entire depot through, for packages
# that would like to add functionality based on this.
#
# Note that it is intended for exceptional circumstance, such as
# debugging by bisecting nixpkgs.
externalArgs = args;
};
in
fix (self:
let
depotArgs = depotArgsFor self;
lib = self.third_party.nixpkgs.lib;
in
{
nix = import ./nix/packages.nix depotArgs;
third_party = import ./third_party/packages.nix depotArgs;
users = import ./users/packages.nix depotArgs;
# Make the path to the home-repo available for things that might need it
# (e.g. NixOS module inclusions)
path = lib.cleanSourceWith {
name = "home-repo";
src = ./.;
filter = lib.cleanSourceFilter;
};
})
|