nixops/seattle/flake.nix

78 lines
2.0 KiB
Nix
Raw Normal View History

2021-10-05 22:07:16 -07:00
{
description = "Definition of the Seattle NixOps network.";
inputs = {
nixpkgs.url = "nixpkgs/nixos-21.05";
2021-10-08 15:23:56 -07:00
fudo-home.url = "path:../fudo-home";
2021-10-05 22:07:16 -07:00
fudo-secrets.url = "path:/state/secrets";
2021-10-08 15:23:56 -07:00
fudo-pkgs.url = "path:../fudo-pkgs";
2021-10-05 22:07:16 -07:00
# fudo-pkgs.url = "path:/state/nixos/fudo-pkgs";
fudo-nixos = {
2021-10-08 15:23:56 -07:00
url = "path:../fudo-nixos";
2021-10-05 22:07:16 -07:00
# Don't import it as a flake
flake = false;
};
};
2021-10-08 15:23:56 -07:00
outputs = { self, nixpkgs, fudo-home, fudo-nixos, fudo-pkgs, fudo-secrets, ... }: let
2021-10-05 22:07:16 -07:00
domain = "sea.fudo.org";
2021-10-08 15:23:56 -07:00
site = "seattle";
2021-10-05 22:07:16 -07:00
2021-10-08 15:23:56 -07:00
build-timestamp = self.sourceInfo.lastModified;
2021-10-05 22:07:16 -07:00
2021-10-08 15:23:56 -07:00
hostlib = import (fudo-nixos + /lib/hosts.nix) { lib = nixpkgs.lib; };
2021-10-05 22:07:16 -07:00
2021-10-08 15:23:56 -07:00
hosts = nixpkgs.lib.filterAttrs (hostname: hostOpts:
hostOpts.nixos-system && hostOpts.site == site)
2021-10-05 22:07:16 -07:00
(hostlib.base-host-config (fudo-nixos + /config/hosts));
2021-10-08 15:23:56 -07:00
network-hosts = (import (fudo-nixos + /config/networks/${domain}.nix)).hosts;
2021-10-05 22:07:16 -07:00
pkgs-for = system: import nixpkgs {
inherit system;
config = {
allowUnfree = true;
permittedInsecurePackages = [
"openssh-with-gssapi-8.4p1"
];
};
overlays = [
2021-10-08 15:23:56 -07:00
fudo-pkgs.overlay
(import (fudo-nixos + "/lib/overlay.nix"))
2021-10-05 22:07:16 -07:00
];
};
initialize-host = import (fudo-nixos + /initialize.nix);
in {
nixopsConfigurations.default = {
inherit nixpkgs;
network = {
description = "Seattle NixOps network.";
enableRollback = true;
};
2021-10-08 15:23:56 -07:00
} // (nixpkgs.lib.mapAttrs (hostname: hostOpts: let
system = hostOpts.arch;
profile = hostOpts.profile;
in { config, pkgs, lib, ... }: {
imports = [
2021-10-05 22:07:16 -07:00
fudo-home.nixosModule
fudo-secrets.nixosModule
(initialize-host {
2021-10-08 15:23:56 -07:00
inherit hostname build-timestamp site domain profile config pkgs lib;
2021-10-05 22:07:16 -07:00
})
];
2021-10-08 15:23:56 -07:00
nixpkgs.pkgs = pkgs-for system;
deployment.targetHost = network-hosts.${hostname}.ipv4-address;
}) hosts);
2021-10-05 22:07:16 -07:00
};
}