2023-09-19 00:17:43 +00:00
|
|
|
{
|
2023-11-03 15:16:07 +00:00
|
|
|
description = "Guanran928's Flake";
|
|
|
|
|
2023-09-19 00:17:43 +00:00
|
|
|
inputs = {
|
2024-02-29 17:21:06 +00:00
|
|
|
# INFO: `nixos-unstable` and `nixpkgs-unstable` contains the same set of packages,
|
|
|
|
# the difference between those channels is their jobsets,
|
|
|
|
# `nixpkgs-unstable` contains less(?) jobs, and usually updates faster.
|
|
|
|
#
|
|
|
|
# REFERENCE: https://discourse.nixos.org/t/differences-between-nix-channels/13998/5
|
2024-09-06 11:51:22 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2023-10-14 07:53:25 +00:00
|
|
|
|
2024-09-01 04:19:53 +00:00
|
|
|
colmena = {
|
|
|
|
url = "github:zhaofengli/colmena";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
inputs.flake-compat.follows = "flake-compat";
|
|
|
|
inputs.flake-utils.follows = "flake-utils";
|
|
|
|
inputs.stable.follows = "nixpkgs";
|
|
|
|
};
|
2023-10-15 00:51:56 +00:00
|
|
|
disko = {
|
|
|
|
url = "github:nix-community/disko";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-12-17 12:06:05 +00:00
|
|
|
flake-utils = {
|
|
|
|
url = "github:numtide/flake-utils";
|
|
|
|
inputs.systems.follows = "systems";
|
|
|
|
};
|
2023-09-19 00:17:43 +00:00
|
|
|
home-manager = {
|
|
|
|
url = "github:nix-community/home-manager";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
lanzaboote = {
|
|
|
|
url = "github:nix-community/lanzaboote";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2023-11-03 15:18:31 +00:00
|
|
|
inputs.crane.follows = "crane";
|
|
|
|
inputs.flake-compat.follows = "flake-compat";
|
|
|
|
inputs.flake-parts.follows = "flake-parts";
|
|
|
|
inputs.pre-commit-hooks-nix.follows = "pre-commit-hooks-nix";
|
|
|
|
inputs.rust-overlay.follows = "rust-overlay";
|
2023-09-19 00:17:43 +00:00
|
|
|
};
|
2024-02-26 18:03:00 +00:00
|
|
|
neovim = {
|
2024-07-04 05:29:18 +00:00
|
|
|
url = "git+https://git.ny4.dev/nyancat/nvim";
|
2024-02-26 18:03:00 +00:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
inputs.flake-utils.follows = "flake-utils";
|
2024-03-23 06:17:09 +00:00
|
|
|
inputs.treefmt-nix.follows = "treefmt-nix";
|
|
|
|
inputs.systems.follows = "systems";
|
2024-02-26 18:03:00 +00:00
|
|
|
};
|
2023-12-16 08:32:13 +00:00
|
|
|
nixos-hardware = {
|
2024-07-25 16:44:41 +00:00
|
|
|
url = "github:NixOS/nixos-hardware";
|
2023-12-16 08:32:13 +00:00
|
|
|
};
|
2024-09-07 06:49:47 +00:00
|
|
|
preservation = {
|
|
|
|
url = "github:WilliButz/preservation";
|
|
|
|
};
|
2023-10-15 00:51:56 +00:00
|
|
|
sops-nix = {
|
|
|
|
url = "github:Mic92/sops-nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2024-07-31 07:00:48 +00:00
|
|
|
inputs.nixpkgs-stable.follows = "nixpkgs";
|
2023-11-03 15:18:31 +00:00
|
|
|
};
|
2024-09-01 04:19:53 +00:00
|
|
|
systems = {
|
|
|
|
url = "github:nix-systems/default";
|
|
|
|
};
|
2024-03-09 01:44:41 +00:00
|
|
|
treefmt-nix = {
|
|
|
|
url = "github:numtide/treefmt-nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-11-03 15:18:31 +00:00
|
|
|
|
2024-02-29 17:21:06 +00:00
|
|
|
### De-dupe flake dependencies
|
2023-11-03 15:18:31 +00:00
|
|
|
crane = {
|
|
|
|
url = "github:ipetkov/crane";
|
|
|
|
};
|
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
};
|
|
|
|
flake-parts = {
|
|
|
|
url = "github:hercules-ci/flake-parts";
|
|
|
|
inputs.nixpkgs-lib.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
gitignore = {
|
|
|
|
url = "github:hercules-ci/gitignore.nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
pre-commit-hooks-nix = {
|
|
|
|
url = "github:cachix/pre-commit-hooks.nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2024-07-31 07:00:48 +00:00
|
|
|
inputs.nixpkgs-stable.follows = "nixpkgs";
|
2023-11-03 15:18:31 +00:00
|
|
|
inputs.flake-compat.follows = "flake-compat";
|
|
|
|
inputs.gitignore.follows = "gitignore";
|
|
|
|
};
|
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-09-19 00:17:43 +00:00
|
|
|
};
|
|
|
|
|
2024-08-25 15:02:35 +00:00
|
|
|
outputs =
|
|
|
|
inputs:
|
2024-09-21 16:21:30 +00:00
|
|
|
let
|
|
|
|
data = builtins.fromJSON (builtins.readFile ./infra/data.json);
|
|
|
|
specialArgs = {
|
|
|
|
inherit inputs;
|
|
|
|
nodes = data.nodes.value;
|
|
|
|
};
|
|
|
|
in
|
2024-08-25 15:02:35 +00:00
|
|
|
inputs.flake-utils.lib.eachDefaultSystem (
|
|
|
|
system:
|
|
|
|
let
|
|
|
|
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
|
|
|
treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
|
|
|
|
in
|
|
|
|
{
|
2024-09-01 04:19:53 +00:00
|
|
|
# nix fmt
|
2024-08-25 15:02:35 +00:00
|
|
|
formatter = treefmtEval.config.build.wrapper;
|
2024-03-09 04:25:06 +00:00
|
|
|
|
2024-09-01 04:19:53 +00:00
|
|
|
# nix flake check
|
2024-08-25 15:02:35 +00:00
|
|
|
checks.formatting = treefmtEval.config.build.check inputs.self;
|
2023-12-17 14:00:56 +00:00
|
|
|
|
2024-09-01 04:19:53 +00:00
|
|
|
# nix {run,shell,build}
|
2024-08-25 15:02:35 +00:00
|
|
|
legacyPackages = import ./pkgs pkgs;
|
2024-06-20 14:04:34 +00:00
|
|
|
|
2024-09-01 04:19:53 +00:00
|
|
|
# nix develop
|
2024-08-30 20:01:51 +00:00
|
|
|
devShells.default = pkgs.mkShellNoCC {
|
2024-08-25 15:02:35 +00:00
|
|
|
packages = with pkgs; [
|
2024-09-21 16:21:30 +00:00
|
|
|
(opentofu.withPlugins (
|
|
|
|
ps: with ps; [
|
2024-09-27 16:03:31 +00:00
|
|
|
aws
|
2024-09-21 16:21:30 +00:00
|
|
|
vultr
|
|
|
|
sops
|
|
|
|
]
|
|
|
|
))
|
2024-08-25 15:02:35 +00:00
|
|
|
colmena
|
2024-09-22 08:31:40 +00:00
|
|
|
just
|
2024-08-25 15:02:35 +00:00
|
|
|
sops
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
2024-08-24 09:12:08 +00:00
|
|
|
// {
|
2024-03-09 04:06:08 +00:00
|
|
|
nixosModules.default = ./nixos/modules;
|
2024-09-01 04:19:53 +00:00
|
|
|
overlays.default = import ./overlays;
|
2024-03-09 04:25:06 +00:00
|
|
|
|
2024-09-01 04:19:53 +00:00
|
|
|
nixosConfigurations = {
|
|
|
|
"dust" = inputs.nixpkgs.lib.nixosSystem {
|
2024-09-21 16:21:30 +00:00
|
|
|
inherit specialArgs;
|
2024-09-01 04:19:53 +00:00
|
|
|
system = "x86_64-linux";
|
|
|
|
modules = [
|
|
|
|
./nixos/profiles/core
|
|
|
|
./hosts/dust
|
|
|
|
];
|
2024-08-25 15:02:35 +00:00
|
|
|
};
|
2024-09-01 04:19:53 +00:00
|
|
|
} // inputs.self.colmenaHive.nodes;
|
2024-03-20 15:01:42 +00:00
|
|
|
|
2024-09-21 16:21:30 +00:00
|
|
|
colmenaHive = inputs.colmena.lib.makeHive (
|
|
|
|
{
|
|
|
|
meta = {
|
|
|
|
inherit specialArgs;
|
|
|
|
nixpkgs = import inputs.nixpkgs {
|
|
|
|
system = "x86_64-linux"; # How does this work?
|
|
|
|
};
|
2024-04-22 18:35:50 +00:00
|
|
|
};
|
|
|
|
|
2024-09-21 16:21:30 +00:00
|
|
|
defaults.imports = [
|
|
|
|
./nixos/profiles/core
|
|
|
|
./nixos/profiles/server
|
|
|
|
];
|
2024-07-10 09:57:01 +00:00
|
|
|
|
2024-09-21 16:21:30 +00:00
|
|
|
"pek0" = {
|
|
|
|
imports = [ ./hosts/pek0 ];
|
|
|
|
deployment.targetHost = "blacksteel"; # thru tailscale
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// (builtins.mapAttrs (n: v: {
|
|
|
|
deployment = {
|
|
|
|
inherit (v) tags;
|
|
|
|
targetHost = v.fqdn;
|
|
|
|
};
|
|
|
|
imports =
|
|
|
|
if (builtins.elem "vultr" v.tags) then
|
|
|
|
[
|
|
|
|
./hosts/vultr/${n}
|
|
|
|
./hosts/vultr/common
|
|
|
|
{ networking.hostName = n; }
|
|
|
|
]
|
2024-09-27 16:03:31 +00:00
|
|
|
else if (builtins.elem "aws" v.tags) then
|
|
|
|
[
|
|
|
|
./hosts/aws/${n}
|
|
|
|
{ networking.hostName = n; }
|
|
|
|
]
|
2024-09-21 16:21:30 +00:00
|
|
|
else
|
|
|
|
[ ./hosts/${n} ];
|
|
|
|
}) data.nodes.value)
|
|
|
|
);
|
2024-08-24 09:12:08 +00:00
|
|
|
};
|
2023-09-19 00:17:43 +00:00
|
|
|
}
|