Files
nixos-at-home/flake.nix

123 lines
3.7 KiB
Nix

{
description = "NixOS at Home Colmena Remote Management";
inputs = {
# ── Core channels ────────────────────────────────────────
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.11";
# ── Remote deployment ────────────────────────────────────
colmena.url = "github:zhaofengli/colmena";
colmena.inputs.nixpkgs.follows = "nixpkgs";
# ── User environment management ──────────────────────────
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# ── Formatter ────────────────────────────────────────────
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs
, nixpkgs-stable
, colmena
, home-manager
, treefmt-nix
, ...
} @ inputs:
let
system = "x86_64-linux";
lib = nixpkgs.lib;
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
stable-pkgs = import nixpkgs-stable {
inherit system;
config.allowUnfree = true;
};
baseSpecialArgs = {
inherit inputs stable-pkgs;
};
mkHost = hostName: hostModules:
lib.nixosSystem {
inherit system;
specialArgs = baseSpecialArgs;
modules =
[
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.phoenix = import ./home/phoenix.nix;
home-manager.extraSpecialArgs = baseSpecialArgs;
}
./modules/common
]
++ hostModules;
};
treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
settings.global.excludes = [ "*.lock" "secrets.yaml" ];
programs.nixfmt.enable = true;
};
in
{
# ── Local build / nixos-rebuild compat ──────────────────
nixosConfigurations = {
blade = mkHost "blade" [ ./hosts/blade ];
};
# ── Colmena remote deployment ───────────────────────────
colmena = {
meta = {
nixpkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
specialArgs = baseSpecialArgs;
};
blade = { ... }: {
deployment = {
targetHost = "192.168.1.70";
targetPort = 22;
targetUser = "phoenix";
buildOnTarget = true;
keys.phoenix.keyFile = "/home/nixos/.ssh/id_ed25519.pub";
tags = [ "homelab" ];
};
imports = [ ./hosts/blade ];
};
};
# ── Dev shell (enter with `nix develop`) ────────────────
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
colmena
sops
age
ssh-to-age
jq
yq
just
nixfmt-rfc-style
];
};
# ── Formatter (run with `nix fmt`) ──────────────────────
formatter = treefmtEval.config.build.wrapper;
};
}