nixos-config/flake.nix

361 lines
11 KiB
Nix
Raw Permalink Normal View History

{
description = "Fudo Host Configuration";
inputs = {
2024-05-21 23:16:02 -07:00
nixpkgs.url =
"nixpkgs/nixos-23.11"; # "git+https://fudo.dev/nix/nixpkgs.git";
2021-09-29 17:55:13 -07:00
2022-03-16 09:49:35 -07:00
fudo-home = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/nix/home.git";
2023-05-16 22:40:08 -07:00
# url = "path:/state/fudo-home";
2022-03-16 09:49:35 -07:00
inputs.nixpkgs.follows = "nixpkgs";
};
2021-11-17 17:32:27 -08:00
2021-11-29 16:03:38 -08:00
# This MUST be a clean git repo, because we use the timestamp.
2024-05-21 23:16:02 -07:00
fudo-entities.url = "git+https://fudo.dev/nix/entities.git";
2024-05-21 23:16:02 -07:00
fudo-lib.url = "git+https://fudo.dev/nix/lib.git";
2021-09-29 17:55:13 -07:00
2024-05-21 23:16:02 -07:00
fudo-pkgs.url = "git+https://fudo.dev/nix/pkgs.git";
2021-12-18 12:10:42 -08:00
2024-05-21 23:16:02 -07:00
fudo-secrets = {
url = "path:/secrets";
2023-10-14 16:15:26 -07:00
inputs.nixpkgs.follows = "nixpkgs";
};
2021-12-18 12:10:42 -08:00
2024-05-21 23:16:02 -07:00
# chute = {
# url = "git+https://fudo.dev/chute/chute.git?ref=stable";
# inputs.nixpkgs.follows = "nixpkgs";
# };
2022-03-16 09:49:35 -07:00
2024-05-21 23:16:02 -07:00
# chuteUnstable = {
# url = "git+https://fudo.dev/chute/chute.git?ref=master";
# inputs.nixpkgs.follows = "nixpkgs";
# };
# pricebot = {
# url = "git+https://fudo.dev/public/pricebot.git";
# inputs.nixpkgs.follows = "nixpkgs";
# };
2022-07-10 20:46:03 -07:00
2022-03-16 09:49:35 -07:00
nixpkgsUnstable.url = "nixpkgs/nixos-unstable";
2022-06-01 13:57:58 -07:00
2023-10-14 16:15:26 -07:00
wallfly = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/wallfly.git";
2023-10-14 16:15:26 -07:00
inputs.nixpkgs.follows = "nixpkgs";
};
objectifier = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/objectifier.git";
2023-10-14 16:15:26 -07:00
inputs.nixpkgs.follows = "nixpkgs";
};
nexus = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/nexus.git";
2023-10-14 16:15:26 -07:00
inputs.nixpkgs.follows = "nixpkgs";
};
suanni = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/suanni.git";
2023-10-14 16:15:26 -07:00
inputs.nixpkgs.follows = "nixpkgs";
};
snooper = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/snooper.git";
2023-10-14 16:15:26 -07:00
inputs.nixpkgs.follows = "nixpkgs";
};
tattler = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/tattler.git";
2023-10-14 16:15:26 -07:00
inputs.nixpkgs.follows = "nixpkgs";
};
2023-05-16 22:40:08 -07:00
2024-05-21 23:16:02 -07:00
mabel = {
url = "git+https://fudo.dev/public/mabel.git";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-10-14 16:15:26 -07:00
arion = {
url = "github:hercules-ci/arion";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-05-16 22:40:08 -07:00
2023-10-14 16:15:26 -07:00
lemmy-docker = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/lemmy-docker.git";
2023-10-14 16:15:26 -07:00
inputs = {
nixpkgs.follows = "nixpkgs";
arion.follows = "arion";
};
};
2023-05-16 22:40:08 -07:00
2023-10-14 16:15:26 -07:00
tesla-mate-container = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/tesla-mate-container.git";
2023-10-14 16:15:26 -07:00
inputs = {
nixpkgs.follows = "nixpkgs";
arion.follows = "arion";
};
};
2023-05-16 22:40:08 -07:00
2023-10-14 16:15:26 -07:00
mastodon-container = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/mastodon-container.git";
2023-10-14 16:15:26 -07:00
inputs = {
nixpkgs.follows = "nixpkgs";
arion.follows = "arion";
};
};
2024-02-10 16:53:55 -08:00
lemmy-container = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/lemmy-container.git";
2024-02-10 16:53:55 -08:00
inputs = {
nixpkgs.follows = "nixpkgs";
arion.follows = "arion";
};
};
2023-10-14 16:15:26 -07:00
authentik-container = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/nix/authentik-container.git";
2023-10-14 16:15:26 -07:00
inputs = {
nixpkgs.follows = "nixpkgs";
arion.follows = "arion";
};
};
nextcloud-container = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/nextcloud-container.git";
2023-10-14 16:15:26 -07:00
inputs = {
nixpkgs.follows = "nixpkgs";
arion.follows = "arion";
};
};
2023-05-16 22:40:08 -07:00
2023-10-14 16:15:26 -07:00
matrix-module = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/matrix-module.git";
2023-10-14 16:15:26 -07:00
inputs.nixpkgs.follows = "nixpkgs";
};
mail-server = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/mail-server.git";
2024-02-10 16:53:55 -08:00
inputs = {
arion.follows = "arion";
nixpkgs.follows = "nixpkgs";
};
};
immich-container = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/immich-container.git";
2024-02-10 16:53:55 -08:00
inputs = {
arion.follows = "arion";
nixpkgs.follows = "nixpkgs";
};
2023-10-14 16:15:26 -07:00
};
2024-05-21 23:16:02 -07:00
immich-ml-container = {
url = "git+https://fudo.dev/public/immich-ml-container.git";
inputs = {
arion.follows = "arion";
nixpkgs.follows = "nixpkgs";
};
};
2023-10-14 16:15:26 -07:00
authoritative-dns = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/authoritative-dns.git";
2023-10-14 16:15:26 -07:00
inputs.nixpkgs.follows = "nixpkgs";
};
2023-12-04 17:10:57 -08:00
frigate-container = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/frigate-container.git";
2023-12-04 17:10:57 -08:00
inputs.nixpkgs.follows = "nixpkgs";
};
grafana-module = {
2024-03-23 14:23:43 -07:00
url = "git+https://fudo.dev/public/grafana-module.git";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-10-14 16:15:26 -07:00
textfiles = {
url = "git+https://git.informis.land/informis/textfiles.git";
flake = false;
};
2024-05-21 23:16:02 -07:00
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
};
2022-06-01 13:57:58 -07:00
outputs = { self, nixpkgs, fudo-home, fudo-lib, fudo-entities, fudo-pkgs
2024-05-21 23:16:02 -07:00
, fudo-secrets, nixpkgsUnstable, wallfly, objectifier, nexus, suanni
, snooper, tattler, lemmy-docker, tesla-mate-container, mastodon-container
, authentik-container, nextcloud-container, textfiles, matrix-module
, mail-server, authoritative-dns, frigate-container, grafana-module
, lemmy-container, immich-container, immich-ml-container, mabel
, nixos-hardware, ... }@inputs:
2021-11-19 10:26:10 -08:00
with nixpkgs.lib;
let
2022-06-01 13:57:58 -07:00
fudo-nixos-hosts = filterAttrs (hostname: hostOpts: hostOpts.nixos-system)
fudo-entities.entities.hosts;
2021-09-29 17:55:13 -07:00
fudo-networks = fudo-entities.entities.networks;
2021-11-17 17:32:27 -08:00
2022-06-01 13:57:58 -07:00
unstable-for = arch:
import nixpkgsUnstable {
system = arch;
2022-07-10 20:46:03 -07:00
config.allowUnfree = true;
2022-03-16 09:49:35 -07:00
};
2022-06-01 13:57:58 -07:00
pkgs-for = arch:
let unstable = unstable-for arch;
in import nixpkgs {
system = arch;
config = {
allowUnfree = true;
2023-10-14 16:15:26 -07:00
permittedInsecurePackages = [
# Necessary for Kerberos
"openssl-1.1.1w"
"python3.10-requests-2.28.2"
"python3.10-cryptography-40.0.1"
2023-12-04 17:10:57 -08:00
"gitea-1.19.4"
2023-10-14 16:15:26 -07:00
];
2022-06-01 13:57:58 -07:00
};
overlays = [
2023-12-04 17:10:57 -08:00
fudo-lib.overlays.default
2023-05-16 22:40:08 -07:00
fudo-pkgs.overlays.default
fudo-secrets.overlays.default
fudo-entities.overlays.default
2023-11-15 12:22:14 -08:00
self.overlays.fudoHostConfig
2022-06-01 13:57:58 -07:00
(final: prev: {
chute = chute.packages.${arch}.chute;
chuteUnstable = chuteUnstable.packages.${arch}.chute;
})
2024-05-21 23:16:02 -07:00
(final: prev: {
pkgsUnstable = unstable;
inherit nixos-hardware;
})
2022-11-30 09:46:03 -08:00
(final: prev: {
2023-01-04 10:50:38 -08:00
signal-desktop = unstable.signal-desktop;
2022-11-30 09:46:03 -08:00
factorio-experimental = unstable.factorio-experimental;
factorio-headless-experimental =
unstable.factorio-headless-experimental;
})
2023-10-14 16:15:26 -07:00
(final: prev: { inherit textfiles; })
2024-05-24 08:51:54 -07:00
(final: prev: {
nvidia-container-toolkit = unstable.nvidia-container-toolkit;
})
];
};
2021-11-29 16:03:38 -08:00
2022-06-01 13:57:58 -07:00
latest-modified-timestamp = head (sort (a: b: a > b)
(map (input: toInt input.lastModifiedDate)
(filter (input: hasAttr "lastModifiedDate" input)
(attrValues inputs))));
concat-timestamp = timestamp: toInt (substring 0 10 (toString timestamp));
2023-11-15 12:22:14 -08:00
mkFudoHostConfig = hostname: hostOpts:
2022-06-01 13:57:58 -07:00
let
config-dir = ./config;
build-timestamp = concat-timestamp latest-modified-timestamp;
in { config, ... }: {
imports = [
2022-10-23 13:36:31 -07:00
fudo-home.nixosModules.default
2023-05-16 22:40:08 -07:00
fudo-secrets.nixosModules.default
2023-12-04 17:10:57 -08:00
fudo-lib.nixosModules.default
2022-06-01 13:57:58 -07:00
fudo-entities.nixosModule
2024-05-21 23:16:02 -07:00
# pricebot.nixosModules.default
2022-07-10 20:46:03 -07:00
wallfly.nixosModule
2023-05-16 22:40:08 -07:00
objectifier.nixosModules.default
suanni.nixosModules.default
snooper.nixosModules.default
tattler.nixosModules.default
2023-10-14 16:15:26 -07:00
lemmy-docker.nixosModules.default
tesla-mate-container.nixosModules.default
mastodon-container.nixosModules.default
authentik-container.nixosModules.default
nextcloud-container.nixosModules.default
matrix-module.nixosModules.default
mail-server.nixosModules.default
authoritative-dns.nixosModules.default
2023-12-04 17:10:57 -08:00
frigate-container.nixosModules.default
grafana-module.nixosModules.default
2024-02-10 16:53:55 -08:00
lemmy-container.nixosModules.default
immich-container.nixosModules.default
2024-05-21 23:16:02 -07:00
immich-ml-container.nixosModules.default
mabel.nixosModules.default
2023-05-16 22:40:08 -07:00
nexus.nixosModules.nexus-client
nexus.nixosModules.nexus-server
nexus.nixosModules.nexus-powerdns
2022-06-01 13:57:58 -07:00
./config
(config-dir + "/hardware/${hostname}.nix")
(config-dir + "/host-config/${hostname}.nix")
(config-dir + "/profile-config/${hostOpts.profile}.nix")
(config-dir + "/domain-config/${hostOpts.domain}.nix")
(config-dir + "/site-config/${hostOpts.site}.nix")
2024-05-21 23:16:02 -07:00
(import ./hardware-modules.nix nixos-hardware.nixosModules hostname)
2022-06-01 13:57:58 -07:00
];
2022-03-16 09:49:35 -07:00
2022-06-01 13:57:58 -07:00
config = let pkgs = pkgs-for hostOpts.arch;
in {
instance = let
build-seed =
builtins.readFile config.fudo.secrets.files.build-seed;
in { inherit hostname build-timestamp build-seed; };
environment.etc.nixos-live.source = ./.;
nix = {
registry = {
nixpkgs.flake = nixpkgs;
fudo-nixos.flake = self;
fudo-entities.flake = fudo-entities;
fudo-lib.flake = fudo-lib;
fudo-pkgs.flake = fudo-pkgs;
};
nixPath = let lib = nixpkgs.lib;
in lib.mkDefault (lib.mkBefore [ "nixpkgs=${nixpkgs}" ]);
2022-03-16 09:49:35 -07:00
};
2022-06-01 13:57:58 -07:00
nixpkgs.pkgs = pkgs;
2021-11-29 16:03:38 -08:00
};
2022-06-01 13:57:58 -07:00
};
2023-11-15 12:22:14 -08:00
mkFudoNixOsSystem = hostname: hostOpts:
2022-06-01 13:57:58 -07:00
let system = hostOpts.arch;
in nixosSystem {
inherit system;
2023-11-15 12:22:14 -08:00
modules = [ (mkFudoHostConfig hostname hostOpts) ];
2022-06-01 13:57:58 -07:00
};
2023-11-15 12:22:14 -08:00
mkFudoNixopsHostConfig = hostname: hostOpts:
2022-06-01 13:57:58 -07:00
let zone-hosts = fudo-entities.entities.zones.${hostOpts.domain}.hosts;
in {
imports = [
2023-11-15 12:22:14 -08:00
(mkFudoHostConfig hostname hostOpts)
2021-11-29 16:03:38 -08:00
2022-06-01 13:57:58 -07:00
(_: {
config.deployment.targetHost =
zone-hosts.${hostname}.ipv4-address;
})
];
2021-11-29 16:03:38 -08:00
};
in {
2023-11-15 12:22:14 -08:00
nixosConfigurations = mapAttrs mkFudoNixOsSystem fudo-nixos-hosts;
nixopsHostConfigurations =
mapAttrs mkFudoNixopsHostConfig fudo-nixos-hosts;
lib = {
inherit mkFudoHostConfig mkFudoNixOsSystem mkFudoNixopsHostConfig;
};
overlays = rec {
default = fudoHostConfig;
fudoHostConfig = (final: prev: {
lib = prev.lib // self.lib;
moduleRegistry = {
authoritativeDns = authoritative-dns.nixosModules.default;
};
});
};
2021-11-19 10:26:10 -08:00
};
}