modernise flake: add home-manager, devShell, formatter, bump stable to 24.11
This commit is contained in:
114
flake.nix
114
flake.nix
@@ -1,26 +1,122 @@
|
|||||||
{
|
{
|
||||||
description = "NixOS at Home - Colmena Remote Management";
|
description = "NixOS at Home — Colmena Remote Management";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
|
# ── Core channels ────────────────────────────────────────
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-22.11";
|
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.11";
|
||||||
|
|
||||||
|
# ── Remote deployment ────────────────────────────────────
|
||||||
colmena.url = "github:zhaofengli/colmena";
|
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 = inputs@{ nixpkgs, colmena, ... }:
|
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 = {
|
colmena = {
|
||||||
meta = {
|
meta = {
|
||||||
nixpkgs = import nixpkgs {
|
nixpkgs = import nixpkgs {
|
||||||
system = "x86_64-linux";
|
inherit system;
|
||||||
overlays = [];
|
config.allowUnfree = true;
|
||||||
};
|
|
||||||
specialArgs = {
|
|
||||||
inherit inputs;
|
|
||||||
};
|
};
|
||||||
|
specialArgs = baseSpecialArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
blade = import ./hosts/blade;
|
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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user