puter/flake.nix

76 lines
1.8 KiB
Nix
Raw Normal View History

2024-02-04 20:51:11 +00:00
{
description = "My NixOS configuration";
inputs = {
2024-03-08 21:46:46 +00:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
2024-02-04 20:51:11 +00:00
hardware.url = "github:NixOS/nixos-hardware";
agenix.url = "github:ryantm/agenix";
};
2024-03-08 21:46:46 +00:00
outputs = {
nixpkgs,
flake-parts,
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux"];
2024-08-18 12:54:44 +00:00
flake = {
nixosConfigurations = let
2024-09-15 12:16:32 +00:00
lib = nixpkgs.lib.extend (import ./lib.nix);
2024-08-30 23:17:38 +00:00
2024-08-18 12:54:44 +00:00
commonNixosSystem = name:
2024-09-15 12:16:32 +00:00
lib.nixosSystem {
2024-08-18 12:54:44 +00:00
specialArgs = {
2024-09-15 12:16:32 +00:00
inherit inputs lib;
2024-08-18 12:54:44 +00:00
attrName = name;
};
2024-03-08 21:46:46 +00:00
2024-09-15 12:16:32 +00:00
modules =
(lib.findModules [
./common
./hosts/${name}
])
++ [
inputs.agenix.nixosModules.default
{networking.hostName = lib.mkDefault name;}
];
2024-08-18 12:54:44 +00:00
};
2024-08-18 18:11:43 +00:00
2024-09-15 12:16:32 +00:00
genHosts = lib.pipe (builtins.readDir ./hosts) [
2024-10-27 21:05:53 +00:00
(lib.filterAttrs (_: type: type == "directory"))
2024-08-18 18:11:43 +00:00
builtins.attrNames
2024-09-15 12:16:32 +00:00
lib.genAttrs
2024-08-20 19:46:27 +00:00
];
2024-08-18 12:54:44 +00:00
in
2024-08-18 18:11:43 +00:00
genHosts commonNixosSystem;
2024-02-04 20:51:11 +00:00
};
2024-03-08 21:46:46 +00:00
perSystem = {
inputs',
pkgs,
...
}: {
devShells.default = pkgs.mkShellNoCC {
packages = [inputs'.agenix.packages.agenix];
};
2024-02-04 20:51:11 +00:00
2024-03-08 21:46:46 +00:00
formatter = pkgs.alejandra;
2024-04-21 17:55:29 +00:00
packages.disk = pkgs.writeShellApplication {
name = "disk";
runtimeInputs = with pkgs; [
util-linux
jq
2024-07-01 22:06:05 +00:00
e2fsprogs
2024-04-21 17:55:29 +00:00
dosfstools
];
2024-04-21 17:56:53 +00:00
text = builtins.readFile ./disk.sh;
2024-04-21 17:55:29 +00:00
};
2024-02-04 20:51:11 +00:00
};
2024-03-08 21:46:46 +00:00
};
2024-02-04 20:51:11 +00:00
}