puter/flake.nix
2024-08-31 01:17:38 +02:00

75 lines
1.7 KiB
Nix

{
description = "My NixOS configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
hardware.url = "github:NixOS/nixos-hardware";
agenix.url = "github:ryantm/agenix";
};
outputs = {
self,
nixpkgs,
flake-parts,
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux"];
flake = {
nixosConfigurations = let
hostsDir = "hosts";
commonNixosSystem = name:
nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
attrName = name;
};
modules = [
inputs.agenix.nixosModules.default
./common
./${hostsDir}/${name}
({lib, ...}: {networking.hostName = lib.mkDefault name;})
];
};
genHosts = nixpkgs.lib.pipe (builtins.readDir ./${hostsDir}) [
(nixpkgs.lib.filterAttrs (name: type: type == "directory"))
builtins.attrNames
nixpkgs.lib.genAttrs
];
in
genHosts commonNixosSystem;
};
perSystem = {
inputs',
pkgs,
...
}: {
devShells.default = pkgs.mkShellNoCC {
packages = [inputs'.agenix.packages.agenix];
};
formatter = pkgs.alejandra;
packages.disk = pkgs.writeShellApplication {
name = "disk";
runtimeInputs = with pkgs; [
util-linux
jq
e2fsprogs
dosfstools
];
text = builtins.readFile ./disk.sh;
};
};
};
}