nixos/flake.nix
2025-10-11 12:49:14 +02:00

134 lines
3.3 KiB
Nix

{
description = "La flake de aurore";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
flake-parts.url = "github:hercules-ci/flake-parts";
# Secret management
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Disks management
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
# Formatter
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{ self
, agenix
, disko
, flake-parts
, nixpkgs
, ...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ inputs.treefmt-nix.flakeModule ];
systems = [ "x86_64-linux" ];
flake = with nixpkgs.lib;
let
defaultConfig = [
./profiles/common
agenix.nixosModules.default
disko.nixosModules.disko
];
defaultVM = [
./profiles/vm
./disks/layout_vm.nix
]
++ defaultConfig;
machines = {
jitsi = {
domain = "pub.infra.auro.re";
tags = [ "vm" ];
config = [ ./hosts/vm/jitsi ] ++ defaultVM;
};
grafana = {
domain = "ext.infra.auro.re";
tags = [ "vm" ];
config = [
./hosts/vm/grafana
] ++ defaultVM;
};
log-2 = {
domain = "int.infra.auro.re";
tags = [ "vm" "log" ];
config = [
./hosts/vm/log-2
./disks/layout_vm_log.nix
] ++ defaultVM;
};
};
colmena_conf = builtins.mapAttrs
(
name: conf: {
deployment = {
targetHost = "${name}.${conf.domain}";
targetPort = 22;
targetUser = "root";
tags = conf.tags;
};
networking = {
hostName = name;
domain = conf.domain;
};
imports = conf.config;
}
)
machines;
nixos_conf = builtins.mapAttrs
(
name: conf: nixosSystem {
specialArgs = inputs;
modules = [{
networking = {
hostName = name;
domain = conf.domain;
};
}] ++ conf.config;
}
)
machines;
in
{
colmena = {
meta = {
nixpkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [ ];
};
};
} // colmena_conf;
nixosConfigurations = nixos_conf;
};
perSystem = { config, pkgs, system, ... }:
{
devShells = {
default = pkgs.callPackage ./devshells/default.nix { inherit (inputs) agenix; };
};
# Formatter
treefmt.config = {
package = pkgs.treefmt;
programs = {
nixpkgs-fmt.enable = true; # *.nix
prettier.enable = true; # *.md (and more)
};
};
};
};
}