nixos/flake.nix
2025-07-18 10:34:50 -04:00

98 lines
2.5 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
nixpkgsUnstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
home-manager = {
url = "github:nix-community/home-manager/release-25.05";
inputs.nixpkgs.follows = "nixpkgs";
};
agenix.url = "github:ryantm/agenix";
simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-25.05";
};
outputs =
inputs@{
nixpkgs,
nixpkgsUnstable,
home-manager,
nixos-hardware,
agenix,
simple-nixos-mailserver,
...
}:
let
system = "x86_64-linux";
overlayUnstable = final: prev: {
unstable = import nixpkgsUnstable {
inherit system;
config.allowUnfree = true;
config.android_sdk.accept_license = true;
};
};
# Common modules shared across all hosts
commonModules = [
agenix.nixosModules.default
{
environment.systemPackages = [ agenix.packages.${system}.default ];
}
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = [ overlayUnstable ];
}
)
];
# Common home-manager modules
homeManagerModules = [
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
];
# Helper function to create a host configuration
mkHost =
{
hostPath,
extraModules ? [ ],
includeHomeManager ? true,
specialArgs ? { },
}:
nixpkgs.lib.nixosSystem {
inherit system specialArgs;
modules =
commonModules
++ (if includeHomeManager then homeManagerModules else [ ])
++ extraModules
++ [ hostPath ];
};
in
{
nixosConfigurations = {
nixbox = mkHost {
hostPath = ./hosts/nixbox;
};
flynode = mkHost {
hostPath = ./hosts/flynode;
extraModules = [ nixos-hardware.nixosModules.lenovo-thinkpad-z13-gen1 ];
};
thewordnerd = mkHost {
hostPath = ./hosts/hub;
extraModules = [ simple-nixos-mailserver.nixosModule ];
specialArgs = { inherit inputs; };
};
garden = mkHost {
hostPath = ./hosts/garden;
includeHomeManager = false;
specialArgs = { inherit inputs; };
};
};
};
}