homelab/flake.nix
plasmagoat bcbcc8b17b
Some checks failed
Test / tests (push) Has been cancelled
/ OpenTofu (push) Has been cancelled
homelab framework module init (everything is a mess)
2025-07-28 02:05:13 +02:00

88 lines
2.8 KiB
Nix

{
description = "Declarative NixOS HomeLab";
inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs";
# You can access packages and modules from different nixpkgs revs
# at the same time. Here's an working example:
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
# Also see the 'unstable-packages' overlay at 'overlays/default.nix'.
# systems.url = "github:nix-systems/default";
sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
simple-nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs";
# home-manager = {
# url = "home-manager";
# inputs.nixpkgs.follows = "nixpkgs";
# };
colmena.url = "github:zhaofengli/colmena";
};
outputs = {
self,
nixpkgs,
# systems,
sops-nix,
# home-manager,
simple-nixos-mailserver,
...
} @ inputs: let
inherit (self) outputs;
lib = nixpkgs.lib;
# Supported systems for your flake packages, shell, etc.
systems = [
"x86_64-linux"
];
# This is a function that generates an attribute by calling a function you
# pass to it, with each system as an argument
forAllSystems = lib.genAttrs systems;
in {
# Custom packages
# Accessible through 'nix build', 'nix shell', etc
packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
# Formatter for your nix files, available through 'nix fmt'
# Other options beside 'alejandra' include 'nixpkgs-fmt'
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
# Custom packages and modifications, exported as overlays
overlays = import ./overlays {inherit inputs;};
# Reusable nixos modules
nixosModules = import ./modules/nixos;
colmenaHive = inputs.colmena.lib.makeHive self.outputs.colmena;
colmena = import ./colmena.nix {inherit inputs outputs;};
# Development shells
devShells = forAllSystems (
system: let
inherit (inputs.colmena.packages."${pkgs.system}") colmena;
pkgs = nixpkgs.legacyPackages.${system};
in {
default = pkgs.mkShell {
packages = with pkgs; [
# colmena
sops
age
nix-output-monitor
jq
ssh-to-age # For converting SSH keys to age keys
];
shellHook = ''
echo "🏠 Homelab Development Environment"
echo "Available commands:"
echo " colmena apply - Deploy all hosts"
echo " colmena apply --on HOST - Deploy specific host"
echo " sops secrets/secrets.yaml - Edit secrets"
echo ""
'';
};
}
);
};
}