refactor(ops/nixos): add "depot" argument to NixOS modules

For the moment I've opted to not import all of the other things we'd
usually provide to things imports via readTree, because I think it's a
bit dangerous to accidentally overwrite things like NixOS' notion of
"lib" with our own version.

So for the moment, baseModule provides only "depot".

Change-Id: I3db9132a3d9227055d4c1b00f02effcb84edcc53
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2760
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
Luke Granger-Brown 2021-04-02 12:13:08 +00:00 committed by lukegb
parent dc9a1754d5
commit 4bfcd09682

View file

@ -19,16 +19,24 @@ rec {
allSystems = import ./all-systems.nix args;
nixosFor = configuration: depot.third_party.nixos {
configuration = {
inherit depot;
imports = [
configuration
"${depot.depotPath}/ops/nixos/depot.nix"
];
# This provides our standard set of arguments to all NixOS modules.
baseModule = { ... }: {
_module.args = {
inherit (args) depot;
};
};
nixosFor = configuration: (depot.third_party.nixos {
configuration = { ... }: {
imports = [
baseModule
"${depot.depotPath}/ops/nixos/depot.nix" # TODO(lukegb): remove this once config.depot is no longer referenced.
configuration
];
config.depot = depot;
};
});
findSystem = hostname:
(findFirst
(system: system.config.networking.hostName == hostname)