Working 'flakified' nixops deploy!
This commit is contained in:
@@ -9,8 +9,9 @@
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
# This MUST be a clean git repo, because we use the timestamp.
|
||||
fudo-entities = {
|
||||
url = "path:/state/fudo-entities";
|
||||
url = "git+https://git.fudo.org/nix/fudo-entities.git";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
@@ -22,27 +23,19 @@
|
||||
fudo-pkgs.url = "path:/state/nixops/fudo-pkgs";
|
||||
|
||||
fudo-secrets.url = "path:/state/secrets";
|
||||
|
||||
deploy-rs = {
|
||||
url = "github:serokell/deploy-rs";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self,
|
||||
nixpkgs,
|
||||
deploy-rs,
|
||||
fudo-home,
|
||||
fudo-lib,
|
||||
fudo-entities,
|
||||
fudo-pkgs,
|
||||
fudo-secrets,
|
||||
... }:
|
||||
... } @ inputs:
|
||||
with nixpkgs.lib;
|
||||
let
|
||||
sys-lib = import ./lib/system.nix { lib = nixpkgs.lib; };
|
||||
|
||||
fudo-nix-hosts = filterAttrs
|
||||
fudo-nixos-hosts = filterAttrs
|
||||
(hostname: hostOpts: hostOpts.nixos-system)
|
||||
(fudo-entities.entities.hosts);
|
||||
|
||||
@@ -59,51 +52,70 @@
|
||||
overlays = [
|
||||
fudo-lib.overlay
|
||||
fudo-pkgs.overlay
|
||||
deploy-rs.overlay
|
||||
];
|
||||
};
|
||||
in {
|
||||
nixosConfigurations = let
|
||||
in mapAttrs (hostname: hostOpts: let
|
||||
system = hostOpts.arch;
|
||||
site = hostOpts.site;
|
||||
domain = hostOpts.domain;
|
||||
profile = hostOpts.profile;
|
||||
in nixosSystem {
|
||||
inherit system;
|
||||
|
||||
modules = let
|
||||
config-path = ./config;
|
||||
in [
|
||||
common-host-config = hostname: hostOpts: let
|
||||
config-dir = ./config;
|
||||
build-timestamp = toInt fudo-entities.lastModifiedDate;
|
||||
in { config, ... }: {
|
||||
imports = [
|
||||
fudo-home.nixosModule
|
||||
fudo-secrets.nixosModule
|
||||
fudo-lib.nixosModule
|
||||
fudo-entities.nixosModule
|
||||
|
||||
({ config, ... }: let
|
||||
network-hosts = config.fudo.networks.${domain}.hosts;
|
||||
./config
|
||||
(config-dir + /hardware/${hostname}.nix)
|
||||
(config-dir + /host-config/${hostname}.nix)
|
||||
(config-dir + /profile-config/${hostOpts.profile}.nix)
|
||||
(config-dir + /domain-config/${hostOpts.domain}.nix)
|
||||
(config-dir + /site-config/${hostOpts.site}.nix)
|
||||
];
|
||||
|
||||
config = {
|
||||
instance = let
|
||||
build-seed = builtins.readFile
|
||||
config.fudo.secrets.files.build-seed;
|
||||
in {
|
||||
imports = [
|
||||
./config
|
||||
fudo-entities.nixosModule
|
||||
(config-path + /hardware/${hostname}.nix)
|
||||
] ++ (filter pathExists
|
||||
[
|
||||
(config-path + /host-config/${hostname}.nix)
|
||||
(config-path + /profile-config/${profile}.nix)
|
||||
(config-path + /domain-config/${domain}.nix)
|
||||
(config-path + /site-config/${site}.nix)
|
||||
]
|
||||
);
|
||||
instance = {
|
||||
inherit hostname;
|
||||
build-seed = builtins.readFile
|
||||
config.fudo.secrets.files.build-seed;
|
||||
# build-timestamp =
|
||||
# self.sourceInfo.lastModified;
|
||||
};
|
||||
nixpkgs.pkgs = pkgs-for system;
|
||||
inherit hostname build-timestamp build-seed;
|
||||
};
|
||||
|
||||
nix.registry = {
|
||||
fudo-nixos.flake = self;
|
||||
fudo-entities.flake = fudo-entities;
|
||||
fudo-lib.flake = fudo-lib;
|
||||
fudo-pkgs.flake = fudo-pkgs;
|
||||
};
|
||||
|
||||
nixpkgs.pkgs = pkgs-for hostOpts.arch;
|
||||
};
|
||||
};
|
||||
|
||||
nixos-host-config = hostname: hostOpts: let
|
||||
system = hostOpts.arch;
|
||||
in nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
(common-host-config hostname hostOpts)
|
||||
];
|
||||
};
|
||||
|
||||
nixops-host-config = hostname: hostOpts: let
|
||||
zone-hosts = fudo-entities.entities.zones.${hostOpts.domain}.hosts;
|
||||
in {
|
||||
imports = [
|
||||
(common-host-config hostname hostOpts)
|
||||
|
||||
({ ... }: {
|
||||
config.deployment.targetHost =
|
||||
zone-hosts.${hostname}.ipv4-address;
|
||||
})
|
||||
];
|
||||
}) fudo-nix-hosts;
|
||||
};
|
||||
|
||||
in {
|
||||
nixosConfigurations = mapAttrs nixos-host-config fudo-nixos-hosts;
|
||||
nixopsHostConfigurations = mapAttrs nixops-host-config fudo-nixos-hosts;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user