infra/flake.nix

144 lines
4.1 KiB
Nix

{
outputs = {
flake-parts,
self,
...
} @ inputs: let
overlays = [
(final: _: rec {
atuin = unstable.atuin;
prometheus-fail2ban-exporter = final.callPackage ./pkgs/prometheus-fail2ban-exporter {};
unstable = inputs.nixpkgs-unstable.legacyPackages.${final.system};
})
];
in
flake-parts.lib.mkFlake {inherit inputs;} {
flake = {
nixosConfigurations.main-node = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{
_module.args.nixinate.host = "main-node";
nixpkgs = {
config.allowUnfree = true;
inherit overlays;
};
}
./hosts/main-node
./config
./modules
inputs.agenix.nixosModules.default
inputs.attic.nixosModules.atticd
inputs.home-manager.nixosModules.home-manager
inputs.valheim-server.nixosModules.default
inputs.satisfactory-server.nixosModules.default
];
specialArgs = {inherit inputs;};
};
};
perSystem = {
config,
inputs',
pkgs,
self',
system,
...
}: {
_module.args.pkgs = import inputs.nixpkgs {
inherit overlays system;
};
apps = (inputs.nixinate.nixinate.${system} self).nixinate;
pre-commit = {
check.enable = true;
settings.excludes = ["_sources/"];
settings.hooks = {
alejandra.enable = true;
commitizen.enable = true;
deadnix.enable = true;
editorconfig-checker.enable = true;
nil.enable = true;
shellcheck.enable = true;
};
};
devShells.default = pkgs.mkShell {
inherit (config.pre-commit.devShell) shellHook;
buildInputs = [
inputs'.agenix.packages.agenix
pkgs.unstable.nh
pkgs.unstable.nil
self'.formatter
];
};
formatter = pkgs.alejandra;
};
imports = [inputs.pre-commit-hooks.flakeModule];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
agenix = {
url = "github:ryantm/agenix";
inputs.darwin.follows = "";
inputs.home-manager.follows = "";
inputs.nixpkgs.follows = "nixpkgs";
};
attic = {
url = "github:zhaofengli/attic";
inputs.nixpkgs.follows = "nixpkgs-unstable";
inputs.nixpkgs-stable.follows = "nixpkgs";
inputs.flake-compat.follows = "";
inputs.flake-utils.follows = "flake-utils";
};
nixinate = {
url = "github:matthewcroughan/nixinate";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.flake-compat.follows = "";
inputs.nixpkgs.follows = "nixpkgs-unstable";
inputs.nixpkgs-stable.follows = "nixpkgs";
};
valheim-server = {
url = "github:aidalgol/valheim-server-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
satisfactory-server = {
# url = "github:nekowinston/satisfactory-server-flake";
url = "path:/home/winston/satisfactory-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
};
nixConfig = {
substituters = [
"https://cache.nixos.org"
"https://cache.garnix.io"
"https://pre-commit-hooks.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc="
];
};
}