nix-config/flake.nix

304 lines
8.7 KiB
Nix
Raw Permalink Normal View History

2022-04-23 03:01:58 +02:00
{
2023-10-28 16:33:27 +02:00
nixConfig = {
extra-substituters = [ "https://nix-cache.hq.c3d2.de" ];
extra-trusted-public-keys = [ "nix-cache.hq.c3d2.de:KZRGGnwOYzys6pxgM8jlur36RmkJQ/y8y62e52fj1ps=" ];
};
2022-04-23 13:41:36 +02:00
inputs = {
2024-04-27 22:33:15 +02:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
2023-03-04 23:59:22 +01:00
# naersk and flake utils are not used by this flake directly, but needed
# for the follows in all the other ones.
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-03-17 19:51:49 +01:00
# DO NOT remame this to utils
flake-utils.url = "github:numtide/flake-utils";
2023-03-16 22:55:12 +01:00
2022-05-14 22:47:54 +02:00
microvm = {
2023-06-14 18:32:00 +02:00
url = "github:astro/microvm.nix";
2022-06-06 22:41:04 +02:00
inputs.nixpkgs.follows = "nixpkgs";
2023-03-17 19:51:49 +01:00
inputs.flake-utils.follows = "flake-utils";
2022-05-14 22:47:54 +02:00
};
sops-nix = {
2023-02-19 22:28:44 +01:00
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
private-flake-overlays = {
url = "github:marenz2569/private-flake-overlays";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-03-05 14:07:31 +01:00
## TLMS stuff below
2023-02-15 11:17:36 +01:00
trekkie = {
url = "github:tlm-solutions/trekkie";
2023-03-04 23:59:22 +01:00
inputs = {
nixpkgs.follows = "nixpkgs";
naersk.follows = "naersk";
2023-03-05 14:07:31 +01:00
tlms-rs.follows = "tlms-rs";
2023-03-17 19:51:49 +01:00
utils.follows = "flake-utils";
2023-03-04 23:59:22 +01:00
};
2023-02-15 11:17:36 +01:00
};
2023-02-19 22:28:44 +01:00
datacare = {
url = "github:tlm-solutions/datacare";
};
2023-02-24 14:25:30 +01:00
2023-10-14 15:25:29 +02:00
kindergarten = {
url = "github:tlm-solutions/kindergarten";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
2023-10-14 15:25:29 +02:00
};
2023-03-05 00:00:05 +01:00
telegram-decoder = {
url = "github:tlm-solutions/telegram-decoder";
inputs = {
nixpkgs.follows = "nixpkgs";
naersk.follows = "naersk";
2023-03-17 19:51:49 +01:00
utils.follows = "flake-utils";
2023-03-05 00:00:05 +01:00
};
};
2023-03-05 14:07:31 +01:00
r09-receiver = {
url = "github:tlm-solutions/r09-receiver";
2023-03-05 14:07:31 +01:00
inputs.nixpkgs.follows = "nixpkgs";
2023-03-17 19:51:49 +01:00
inputs.utils.follows = "flake-utils";
2023-03-05 14:07:31 +01:00
};
data-accumulator = {
url = "github:tlm-solutions/data-accumulator";
inputs.nixpkgs.follows = "nixpkgs";
inputs.naersk.follows = "naersk";
2023-03-17 19:51:49 +01:00
inputs.utils.follows = "flake-utils";
2023-03-05 14:07:31 +01:00
};
2023-04-12 17:20:07 +02:00
lizard = {
url = "github:tlm-solutions/lizard";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
bureaucrat = {
url = "github:tlm-solutions/bureaucrat";
2023-03-05 14:07:31 +01:00
inputs.nixpkgs.follows = "nixpkgs";
2023-03-17 19:51:49 +01:00
inputs.utils.follows = "flake-utils";
2023-03-05 14:07:31 +01:00
};
funnel = {
url = "github:tlm-solutions/funnel";
inputs.nixpkgs.follows = "nixpkgs";
2023-03-17 19:51:49 +01:00
inputs.utils.follows = "flake-utils";
2023-03-05 14:07:31 +01:00
};
tlms-rs = {
url = "github:tlm-solutions/tlms.rs";
inputs.nixpkgs.follows = "nixpkgs";
};
chemo = {
url = "github:tlm-solutions/chemo";
inputs.nixpkgs.follows = "nixpkgs";
2023-11-18 14:55:13 +01:00
inputs.utils.follows = "flake-utils";
};
2023-05-19 19:08:52 +02:00
borzoi = {
url = "github:tlm-solutions/borzoi";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-04-28 14:43:40 +02:00
};
2022-04-23 13:41:36 +02:00
2022-07-06 20:58:15 +02:00
outputs =
inputs@{ self
, private-flake-overlays
2023-05-19 19:08:52 +02:00
, borzoi
2023-03-05 14:07:31 +01:00
, data-accumulator
2023-02-19 22:28:44 +01:00
, datacare
2023-03-05 14:07:31 +01:00
, funnel
, r09-receiver
2023-10-14 15:25:29 +02:00
, kindergarten
2022-07-06 20:58:15 +02:00
, microvm
, nixpkgs
2022-07-06 20:58:15 +02:00
, sops-nix
2023-04-12 17:20:07 +02:00
, lizard
, bureaucrat
2023-03-05 14:07:31 +01:00
, telegram-decoder
2023-02-15 11:17:36 +01:00
, trekkie
, chemo
2022-07-06 20:58:15 +02:00
, ...
}:
2022-04-30 23:41:24 +02:00
let
pkgs = nixpkgs.legacyPackages."x86_64-linux";
lib = pkgs.lib;
overlayFlake = private-flake-overlays.lib.overlayFlake;
2022-05-28 06:12:39 +02:00
registry = import ./registry;
2022-05-28 21:24:15 +02:00
data-hoarder-modules = [
./modules/data-hoarder
2022-12-30 18:29:13 +01:00
./modules/TLMS
2023-03-05 14:07:31 +01:00
data-accumulator.nixosModules.default
2023-02-19 22:28:44 +01:00
datacare.nixosModules.default
2023-03-05 14:07:31 +01:00
funnel.nixosModules.default
sops-nix.nixosModules.sops
2023-04-12 17:20:07 +02:00
lizard.nixosModules.default
bureaucrat.nixosModules.default
2023-02-15 11:17:36 +01:00
trekkie.nixosModules.default
chemo.nixosModules.default
2022-05-28 21:24:15 +02:00
{
nixpkgs.overlays = [
2023-02-19 22:28:44 +01:00
datacare.overlays.default
2023-10-14 15:25:29 +02:00
kindergarten.overlays.default
2023-02-15 11:17:36 +01:00
trekkie.overlays.default
2023-04-12 17:20:07 +02:00
lizard.overlays.default
bureaucrat.overlays.default
2023-03-05 14:07:31 +01:00
funnel.overlays.default
data-accumulator.overlays.default
chemo.overlays.default
2022-05-28 21:24:15 +02:00
];
}
];
2022-05-28 06:12:39 +02:00
stop-box-modules = [
2023-03-05 14:07:31 +01:00
./modules/TLMS
telegram-decoder.nixosModules.default
r09-receiver.nixosModules.default
2022-09-27 01:01:20 +02:00
{
nixpkgs.overlays = [
2023-03-05 14:07:31 +01:00
telegram-decoder.overlays.default
r09-receiver.overlays.default
2022-09-27 01:01:20 +02:00
];
}
];
# function that generates a system with the given number
generate_system = (id:
let
myRegistry = registry.traffic-stop-box."${toString id}";
in
{
"${myRegistry.hostName}" = {
system = myRegistry.arch;
specialArgs = { inherit self inputs; registry = myRegistry; };
modules =
[
# box-specific config
./hosts/traffic-stop-box/${toString id}
# default modules
sops-nix.nixosModules.sops
./modules/traffic-stop-box
./modules/TLMS
{
deployment-TLMS.monitoring.enable = myRegistry.monitoring;
}
] ++ stop-box-modules;
};
2022-04-30 23:41:24 +02:00
}
2022-04-28 14:43:40 +02:00
);
# list of traffic-stop-box-$id that will be built
stop_box_ids = [ 0 1 4 8 9 ];
2022-04-30 23:41:24 +02:00
# attribute set of all traffic stop boxes
r09_receivers = nixpkgs.lib.foldl (x: id: nixpkgs.lib.mergeAttrs x (generate_system id)) { } stop_box_ids;
2022-05-14 20:47:17 +02:00
unevaluatedNixosConfigurations = r09_receivers // {
data-hoarder = {
2022-05-28 21:24:15 +02:00
system = "x86_64-linux";
specialArgs = { inherit inputs self; registry = registry.data-hoarder; };
2022-05-29 01:57:24 +02:00
modules = [
microvm.nixosModules.microvm
2022-10-02 21:39:37 +02:00
./hosts/data-hoarder
2022-05-29 01:57:24 +02:00
] ++ data-hoarder-modules;
2022-05-28 06:12:39 +02:00
};
staging-data-hoarder = {
2022-05-28 21:24:15 +02:00
system = "x86_64-linux";
2023-11-26 02:38:52 +01:00
specialArgs = { inherit inputs self; registry = registry.staging-data-hoarder; };
2022-05-29 01:57:24 +02:00
modules = [
2022-10-02 21:39:37 +02:00
./hosts/staging-data-hoarder
2022-05-28 21:24:15 +02:00
microvm.nixosModules.microvm
2022-05-29 01:57:24 +02:00
] ++ data-hoarder-modules;
2022-05-28 21:24:15 +02:00
};
2023-04-17 00:06:47 +02:00
notice-me-senpai = {
2023-04-23 21:19:45 +02:00
system = "x86_64-linux";
2023-11-26 02:38:52 +01:00
specialArgs = { inherit inputs self; registry = registry.notice-me-senpai; };
2023-04-23 21:19:45 +02:00
modules = [
sops-nix.nixosModules.sops
microvm.nixosModules.microvm
2023-04-23 21:19:45 +02:00
./modules/TLMS
./hosts/notice-me-senpai
];
};
tram-borzoi = {
2023-05-19 19:08:52 +02:00
system = "x86_64-linux";
2023-11-26 02:38:52 +01:00
specialArgs = { inherit inputs self; registry = registry.tram-borzoi; };
2023-05-19 19:08:52 +02:00
modules = [
sops-nix.nixosModules.sops
microvm.nixosModules.microvm
borzoi.nixosModules.default
{ nixpkgs.overlays = [ borzoi.overlays.default ]; }
./modules/TLMS
./hosts/tram-borzoi
];
};
tetra-zw = {
system = "x86_64-linux";
specialArgs = { inherit inputs self; registry = registry.tetra-zw; };
modules = [
sops-nix.nixosModules.sops
./modules/TLMS
./hosts/tetra-zw
];
};
uranus = {
2023-05-30 16:00:35 +02:00
system = "x86_64-linux";
2023-11-26 02:38:52 +01:00
specialArgs = { inherit inputs self; registry = registry.uranus; };
2023-05-30 16:00:35 +02:00
modules = [
sops-nix.nixosModules.sops
microvm.nixosModules.microvm
./modules/TLMS
./hosts/uranus
];
};
};
in
# overlays this private flake when in impure mode
overlayFlake "git+ssh://git@github.com/tlm-solutions/nix-config-private.git" {
inherit unevaluatedNixosConfigurations;
packages."aarch64-linux".box8 = self.nixosConfigurations.traffic-stop-box-8.config.system.build.sdImage;
packages."aarch64-linux".box9 = self.nixosConfigurations.traffic-stop-box-9.config.system.build.sdImage;
2023-05-30 16:00:35 +02:00
packages."x86_64-linux" = {
staging-microvm = self.nixosConfigurations.staging-data-hoarder.config.microvm.declaredRunner;
data-hoarder-microvm = self.nixosConfigurations.data-hoarder.config.microvm.declaredRunner;
2023-04-17 00:06:47 +02:00
};
2022-04-29 11:52:57 +02:00
# these are in the app declaration as nix before 2.19 tries to find attrPaths in packages first.
# here we evaluate over all nixos configurations making this extremely slow
apps."x86_64-linux" = (import ./pkgs/deployment.nix { inherit self pkgs lib; });
nixosConfigurations = lib.attrsets.mapAttrs (name: value: nixpkgs.lib.nixosSystem value) unevaluatedNixosConfigurations;
2023-05-26 22:17:21 +02:00
hydraJobs =
let
get-toplevel = (host: nixSystem: nixSystem.config.microvm.declaredRunner or nixSystem.config.system.build.toplevel);
in
nixpkgs.lib.mapAttrs get-toplevel self.nixosConfigurations;
2023-06-08 14:46:27 +02:00
};
2022-12-07 23:30:37 +01:00
}