puter/flake.nix

73 lines
1.7 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 = {
2024-08-18 00:55:37 +00:00
self,
2024-03-08 21:46:46 +00:00
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
commonNixosSystem = name:
nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
attrName = name;
};
modules = [
inputs.agenix.nixosModules.default
2024-03-08 21:46:46 +00:00
2024-08-18 12:54:44 +00:00
./common
./hosts/${name}
2024-03-08 21:46:46 +00:00
2024-08-18 12:54:44 +00:00
({lib, ...}: {networking.hostName = lib.mkDefault name;})
];
};
2024-08-18 18:11:43 +00:00
genHosts = (nixpkgs.lib.pipe (builtins.readDir ./hosts) [
(nixpkgs.lib.filterAttrs (name: type: type == "directory" && name != "default.nix"))
builtins.attrNames
nixpkgs.lib.genAttrs
]);
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
}