2021-10-13 16:49:41 +02:00
|
|
|
{
|
2022-09-13 14:57:48 +02:00
|
|
|
description = "0x76's infrastructure";
|
2021-10-13 16:49:41 +02:00
|
|
|
|
2021-11-21 15:50:29 +01:00
|
|
|
# Based on:
|
|
|
|
# * https://github.com/serokell/pegasus-infra/blob/master/flake.nix
|
|
|
|
# * https://git.voidcorp.nl/j00lz/nixos-configs/src/branch/main/flake.nix
|
2021-11-16 21:52:43 +01:00
|
|
|
|
2021-11-16 16:28:55 +01:00
|
|
|
inputs = {
|
2022-09-20 16:38:57 +02:00
|
|
|
nixpkgs.url = "github:NULLx76/nixpkgs/0x76";
|
2022-06-12 12:25:46 +02:00
|
|
|
|
2022-05-27 11:41:22 +02:00
|
|
|
colmena.url = "github:zhaofengli/colmena";
|
|
|
|
colmena.inputs.nixpkgs.follows = "nixpkgs";
|
2022-06-12 12:25:46 +02:00
|
|
|
|
2021-11-16 16:28:55 +01:00
|
|
|
serokell-nix.url = "github:serokell/serokell.nix";
|
2022-05-24 21:06:38 +02:00
|
|
|
serokell-nix.inputs.nixpkgs.follows = "nixpkgs";
|
2022-06-12 12:25:46 +02:00
|
|
|
|
2021-11-16 16:28:55 +01:00
|
|
|
vault-secrets.url = "github:serokell/vault-secrets";
|
2022-05-24 21:06:38 +02:00
|
|
|
vault-secrets.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2022-05-05 15:16:37 +02:00
|
|
|
minecraft-servers.url = "github:jyooru/nix-minecraft-servers";
|
2022-05-24 21:06:38 +02:00
|
|
|
minecraft-servers.inputs.nixpkgs.follows = "nixpkgs";
|
2022-08-20 12:55:59 +02:00
|
|
|
|
2022-08-25 13:33:35 +02:00
|
|
|
home-manager.url = "github:nix-community/home-manager";
|
|
|
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
2022-08-24 18:17:29 +02:00
|
|
|
|
|
|
|
hyprland.url = "github:hyprwm/Hyprland";
|
2022-08-25 13:33:35 +02:00
|
|
|
hyprpaper.url = "github:hyprwm/hyprpaper";
|
|
|
|
hyprpaper.inputs.nixpkgs.follows = "nixpkgs";
|
2022-09-07 14:25:42 +02:00
|
|
|
|
|
|
|
riff.url = "github:DeterminateSystems/riff";
|
2022-09-13 14:43:23 +02:00
|
|
|
riff.inputs.nixpkgs.follows = "nixpkgs";
|
2022-09-10 19:49:04 +02:00
|
|
|
|
|
|
|
webcord.url = "github:fufexan/webcord-flake";
|
2021-11-16 16:28:55 +01:00
|
|
|
};
|
2021-10-13 16:49:41 +02:00
|
|
|
|
2021-11-17 00:55:01 +01:00
|
|
|
outputs =
|
2022-09-13 14:43:23 +02:00
|
|
|
{ self
|
|
|
|
, nixpkgs
|
|
|
|
, vault-secrets
|
|
|
|
, serokell-nix
|
|
|
|
, minecraft-servers
|
|
|
|
, colmena
|
|
|
|
, home-manager
|
|
|
|
, hyprpaper
|
|
|
|
, hyprland
|
|
|
|
, ...
|
|
|
|
} @ inputs:
|
2021-11-16 21:52:43 +01:00
|
|
|
let
|
2021-11-21 15:50:29 +01:00
|
|
|
inherit (nixpkgs) lib;
|
2022-07-30 22:16:44 +02:00
|
|
|
inherit (builtins) filter mapAttrs attrValues concatLists;
|
2022-08-21 11:42:17 +02:00
|
|
|
|
2022-09-13 14:43:23 +02:00
|
|
|
util = import ./util.nix inputs;
|
2022-08-21 11:42:17 +02:00
|
|
|
|
2021-11-16 21:52:43 +01:00
|
|
|
system = "x86_64-linux";
|
2022-08-21 11:42:17 +02:00
|
|
|
# import and add realm to list of tags
|
|
|
|
hosts = mapAttrs util.add_realm_to_tags (import ./nixos/hosts);
|
2022-07-30 22:16:44 +02:00
|
|
|
# flatten hosts to single list
|
2022-08-21 11:42:17 +02:00
|
|
|
flat_hosts = util.flatten_hosts hosts;
|
|
|
|
# Filter out all non-nixos hosts
|
|
|
|
nixHosts = util.filter_nix_hosts flat_hosts;
|
|
|
|
|
2022-07-30 22:16:44 +02:00
|
|
|
# Define args each module gets access to (access to hosts is useful for DNS/DHCP)
|
|
|
|
specialArgs = { inherit hosts flat_hosts inputs; };
|
2022-08-25 10:24:31 +02:00
|
|
|
pkgs = serokell-nix.lib.pkgsWith nixpkgs.legacyPackages.${system} [
|
|
|
|
(import ./nixos/pkgs)
|
|
|
|
vault-secrets.overlay
|
|
|
|
minecraft-servers.overlays.default
|
2022-08-25 13:33:35 +02:00
|
|
|
hyprpaper.overlays.default
|
2022-09-03 20:42:43 +02:00
|
|
|
hyprland.overlays.default
|
2022-08-25 10:24:31 +02:00
|
|
|
];
|
2022-08-21 12:01:19 +02:00
|
|
|
|
|
|
|
# Script to apply local colmena deployments
|
|
|
|
apply-local = pkgs.writeScriptBin "apply-local" ''
|
|
|
|
#!${pkgs.stdenv.shell}
|
2022-09-13 14:43:23 +02:00
|
|
|
"${colmena.packages.${system}.colmena}"/bin/colmena apply-local --sudo $@
|
2022-08-21 12:01:19 +02:00
|
|
|
'';
|
2022-05-08 02:13:44 +02:00
|
|
|
in
|
|
|
|
{
|
2022-09-13 14:57:48 +02:00
|
|
|
# Make the nixosConfigurations for compat reasons
|
|
|
|
nixosConfigurations = (import (inputs.colmena + "/src/nix/hive/eval.nix") {
|
|
|
|
rawFlake = self;
|
|
|
|
colmenaOptions = import (inputs.colmena + "/src/nix/hive/options.nix");
|
|
|
|
colmenaModules = import (inputs.colmena + "/src/nix/hive/modules.nix");
|
|
|
|
}).nodes;
|
|
|
|
|
2022-07-30 16:42:46 +02:00
|
|
|
|
2022-07-30 23:35:52 +02:00
|
|
|
# Make the coleman configuration
|
2022-08-21 11:42:17 +02:00
|
|
|
colmena = lib.foldr (el: acc: acc // util.mkColmenaHost el)
|
2022-07-30 16:42:46 +02:00
|
|
|
{
|
|
|
|
meta = {
|
2022-08-21 11:42:17 +02:00
|
|
|
inherit specialArgs;
|
2022-08-25 10:24:31 +02:00
|
|
|
nixpkgs = pkgs;
|
2022-08-25 13:33:35 +02:00
|
|
|
};
|
2022-07-30 16:42:46 +02:00
|
|
|
}
|
|
|
|
nixHosts;
|
2022-06-12 17:06:32 +02:00
|
|
|
|
2022-09-13 14:57:48 +02:00
|
|
|
packages.${system} = {
|
|
|
|
default = colmena.packages.${system}.colmena;
|
|
|
|
apply-local = apply-local;
|
|
|
|
};
|
2022-08-21 12:01:19 +02:00
|
|
|
|
2021-11-16 21:52:43 +01:00
|
|
|
# Use by running `nix develop`
|
2022-07-30 18:02:40 +02:00
|
|
|
devShells.${system}.default = pkgs.mkShell {
|
2021-11-23 17:44:00 +01:00
|
|
|
VAULT_ADDR = "http://vault.olympus:8200/";
|
2022-08-21 12:01:19 +02:00
|
|
|
buildInputs = with pkgs; [
|
|
|
|
apply-local
|
2022-09-13 14:43:23 +02:00
|
|
|
colmena.packages.${system}.colmena
|
2021-11-21 15:50:29 +01:00
|
|
|
fluxcd
|
|
|
|
k9s
|
|
|
|
kubectl
|
|
|
|
kubectx
|
2021-11-21 16:32:30 +01:00
|
|
|
terraform
|
2021-11-21 15:50:29 +01:00
|
|
|
nixfmt
|
|
|
|
nixUnstable
|
|
|
|
vault
|
2022-09-20 16:38:57 +02:00
|
|
|
(vault-push-approle-envs self {})
|
|
|
|
(vault-push-approles self {})
|
2021-11-16 16:28:55 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2021-10-13 16:49:41 +02:00
|
|
|
}
|