nix-config/flake.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

1018 lines
33 KiB
Nix
Raw Normal View History

{
description = "C3D2 NixOS configurations";
2020-06-11 07:50:42 +02:00
inputs = {
2022-07-24 03:58:12 +02:00
nixos.url = "github:nixos/nixpkgs/nixos-22.05";
2022-06-16 23:48:49 +02:00
nixpkgs-mobilizon.url = "github:minijackson/nixpkgs/init-mobilizon";
nixos-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
2022-05-31 12:47:58 +02:00
nixos-hardware.url = "github:nixos/nixos-hardware";
2022-09-29 18:23:19 +02:00
nixos-armv6.url = "github:rnhmjoj/nixpkgs/pr-fix-armv6";
2022-09-14 23:16:06 +02:00
affection-src = {
url = "git+https://gitea.nek0.eu/nek0/affection";
inputs = {
nixpkgs.follows = "nixos";
2022-09-17 17:52:56 +02:00
flake-utils.follows = "flake-utils";
2022-09-14 23:16:06 +02:00
};
};
bevy-mandelbrot = {
# url = "github:matelab/bevy_mandelbrot";
url = "git+https://gitea.c3d2.de/astro/bevy-mandelbrot.git?ref=main";
inputs = {
naersk.follows = "naersk";
2022-09-17 17:52:56 +02:00
nixpkgs.follows = "nixos";
2022-09-14 23:16:06 +02:00
rust-overlay.follows = "rust-overlay";
};
};
bevy-julia = {
# url = "github:matelab/bevy_julia";
url = "git+https://gitea.c3d2.de/astro/bevy-julia.git?ref=main";
inputs = {
nixpkgs.follows = "nixos";
# breaks the build:
# naersk.follows = "naersk";
# naersk.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.follows = "rust-overlay";
};
};
2022-10-22 22:46:14 +02:00
# eris = {
# url = "git+https://codeberg.org/eris/nix-eris?ref=trunk";
# inputs.nixpkgs.follows = "nixos";
# };
2022-05-31 12:47:58 +02:00
fenix = {
url = "github:nix-community/fenix";
2022-07-24 03:58:12 +02:00
inputs.nixpkgs.follows = "nixos";
2022-05-31 12:47:58 +02:00
};
2022-08-18 23:59:07 +02:00
flake-utils.url = "github:numtide/flake-utils";
harmonia = {
url = "github:helsinki-systems/harmonia";
flake = false;
};
2022-05-31 12:47:58 +02:00
heliwatch = {
url = "git+https://gitea.c3d2.de/astro/heliwatch.git";
2022-04-17 22:45:05 +02:00
inputs = {
2022-05-31 12:47:58 +02:00
fenix.follows = "fenix";
2022-07-24 03:58:12 +02:00
nixpkgs.follows = "nixos";
2022-05-31 12:47:58 +02:00
naersk.follows = "naersk";
2022-09-03 01:26:45 +02:00
utils.follows = "flake-utils";
2022-04-17 22:45:05 +02:00
};
};
2022-06-24 01:02:11 +02:00
hydra.url = "github:nixos/hydra";
2022-06-28 20:34:54 +02:00
hydra-ca.url = "github:mlabs-haskell/hydra/aciceri/ca-derivations";
2022-05-31 12:47:58 +02:00
microvm = {
url = "github:astro/microvm.nix";
2022-08-18 23:59:07 +02:00
inputs = {
nixpkgs.follows = "nixos";
flake-utils.follows = "flake-utils";
};
2022-04-24 21:56:45 +02:00
};
2022-05-31 12:47:58 +02:00
naersk = {
url = "github:nix-community/naersk";
2022-09-17 17:52:56 +02:00
inputs = {
nixpkgs.follows = "nixos";
};
2022-05-31 12:47:58 +02:00
};
oparl-scraper = {
url = "github:offenesdresden/ratsinfo-scraper/oparl";
flake = false;
};
2022-05-31 12:47:58 +02:00
openwrt = {
url = "git+https://git.openwrt.org/openwrt/openwrt.git?ref=openwrt-21.02";
flake = false;
};
openwrt-imagebuilder = {
url = "github:astro/nix-openwrt-imagebuilder";
2022-04-17 22:45:05 +02:00
inputs = {
2022-07-24 03:58:12 +02:00
nixpkgs.follows = "nixos";
2022-05-31 12:47:58 +02:00
};
};
2022-09-14 23:16:06 +02:00
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
2022-09-17 17:52:56 +02:00
flake-utils.follows = "flake-utils";
2022-09-14 23:16:06 +02:00
nixpkgs.follows = "nixos";
};
};
2022-05-31 12:47:58 +02:00
scrapers = {
url = "git+https://gitea.c3d2.de/astro/scrapers.git";
flake = false;
};
2022-09-19 23:57:54 +02:00
sshlogd = {
url = "git+https://gitea.c3d2.de/astro/sshlogd.git?ref=main";
inputs = {
utils.follows = "flake-utils";
naersk.follows = "naersk";
nixpkgs.follows = "nixos";
fenix.follows = "fenix";
};
};
2022-05-31 12:47:58 +02:00
secrets = {
url = "git+ssh://gitea@gitea.c3d2.de/c3d2-admins/secrets.git";
inputs = {
2022-07-24 03:58:12 +02:00
nixpkgs.follows = "nixos";
2022-04-17 22:45:05 +02:00
};
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs = {
2022-07-24 03:58:12 +02:00
nixpkgs.follows = "nixos";
nixpkgs-22_05.follows = "nixos";
2022-04-17 22:45:05 +02:00
};
};
2022-05-31 12:47:58 +02:00
spacemsg = {
url = "github:astro/spacemsg";
flake = false;
};
2022-10-22 22:46:14 +02:00
# syndicate = {
# url = "git+https://git.syndicate-lang.org/ehmry/syndicate-flake";
# inputs = {
# nixpkgs.follows = "nixos";
# rust.follows = "rust-overlay";
# };
# };
2022-05-31 12:47:58 +02:00
ticker = {
url = "git+https://gitea.c3d2.de/astro/ticker.git";
2022-07-16 01:05:49 +02:00
inputs = {
fenix.follows = "fenix";
# TODO: build regression in https://github.com/nix-community/naersk/commit/6944160c19cb591eb85bbf9b2f2768a935623ed3
# naersk.follows = "naersk";
2022-07-24 03:58:12 +02:00
nixpkgs.follows = "nixos";
2022-08-18 23:59:07 +02:00
utils.follows = "flake-utils";
2022-07-16 01:05:49 +02:00
};
2022-05-31 12:47:58 +02:00
};
tigger = {
url = "github:astro/tigger";
flake = false;
};
tracer = {
# url = "git+https://gitea.nek0.eu/nek0/tracer";
url = "git+https://gitea.c3d2.de/astro/tracer";
inputs = {
2022-09-14 23:16:06 +02:00
affection-src.follows = "affection-src";
nixpkgs.follows = "nixos";
flake-utils.follows = "flake-utils";
};
2022-09-01 21:28:20 +02:00
};
2022-05-31 12:47:58 +02:00
yammat = {
2022-06-16 22:51:51 +02:00
url = "git+https://gitea.c3d2.de/C3D2/yammat.git?ref=nix";
2022-07-24 03:58:12 +02:00
inputs.nixpkgs.follows = "nixos";
2022-05-12 02:58:47 +02:00
};
2022-05-31 12:47:58 +02:00
zentralwerk = {
url = "git+https://gitea.c3d2.de/zentralwerk/network.git";
inputs = {
2022-07-24 03:58:12 +02:00
nixpkgs.follows = "nixos";
2022-05-31 12:47:58 +02:00
openwrt.follows = "openwrt";
openwrt-imagebuilder.follows = "openwrt-imagebuilder";
};
};
2020-06-11 07:50:42 +02:00
};
2020-04-15 19:00:56 +02:00
2022-10-22 22:46:14 +02:00
outputs = inputs@{ self, fenix, harmonia, heliwatch, microvm, naersk, nixos, nixos-hardware, nixos-unstable, oparl-scraper, scrapers, secrets, sshlogd, sops-nix, spacemsg, ticker, tigger, yammat, zentralwerk, ... }:
2021-02-22 12:31:58 +01:00
let
2022-07-24 03:58:12 +02:00
inherit (nixos) lib;
2022-01-13 18:38:36 +01:00
forAllSystems = lib.genAttrs [ "aarch64-linux" "x86_64-linux" ];
2021-02-24 11:52:19 +01:00
2022-07-16 01:00:45 +02:00
# all the input flakes for `nix copy` to the build machine,
# allowing --override-input
inputPaths = lib.escapeShellArgs (builtins.attrValues inputs);
extractZwHosts = { hosts4, hosts6, ... }:
2022-01-13 18:38:36 +01:00
lib.recursiveUpdate (
builtins.foldl' (result: name:
2022-01-13 18:38:36 +01:00
lib.recursiveUpdate result {
2021-10-31 19:00:03 +01:00
"${name}".ip4 = hosts4."${name}";
}
) {} (builtins.attrNames hosts4)
) (
builtins.foldl' (result: ctx:
builtins.foldl' (result: name:
2022-01-13 18:38:36 +01:00
lib.recursiveUpdate result {
2021-10-31 19:00:03 +01:00
"${name}".ip6 = hosts6."${ctx}"."${name}";
}
2021-10-31 19:00:03 +01:00
) result (builtins.attrNames hosts6."${ctx}")
) {} (builtins.attrNames hosts6)
);
zwHostRegistry = {
hosts =
builtins.foldl' (result: net:
2022-01-13 18:38:36 +01:00
lib.recursiveUpdate result (extractZwHosts zentralwerk.lib.config.site.net."${net}")
) {} [ "core" "c3d2" "serv" "flpk" "pub" ];
};
2022-01-16 13:26:37 +01:00
extraHostRegistry.hosts = import ./host-registry.nix;
2022-01-13 18:38:36 +01:00
hostRegistry = lib.recursiveUpdate zwHostRegistry extraHostRegistry;
getHostAddr = name:
let
2021-10-31 19:00:03 +01:00
hostConf = hostRegistry.hosts."${name}";
in
2022-09-09 23:34:10 +02:00
if hostConf ? ip4
2022-06-18 13:36:36 +02:00
then hostConf.ip4
2022-09-09 23:34:10 +02:00
else if hostConf ? ip6
then hostConf.ip6
else throw "Host ${name} has no ip4 or ip6 address";
in {
overlay = import ./overlay {
inherit nixos-unstable;
inherit (inputs) tracer bevy-mandelbrot bevy-julia;
};
2021-02-26 20:22:15 +01:00
2022-09-01 21:28:20 +02:00
legacyPackages = lib.attrsets.mapAttrs (system: pkgs:
pkgs.appendOverlays [
fenix.overlay
naersk.overlay
2022-10-22 22:46:14 +02:00
# syndicate.overlays.default
# eris.inputs.nimble.overlay
# eris.overlays.default
2022-09-01 21:28:20 +02:00
self.overlay
]) nixos.legacyPackages;
2022-01-13 18:38:36 +01:00
packages = lib.attrsets.mapAttrs (system: pkgs:
let overlayPkgs = builtins.intersectAttrs (self.overlay {} {}) pkgs;
in overlayPkgs //
{
host-registry = pkgs.runCommand "host-registry" {
src = builtins.toFile "host-registry.nix" (
lib.generators.toPretty {} hostRegistry
);
} ''
ln -s $src $out
'';
2021-02-26 20:22:15 +01:00
2021-09-08 00:34:38 +02:00
list-upgradable = pkgs.writeScriptBin "list-upgradable" ''
#! ${pkgs.runtimeShell}
NORMAL="\033[0m"
RED="\033[0;31m"
YELLOW="\033[0;33m"
GREEN="\033[0;32m"
${pkgs.lib.concatMapStringsSep "\n" (name:
let
addr = getHostAddr name;
2022-07-24 03:58:12 +02:00
in nixos.lib.optionalString (addr != null) ''
2021-09-08 00:34:38 +02:00
echo -n -e "${name}: $RED"
RUNNING=$(ssh -o PreferredAuthentications=publickey -o StrictHostKeyChecking=accept-new root@"${addr}" "readlink /run/current-system")
if [ $? = 0 ] && [ -n "$RUNNING" ]; then
2021-09-08 00:34:38 +02:00
CURRENT=$(nix eval --raw ".#nixosConfigurations.${name}.config.system.build.toplevel" 2>/dev/null)
RUNNING_VER=$(basename $RUNNING|rev|cut -d - -f 1|rev)
RUNNING_DATE=$(echo $RUNNING_VER|cut -d . -f 3)
CURRENT_VER=$(basename $CURRENT|rev|cut -d - -f 1|rev)
CURRENT_DATE=$(echo $CURRENT_VER|cut -d . -f 3)
2021-09-08 00:34:38 +02:00
if [ "$RUNNING" = "$CURRENT" ]; then
echo -e "$GREEN"current"$NORMAL $RUNNING_VER"
elif [ $RUNNING_DATE -gt $CURRENT_DATE ]; then
echo -e "$GREEN"newer"$NORMAL $RUNNING_VER > $CURRENT_VER"
elif [ "$RUNNING_VER" = "$CURRENT_VER" ]; then
echo -e "$YELLOW"modified"$NORMAL $RUNNING_VER"
elif [ -n "$RUNNING_VER" ]; then
echo -e "$RED"outdated"$NORMAL $RUNNING_VER < $CURRENT_VER"
else
echo -e "$RED"error"$NORMAL $RUNNING_VER"
2021-09-08 00:34:38 +02:00
fi
fi
echo -n -e "$NORMAL"
2022-01-20 03:12:37 +01:00
'') (builtins.attrNames self.nixosConfigurations)}
2021-09-08 00:34:38 +02:00
'';
2021-10-18 22:26:38 +02:00
2022-09-26 23:47:36 +02:00
prebuild-all = pkgs.runCommand "prebuild-all" {
2021-10-18 22:26:38 +02:00
preferLocalBuild = true;
} ''
mkdir $out
${pkgs.lib.concatMapStrings (name: ''
2021-10-31 19:00:03 +01:00
ln -s ${self.nixosConfigurations."${name}".config.system.build.toplevel} name
2022-01-20 03:12:37 +01:00
'') (builtins.attrNames self.nixosConfigurations)}
2021-10-18 22:26:38 +02:00
'';
2021-11-10 00:33:42 +01:00
prebuild-all-remote = pkgs.writeScriptBin "prebuild-all" ''
#!${pkgs.runtimeShell} -e
2022-09-21 20:25:01 +02:00
nix copy --no-check-sigs --to ssh-ng://$1 ${inputPaths}
2021-11-10 00:33:42 +01:00
set -x
2022-06-17 21:27:38 +02:00
ssh $1 -- nix build -L --no-link ${
2021-11-10 00:33:42 +01:00
pkgs.lib.concatMapStringsSep " " (name:
"${self}#nixosConfigurations.${name}.config.system.build.toplevel"
2022-01-20 03:12:37 +01:00
) (builtins.attrNames self.nixosConfigurations)
2021-11-10 00:33:42 +01:00
}
'';
} //
builtins.foldl' (result: host: result // {
2021-09-29 23:26:05 +02:00
# TODO: check if the ethernet address is reachable and if not,
# execute wol on a machine in HQ.
"${host}-wake" = pkgs.writeScriptBin "${host}-wake" ''
#!${pkgs.runtimeShell}
2021-10-31 19:00:03 +01:00
exec ${pkgs.wol}/bin/wol ${hostRegistry.hosts."${host}".ether}
2021-09-29 23:26:05 +02:00
'';
2022-07-24 03:58:12 +02:00
}) {} (builtins.attrNames (nixos.lib.filterAttrs (_: { wol ? false, ... }: wol) hostRegistry.hosts)) //
2021-09-29 23:26:05 +02:00
builtins.foldl' (result: name:
let
host = getHostAddr name;
2021-09-29 23:26:05 +02:00
target = ''root@"${host}"'';
rebuildArg = "--flake ${self}#${name} --option extra-substituters https://nix-serve.hq.c3d2.de";
hostConfig = self.nixosConfigurations."${name}".config;
profile = hostConfig.system.build.toplevel;
2022-06-21 15:06:52 +02:00
# let /var/lib/microvm/*/flake point to the flake-update branch so that
# `microvm -u $NAME` updates to what hydra built today.
selfRef = "git+https://gitea.c3d2.de/c3d2/nix-config?ref=flake-update";
2021-09-29 23:26:05 +02:00
in result // {
# Generate a small script for copying this flake to the
# remote machine and bulding and switching there.
# Can be run with `nix run c3d2#…-nixos-rebuild switch`
"${name}-nixos-rebuild" = pkgs.writeScriptBin "${name}-nixos-rebuild" ''
2021-10-31 12:49:09 +01:00
#!${pkgs.runtimeShell} -ex
[[ $(ssh ${target} cat /etc/hostname) == ${name} ]]
2022-09-21 20:25:01 +02:00
nix copy --no-check-sigs --to ssh-ng://${target} ${inputPaths}
ssh ${target} nixos-rebuild ${rebuildArg} "$@"
2021-09-08 22:48:13 +02:00
'';
2021-09-29 23:26:05 +02:00
"${name}-nixos-rebuild-hydra" = pkgs.writeScriptBin "${name}-nixos-rebuild" ''
#!${pkgs.runtimeShell} -e
2022-07-16 01:00:45 +02:00
echo Copying Flakes
2022-09-21 20:25:01 +02:00
nix copy --no-check-sigs --to ssh-ng://root@hydra.serv.zentralwerk.org ${inputPaths}
echo Building on Hydra
ssh root@hydra.serv.zentralwerk.org -- \
nix build -L -o /tmp/nixos-system-${name} \
${self}#nixosConfigurations.${name}.config.system.build.toplevel
echo Built. Obtaining link to data
TOPLEVEL=$(ssh root@hydra.serv.zentralwerk.org \
readlink /tmp/nixos-system-${name})
echo Checking target ${name}
ssh ${target} -- bash -e <<EOF
[[ \$(cat /etc/hostname) == ${name} ]]
echo Copying data from Hydra to ${name}
nix copy --from https://nix-serve.hq.c3d2.de \
$TOPLEVEL
echo Activation on ${name}: "$@"
nix-env -p /nix/var/nix/profiles/system --set $TOPLEVEL
$TOPLEVEL/bin/switch-to-configuration "$@"
EOF
'';
2021-09-30 20:54:02 +02:00
"${name}-nixos-rebuild-local" = pkgs.writeScriptBin "${name}-nixos-rebuild" ''
2021-10-31 12:49:09 +01:00
#!${pkgs.runtimeShell} -ex
[[ $1 == build || $(ssh ${target} cat /etc/hostname) == ${name} ]]
${pkgs.nixos-rebuild}/bin/nixos-rebuild ${rebuildArg} --target-host ${target} --use-remote-sudo "$@"
'';
2021-09-29 23:26:05 +02:00
2021-09-30 20:54:02 +02:00
"${name}-cleanup" = pkgs.writeScriptBin "${name}-cleanup" ''
2021-10-31 12:49:09 +01:00
#!${pkgs.runtimeShell} -ex
ssh ${target} "time nix-collect-garbage -d && time nix-store --optimise"
'';
} // lib.optionalAttrs (builtins.elem (hostConfig.c3d2.deployment.server or null) [ "server9" "server10" ]) {
"microvm-update-${name}" = pkgs.writeScriptBin "microvm-update-${name}" ''
#!${pkgs.runtimeShell} -e
2022-07-16 01:00:45 +02:00
${hostConfig.system.build.copyToServer} ${inputPaths}
${hostConfig.system.build.runOnServer} bash -e <<END
mkdir -p /var/lib/microvms/${name}
cd /var/lib/microvms/${name}
chown root:kvm .
chmod 0775 .
rm -f old
[ -e current ] && mv current old
2022-06-17 21:27:38 +02:00
nix build -L \
-o current \
${self}#nixosConfigurations.${name}.config.microvm.declaredRunner
echo '${selfRef}' > flake
[ -e old ] && nix store diff-closures ./old ./current
ln -sfT \$PWD/current /nix/var/nix/gcroots/microvm/${name}
ln -sfT \$PWD/booted /nix/var/nix/gcroots/microvm/booted-${name}
ln -sfT \$PWD/old /nix/var/nix/gcroots/microvm/old-${name}
systemctl restart microvm@${name}.service
END
'';
2022-09-12 18:49:58 +02:00
"microvm-update-${name}-local" = pkgs.writeScriptBin "microvm-update-${name}" ''
#!${pkgs.runtimeShell} -e
${hostConfig.system.build.copyToServer} ${hostConfig.microvm.declaredRunner}
${hostConfig.system.build.runOnServer} bash -e <<END
mkdir -p /var/lib/microvms/${name}
cd /var/lib/microvms/${name}
chown root:kvm .
chmod 0775 .
rm -f old
[ -e current ] && mv current old
ln -sfT ${hostConfig.microvm.declaredRunner} current
echo '${selfRef}' > flake
[ -e old ] && nix store diff-closures ./old ./current
ln -sfT \$PWD/current /nix/var/nix/gcroots/microvm/${name}
ln -sfT \$PWD/booted /nix/var/nix/gcroots/microvm/booted-${name}
ln -sfT \$PWD/old /nix/var/nix/gcroots/microvm/old-${name}
systemctl restart microvm@${name}.service
END
'';
2022-07-05 00:08:03 +02:00
2022-09-12 18:49:58 +02:00
} // lib.optionalAttrs (hostConfig.c3d2.deployment.server or null == "nomad") {
2022-07-05 00:08:03 +02:00
"nomad-${name}" = pkgs.writeScriptBin "nomad-${name}" ''
#!${pkgs.runtimeShell} -e
echo Copying Flakes
2022-09-21 20:25:01 +02:00
nix copy --no-check-sigs --to ssh-ng://root@hydra.serv.zentralwerk.org ${secrets} ${self}
2022-07-05 00:08:03 +02:00
echo Building on Hydra
ssh root@hydra.serv.zentralwerk.org -- \
nix build -L -o /tmp/microvm-${name}.job \
${self}#nixosConfigurations.${name}.config.system.build.nomadJob
echo -n Built. Obtaining path...
JOB=$(ssh root@hydra.serv.zentralwerk.org -- \
readlink /tmp/microvm-${name}.job)
echo \ $JOB
for h in server9 server10 ; do
echo Sharing with $h
ssh root@$h.cluster.zentralwerk.org -- \
bash -e <<EOF &
nix copy --from https://nix-serve.hq.c3d2.de $JOB
2022-07-07 01:21:39 +02:00
mkdir -p /glusterfs/fast/microvms/${name}
chown microvm:kvm /glusterfs/fast/microvms/${name}
chmod 0775 /glusterfs/fast/microvms/${name}
mkdir -p /nix/var/nix/gcroots/microvm
rm -f /nix/var/nix/gcroots/microvm/${name}
ln -sfT $JOB /nix/var/nix/gcroots/microvm/${name}
2022-07-07 01:21:39 +02:00
EOF
2022-07-05 00:08:03 +02:00
done
wait
2022-07-05 00:08:03 +02:00
echo Now starting the job
ssh root@hydra.serv.zentralwerk.org -- \
nomad run -detach $JOB
'';
2022-01-20 03:12:37 +01:00
}) {} (builtins.attrNames self.nixosConfigurations) //
2021-09-23 19:34:09 +02:00
builtins.foldl' (result: host:
let
inherit (self.nixosConfigurations.${host}) config;
in
result //
2022-07-24 03:58:12 +02:00
nixos.lib.optionalAttrs (config.system.build ? vm) {
2022-05-24 17:02:12 +02:00
# boot any machine in a microvm
"${host}-vm" = (self.nixosConfigurations.${host}
.extendModules {
2022-10-21 23:11:15 +02:00
modules = [ {
microvm = {
mem = nixos.lib.mkForce 2048;
hypervisor = nixos.lib.mkForce "qemu";
socket = nixos.lib.mkForce null;
shares = nixos.lib.mkForce [ {
tag = "ro-store";
source = "/nix/store";
mountPoint = "/nix/.ro-store";
} ];
interfaces = nixos.lib.mkForce [ {
type = "user";
id = "eth0";
mac = "02:23:de:ad:be:ef";
} ];
};
boot.isContainer = lib.mkForce false;
users.users.root.password = "";
fileSystems."/".fsType = lib.mkForce "tmpfs";
services.getty.helpLine = ''
Log in as "root" with an empty password.
Use "reboot" to shut qemu down.
'';
2022-10-21 23:11:15 +02:00
} ] ++ lib.optionals (! config ? microvm) [
microvm.nixosModules.microvm
2022-05-24 17:02:12 +02:00
];
})
.config.microvm.declaredRunner;
} //
2022-07-24 03:58:12 +02:00
nixos.lib.optionalAttrs (config.system.build ? tftproot) {
"${host}-tftproot" = config.system.build.tftproot;
}
) {} (builtins.attrNames self.nixosConfigurations)
2022-01-13 18:38:36 +01:00
) self.legacyPackages;
2020-08-04 17:15:07 +02:00
2021-02-22 12:31:58 +01:00
nixosConfigurations = let
nixosSystem' =
# Our custom NixOS builder
2022-07-24 03:58:12 +02:00
{ nixpkgs ? inputs.nixos, modules, extraArgs ? {}, specialArgs ? { }, system ? "x86_64-linux" }:
nixpkgs.lib.nixosSystem {
2022-06-24 01:02:11 +02:00
inherit specialArgs system;
modules = [
2021-02-22 12:31:58 +01:00
({ pkgs, ... }: {
_module.args = extraArgs // {
inherit hostRegistry inputs zentralwerk;
};
2022-03-29 00:01:14 +02:00
nixpkgs = {
overlays = [ self.overlay ];
};
2021-02-22 12:31:58 +01:00
})
self.nixosModules.c3d2
2022-09-28 21:10:09 +02:00
./modules/audio-server.nix
./modules/c3d2.nix
./modules/stats.nix
./modules/pi-sensors.nix
] ++ modules;
};
2021-02-22 12:31:58 +01:00
in {
2022-07-23 00:06:12 +02:00
auth = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/auth
2022-07-23 00:06:12 +02:00
];
2022-09-04 16:04:28 +02:00
nixpkgs = inputs.nixos-unstable;
2022-07-23 00:06:12 +02:00
};
2020-08-04 17:15:07 +02:00
2022-07-16 02:03:47 +02:00
broker = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/broker
2022-07-16 02:03:47 +02:00
];
};
2022-08-05 19:08:22 +02:00
factorio = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/factorio
];
2022-08-21 22:58:22 +02:00
nixpkgs = inputs.nixos-unstable;
2022-08-05 19:08:22 +02:00
};
2021-02-26 20:22:15 +01:00
freifunk = nixosSystem' {
2021-03-05 01:16:57 +01:00
modules = [
self.nixosModules.microvm
./hosts/freifunk
2022-01-13 18:38:36 +01:00
{
2021-03-05 01:16:57 +01:00
nixpkgs.overlays = with secrets.overlays; [
freifunk ospf
];
2022-01-13 18:38:36 +01:00
}
2021-03-05 01:16:57 +01:00
];
2021-02-26 20:22:15 +01:00
};
2022-07-16 20:38:23 +02:00
ftp = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/ftp
2022-07-16 20:38:23 +02:00
];
};
2021-10-02 20:28:30 +02:00
gitea = nixosSystem' {
modules = [
2022-06-20 22:10:23 +02:00
self.nixosModules.microvm
./hosts/gitea
2021-10-02 20:28:30 +02:00
];
nixpkgs = inputs.nixos-unstable;
2021-10-02 20:28:30 +02:00
};
2021-02-22 13:21:31 +01:00
glotzbert = nixosSystem' {
modules = [
./hosts/glotzbert
nixos-hardware.nixosModules.common-cpu-intel
nixos-hardware.nixosModules.common-pc-ssd
2022-08-07 18:52:11 +02:00
# TODO: migrate away from secrets repo
2021-03-12 17:06:37 +01:00
secrets.nixosModules.admins
];
2021-02-22 13:21:31 +01:00
};
2022-06-21 22:00:17 +02:00
hedgedoc = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/hedgedoc
2022-06-21 22:00:17 +02:00
];
nixpkgs = inputs.nixos-unstable;
2022-06-21 22:00:17 +02:00
};
2021-02-22 13:21:31 +01:00
pulsebert = nixosSystem' {
2021-09-23 19:34:09 +02:00
modules = [
./hosts/pulsebert
2022-09-04 13:13:59 +02:00
# build: outputs.nixosConfigurations.pulsebert.config.system.build.sdImage
# run: unzstd -cd result/sd-image/nixos-sd-image-*-aarch64-linux.img.zst | pv -br | sudo dd bs=4M of=/dev/sdX
"${inputs.nixos-unstable}/nixos/modules/installer/sd-card/sd-image-aarch64-new-kernel.nix"
2022-09-25 19:47:58 +02:00
{
nixpkgs = {
hostPlatform = "aarch64-linux";
# buildPlatform = "x86_64-linux";
};
}
2021-09-23 19:34:09 +02:00
];
nixpkgs = inputs.nixos-unstable;
2021-02-22 13:21:31 +01:00
};
2020-08-04 17:15:07 +02:00
2021-09-23 03:32:17 +02:00
radiobert = nixosSystem' {
modules = [
2022-01-13 18:38:36 +01:00
({ modulesPath, ... }:
{
nixpkgs.overlays = [ heliwatch.overlay ];
2022-01-13 18:38:36 +01:00
})
2021-09-23 03:32:17 +02:00
./hosts/radiobert
];
system = "aarch64-linux";
};
2022-10-22 22:46:14 +02:00
# nncp = nixosSystem' {
# modules = [
# self.nixosModules.microvm
# self.nixosModules.nncp
# syndicate.nixosModules.default
# ./hosts/nncp
# {
# nixpkgs.overlays = [
# syndicate.overlays.default
# eris.inputs.nimble.overlay
# eris.overlays.default
# ];
# }
# ];
# };
2022-01-15 11:28:23 +01:00
2021-09-27 22:19:24 +02:00
dacbert = nixosSystem' {
modules = [
2021-10-07 20:19:48 +02:00
nixos-hardware.nixosModules.raspberry-pi-4
2022-03-16 23:16:02 +01:00
self.nixosModules.rpi-netboot
2021-09-27 22:19:24 +02:00
./hosts/dacbert
];
system = "aarch64-linux";
};
2022-03-13 23:49:12 +01:00
rpi-netboot = nixosSystem' {
modules = [
2022-07-24 03:58:12 +02:00
{ _module.args = { inherit nixos; }; }
2022-03-13 23:49:12 +01:00
nixos-hardware.nixosModules.raspberry-pi-4
self.nixosModules.rpi-netboot
2022-03-13 23:49:12 +01:00
./hosts/rpi-netboot
];
system = "aarch64-linux";
2022-09-26 22:45:34 +02:00
};
schalter = nixosSystem' {
2022-09-29 18:23:19 +02:00
nixpkgs = inputs.nixos-armv6;
modules = [
2022-09-26 22:45:34 +02:00
"${nixos}/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix"
({ lib, ... }: {
networking.hostName = "schalter";
hardware.enableRedistributableFirmware = true;
#networking.wireless.enable = true;
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
boot = {
loader = {
grub.enable = false;
raspberryPi = {
enable = true;
version = 1;
2022-09-26 22:45:34 +02:00
uboot.enable = false;
};
2022-09-26 22:45:34 +02:00
generic-extlinux-compatible.enable = lib.mkForce false;
};
# supportedFilesystems = lib.mkForce [ "vfat" "ext4" ];
tmpOnTmpfs = true;
};
nixpkgs.config.packageOverrides = pkgs: {
makeModulesClosure = x:
# prevent kernel install fail due to missing modules
pkgs.makeModulesClosure (x // { allowMissing = true; });
};
sdImage = {
compressImage = false;
imageBaseName = "schalter";
firmwareSize = 512;
};
2022-09-26 22:45:34 +02:00
nixpkgs.crossSystem = nixos.lib.systems.examples.raspberryPi;
})
];
2022-09-26 22:45:34 +02:00
system = "x86_64-linux";
2022-03-13 23:49:12 +01:00
};
2021-03-06 01:13:27 +01:00
matemat = nixosSystem' {
modules = [
2022-06-17 21:27:38 +02:00
self.nixosModules.microvm
./hosts/matemat
2021-03-10 01:54:28 +01:00
yammat.nixosModule
2022-08-07 18:52:11 +02:00
# TODO: migrate away from secrets repo
secrets.nixosModules.admins
2022-01-13 20:20:48 +01:00
{ nixpkgs.overlays = [ secrets.overlays.matemat ]; }
2021-03-06 01:13:27 +01:00
];
};
2021-03-06 02:57:35 +01:00
scrape = nixosSystem' {
modules = [
2022-06-17 00:05:21 +02:00
self.nixosModules.microvm
./hosts/scrape
2022-06-17 00:05:21 +02:00
{
nixpkgs.overlays = [ secrets.overlays.scrape ];
_module.args = { inherit scrapers; };
}
2021-03-06 02:57:35 +01:00
];
};
2021-03-11 15:59:00 +01:00
dn42 = nixosSystem' {
modules = [
2022-06-16 23:17:10 +02:00
self.nixosModules.microvm
./hosts/dn42
{
2021-03-11 15:59:00 +01:00
nixpkgs.overlays = [ secrets.overlays.dn42 ];
}
2021-03-11 15:59:00 +01:00
];
};
2021-03-11 16:40:39 +01:00
grafana = nixosSystem' {
modules = [
2022-06-18 02:09:33 +02:00
self.nixosModules.microvm
./hosts/grafana
2021-03-11 16:40:39 +01:00
];
};
2021-03-12 21:45:12 +01:00
hydra = nixosSystem' {
modules = [
2022-05-12 02:58:47 +02:00
inputs.hydra.nixosModules.hydra
(harmonia + "/module.nix")
2022-05-05 22:34:51 +02:00
./hosts/hydra
{
_module.args = {
inherit self;
inherit (inputs) hydra-ca;
};
}
2021-03-12 21:45:12 +01:00
];
};
2021-03-22 16:22:57 +01:00
mucbot = nixosSystem' {
modules = [
{ _module.args = { inherit tigger; }; }
2022-06-16 21:36:52 +02:00
self.nixosModules.microvm
self.nixosModules.nomad-microvm
2021-03-22 16:22:57 +01:00
"${tigger}/module.nix"
{ nixpkgs.overlays = [ secrets.overlays.mucbot ]; }
./hosts/mucbot
2021-03-22 16:22:57 +01:00
];
};
2021-06-23 21:59:10 +02:00
public-access-proxy = nixosSystem' {
modules = [
2022-06-16 22:23:36 +02:00
self.nixosModules.microvm
./hosts/public-access-proxy
2021-06-23 21:59:10 +02:00
];
};
2021-09-08 01:22:40 +02:00
ticker = nixosSystem' {
modules = [
2022-06-16 21:26:57 +02:00
self.nixosModules.microvm
ticker.nixosModules.ticker
./hosts/ticker
2021-09-08 01:22:40 +02:00
];
};
2021-09-10 00:21:38 +02:00
spaceapi = nixosSystem' {
modules = [
2022-06-16 21:38:53 +02:00
self.nixosModules.microvm
2021-09-10 00:21:38 +02:00
"${spacemsg}/spaceapi/module.nix"
./hosts/spaceapi
2021-09-10 00:21:38 +02:00
];
};
2021-09-10 22:59:40 +02:00
stream = nixosSystem' {
modules = [
2022-06-28 03:26:08 +02:00
self.nixosModules.microvm
./hosts/stream
2021-09-10 22:59:40 +02:00
];
};
mobilizon = nixosSystem' {
# TODO: pending https://github.com/NixOS/nixpkgs/pull/119132
nixpkgs = inputs.nixpkgs-mobilizon;
modules = [
2022-06-16 23:48:49 +02:00
self.nixosModules.microvm
./hosts/mobilizon
];
};
2021-10-06 02:55:30 +02:00
c3d2-web = nixosSystem' {
modules = [
2022-07-24 03:58:12 +02:00
{ _module.args = { inherit nixos; }; }
2022-06-18 02:42:41 +02:00
self.nixosModules.microvm
./hosts/c3d2-web
2022-01-13 18:38:36 +01:00
{ nixpkgs.overlays = [ secrets.overlays.c3d2-web ]; }
2021-10-06 02:55:30 +02:00
];
};
2021-10-07 23:00:50 +02:00
sdrweb = nixosSystem' {
modules = [
2022-06-19 22:29:08 +02:00
self.nixosModules.microvm
self.nixosModules.nomad-microvm
2021-10-30 02:02:08 +02:00
{ nixpkgs.overlays = [ secrets.overlays.mucbot ]; }
2021-11-09 01:23:35 +01:00
heliwatch.nixosModules.heliwatch
./hosts/sdrweb
2021-10-07 23:00:50 +02:00
];
2022-07-24 03:58:12 +02:00
nixpkgs = nixos-unstable;
2021-10-07 23:00:50 +02:00
};
2021-10-15 02:07:50 +02:00
bind = nixosSystem' {
modules = [
2022-01-13 18:38:36 +01:00
{ nixpkgs.overlays = with secrets.overlays; [ bind ]; }
2022-06-18 02:43:11 +02:00
self.nixosModules.microvm
./hosts/bind
2021-10-15 02:07:50 +02:00
];
};
2021-10-18 03:46:25 +02:00
jabber = nixosSystem' {
modules = [
2022-01-13 18:38:36 +01:00
{ nixpkgs.overlays = with secrets.overlays; [ jabber ]; }
2022-06-20 00:15:34 +02:00
self.nixosModules.microvm
./hosts/jabber
2021-10-18 03:46:25 +02:00
];
};
2021-12-24 03:18:20 +01:00
blogs = nixosSystem' {
modules = [
self.nixosModules.plume
2022-06-20 00:06:32 +02:00
self.nixosModules.microvm
./hosts/blogs
2021-12-24 03:18:20 +01:00
];
};
2022-06-18 01:07:43 +02:00
server9 = nixosSystem' {
modules = [
./hosts/server9
microvm.nixosModules.host
self.nixosModules.microvm-host
2022-06-18 01:07:43 +02:00
self.nixosModules.cluster-network
self.nixosModules.cluster
2022-06-18 01:07:43 +02:00
{ _module.args = { inherit self; }; }
];
};
2022-05-14 20:33:56 +02:00
server10 = nixosSystem' {
modules = [
./hosts/server10
2022-05-15 02:46:14 +02:00
microvm.nixosModules.host
self.nixosModules.microvm-host
self.nixosModules.cluster-network
self.nixosModules.cluster
{ _module.args = { inherit self; }; }
2022-05-14 20:33:56 +02:00
];
};
2022-05-28 00:12:18 +02:00
oparl = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/oparl
{
_module.args = { inherit oparl-scraper; };
}
2022-05-28 00:12:18 +02:00
];
};
2022-06-01 20:46:47 +02:00
leon = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/leon
2022-06-01 20:46:47 +02:00
];
};
2022-09-05 22:17:11 +02:00
leoncloud = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/leoncloud
];
};
2022-06-07 20:15:09 +02:00
nfsroot = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/nfsroot
{
2022-07-24 03:58:12 +02:00
_module.args.tftproots = nixos.lib.filterAttrs (name: _:
builtins.match ".+-tftproot" name != null
) self.packages.x86_64-linux;
}
];
2022-06-07 20:15:09 +02:00
};
2022-06-08 22:55:35 +02:00
riscbert = nixosSystem' {
modules = [
nixos-hardware.nixosModules.starfive-visionfive-v1
2022-06-08 22:55:35 +02:00
./hosts/riscbert
2022-10-13 20:03:37 +02:00
{
nixpkgs.crossSystem = {
config = "riscv64-unknown-linux-gnu";
system = "riscv64-linux";
};
}
2022-06-08 22:55:35 +02:00
];
2022-10-13 20:03:37 +02:00
nixpkgs = nixos-unstable;
2022-09-05 04:18:00 +02:00
system = "x86_64-linux";
2022-06-08 22:55:35 +02:00
};
2022-06-18 00:50:08 +02:00
direkthilfe = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/direkthilfe
2022-06-18 00:50:08 +02:00
];
};
2022-06-23 18:38:42 +02:00
mediawiki = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/mediawiki
2022-06-23 18:38:42 +02:00
];
nixpkgs = nixos-unstable;
2022-06-23 18:38:42 +02:00
};
2022-07-06 21:09:04 +02:00
gnunet = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/gnunet
2022-07-06 21:09:04 +02:00
];
2022-07-24 03:58:12 +02:00
nixpkgs = nixos-unstable;
2022-07-06 21:09:04 +02:00
};
2022-09-15 20:32:50 +02:00
zengel = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/zengel
];
};
2022-09-19 23:57:54 +02:00
sshlog = nixosSystem' {
modules = [
self.nixosModules.microvm
sshlogd.nixosModule
./hosts/sshlog
];
};
2022-10-22 21:38:12 +02:00
network-homepage = nixosSystem' {
modules = [
self.nixosModules.microvm
./hosts/network-homepage
];
};
2020-08-04 17:15:07 +02:00
};
nixosModule = self.nixosModules.c3d2;
2022-01-13 18:38:36 +01:00
nixosModules = {
2022-01-18 21:44:17 +01:00
c3d2 = {
2022-01-16 00:09:17 +01:00
imports = [
sops-nix.nixosModule
./modules/c3d2.nix
2022-01-18 15:39:35 +01:00
./modules/nncp.nix
./modules/autoupdate.nix
2022-01-16 00:09:17 +01:00
];
2022-01-16 13:26:37 +01:00
c3d2.hosts = hostRegistry.hosts;
2022-01-16 00:09:17 +01:00
c3d2.users = import ./users.nix;
2022-09-28 21:10:09 +02:00
c3d2.nncp.neigh = import ./modules/nncp-relays.nix;
2022-01-16 00:09:17 +01:00
};
cluster = ./modules/cluster;
cluster-network = ./modules/cluster-network.nix;
microvm.imports = [
microvm.nixosModules.microvm
./modules/microvm.nix
];
microvm-host = ./modules/microvm-host.nix;
2022-01-15 11:00:01 +01:00
nncp = ./modules/nncp.nix;
nomad-microvm = ./modules/nomad-microvm.nix;
2022-01-13 18:38:36 +01:00
plume = {
imports = [ ./modules/plume.nix ];
2022-01-13 18:38:36 +01:00
nixpkgs.overlays = [ fenix.overlay naersk.overlay ];
};
rpi-netboot = ./modules/rpi-netboot.nix;
2022-01-13 18:38:36 +01:00
};
2021-11-10 00:33:29 +01:00
# `nix develop`
devShell = lib.mapAttrs (system: sopsPkgs:
2022-07-31 18:08:28 +02:00
with nixos.legacyPackages.${system};
mkShell {
sopsPGPKeyDirs = [ "./keys" ];
nativeBuildInputs = [
sopsPkgs.sops-import-keys-hook
];
}
) sops-nix.packages;
hydraJobs =
2022-07-24 03:58:12 +02:00
builtins.mapAttrs (_: nixos.lib.hydraJob) (
builtins.mapAttrs (_: nixosSystem:
if nixosSystem.config ? microvm.declaredRunner
then nixosSystem.config.microvm.declaredRunner
else nixosSystem.config.system.build.toplevel
) self.nixosConfigurations
//
2022-07-24 03:58:12 +02:00
nixos.lib.filterAttrs (name: _:
builtins.match ".+-tftproot" name != null
) self.packages.aarch64-linux
);
2021-02-22 12:31:58 +01:00
};
}