nixos-config/flake.nix
2024-08-31 21:16:40 -07:00

92 lines
2.9 KiB
Nix

{
description = "Entrypoint of all nix configurations";
inputs = {
disko.url = "github:nix-community/disko";
flake-utils.url = "github:numtide/flake-utils";
hardware.url = "github:nixos/nixos-hardware";
home-manager.url = "github:nix-community/home-manager";
jovian.url = "github:Jovian-Experiments/Jovian-NixOS";
mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nix-custom.url = "git+https://forgejo.invariantspace.com/macronova/nix-custom";
plasma-manager.url = "github:pjones/plasma-manager";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
sops-nix.url = "github:Mic92/sops-nix";
};
outputs = inputs @ {
self,
flake-utils,
nixpkgs,
nix-custom,
pre-commit-hooks,
...
}: let
linuxCfgDir = ./linux;
templateDir = ./template;
in
{
nixosConfigurations =
builtins.mapAttrs
(instance: _:
nixpkgs.lib.nixosSystem {
modules = [
# Import config from folder
(linuxCfgDir + "/${instance}")
# Setup Nix
({pkgs, ...}: {
networking.hostName = instance;
nix = {
gc = {
automatic = true;
options = "--delete-older-than 30d";
};
settings = {
auto-optimise-store = true;
experimental-features = ["nix-command" "flakes"];
trusted-substituters = ["https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"];
};
};
nixpkgs = {
config.allowUnfree = true;
# TODO: Remove this when possible
config.permittedInsecurePackages = [
"fluffychat-web-1.20.0"
"olm-3.2.16"
];
overlays = [nix-custom.overlays.default];
};
})
];
specialArgs = {inherit inputs;};
})
(builtins.readDir linuxCfgDir);
templates =
builtins.mapAttrs
(template: _: {
path = templateDir + "/${template}";
description = "Template flake setup: ${template}";
})
(builtins.readDir templateDir);
}
// (
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
checks.pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks.alejandra.enable = true;
};
devShells.default = let
pre-commit = self.checks.${system}.pre-commit-check;
in
pkgs.mkShell {
inherit (pre-commit) shellHook;
buildInputs = pre-commit.enabledPackages;
};
})
);
}