2023-11-05 17:43:32 +00:00
|
|
|
{
|
|
|
|
description = "NixOS definitions for our physical servers";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
|
2023-11-15 10:41:45 +00:00
|
|
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2023-11-11 23:04:37 +00:00
|
|
|
deploy-rs.url = "github:serokell/deploy-rs";
|
2023-11-14 22:53:04 +00:00
|
|
|
disko = {
|
|
|
|
url = "github:nix-community/disko";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
agenix = {
|
|
|
|
url = "github:ryantm/agenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-11-05 17:43:32 +00:00
|
|
|
};
|
|
|
|
|
2023-11-15 10:41:45 +00:00
|
|
|
outputs = { self, nixpkgs, deploy-rs, disko, agenix, nixpkgs-unstable, ... }:
|
|
|
|
let
|
|
|
|
system = "x86_64-linux";
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
|
2023-11-15 11:55:57 +00:00
|
|
|
machines = {
|
|
|
|
jefke = {
|
|
|
|
name = "jefke";
|
|
|
|
hostname = "jefke.hyp";
|
|
|
|
user-cert = builtins.readFile ./jefke_user_ed25519-cert.pub;
|
|
|
|
host-cert = builtins.readFile ./jefke_host_ed25519-cert.pub;
|
|
|
|
};
|
|
|
|
};
|
2023-11-11 23:04:37 +00:00
|
|
|
in {
|
2023-11-15 10:41:45 +00:00
|
|
|
devShells.${system}.default = pkgs.mkShell {
|
2023-11-15 11:55:57 +00:00
|
|
|
packages = [
|
|
|
|
pkgs.libsecret
|
|
|
|
pkgs-unstable.nixos-anywhere
|
|
|
|
pkgs-unstable.deploy-rs
|
|
|
|
];
|
2023-11-15 10:41:45 +00:00
|
|
|
};
|
2023-11-11 23:04:37 +00:00
|
|
|
|
2023-11-15 11:55:57 +00:00
|
|
|
# TODO. if uncommented, nix flake check fails
|
|
|
|
# formatter = pkgs.nixfmt;
|
2023-11-11 23:04:37 +00:00
|
|
|
|
2023-11-15 11:55:57 +00:00
|
|
|
# TODO create helper
|
|
|
|
nixosConfigurations = nixpkgs.lib.foldlAttrs (acc: name: machine:
|
|
|
|
acc // {
|
|
|
|
"${name}" = nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
|
|
|
specialArgs = { inherit machine; };
|
|
|
|
modules = [
|
|
|
|
disko.nixosModules.disko
|
|
|
|
agenix.nixosModules.default
|
|
|
|
./configuration.nix
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}) { } machines;
|
2023-11-11 23:04:37 +00:00
|
|
|
|
|
|
|
deploy = {
|
|
|
|
sshUser = "root";
|
|
|
|
user = "root";
|
|
|
|
|
2023-11-15 11:55:57 +00:00
|
|
|
# TODO create helper
|
|
|
|
nodes = nixpkgs.lib.foldlAttrs (acc: name: machine:
|
|
|
|
acc // {
|
|
|
|
"${name}" = {
|
|
|
|
hostname = machine.hostname;
|
|
|
|
profiles.hypervisor = {
|
|
|
|
path = deploy-rs.lib.${system}.activate.nixos
|
|
|
|
self.nixosConfigurations.${name};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}) { } machines;
|
2023-11-11 23:04:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
checks = builtins.mapAttrs
|
|
|
|
(system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
2023-11-05 17:43:32 +00:00
|
|
|
};
|
|
|
|
}
|