nixos/flake.nix

72 lines
1.7 KiB
Nix

{
description = "Configuration NixOS du Crans";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
flake-parts.url = "github:hercules-ci/flake-parts";
# Formatter
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Secret management
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
nixpkgs,
flake-parts,
agenix,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ inputs.treefmt-nix.flakeModule ];
systems = [ "x86_64-linux" ];
flake = with nixpkgs.lib; {
nixosConfigurations =
let
baseModules = [
./modules
agenix.nixosModules.default
];
hosts = import ./hosts.nix;
in
# Physiques
(mapAttrs (name: value:
nixosSystem {
specialArgs = inputs;
modules = [./hosts/physiques/${name}] ++ baseModules;
}
)
(filterAttrs (n: v: !(attrByPath ["is_debian"] false v)) hosts.physiques)
)//
# VMs
(mapAttrs (name: value:
nixosSystem {
specialArgs = inputs;
modules = [./hosts/vm/${name}] ++ baseModules;
}
)
(filterAttrs (n: v: !(attrByPath ["is_debian"] false v)) hosts.vms)
);
};
perSystem =
{ config, pkgs, ... }:
{
devShells = {
default = pkgs.callPackage ./devshells/default.nix { inherit (inputs) agenix; };
};
};
};
}