nix-config/flake.nix

114 lines
3.2 KiB
Nix
Raw Normal View History

{
description = "C3D2 NixOS configurations";
2020-06-11 07:50:42 +02:00
inputs = {
2020-10-26 16:06:42 +01:00
nixpkgs.url = "github:nixos/nixpkgs/release-20.09";
2021-02-21 21:25:45 +01:00
secrets = {
url = "git+ssh://git@gitea.c3d2.de:2222/c3d2-admins/secrets.git";
flake = false;
};
2020-06-11 07:50:42 +02:00
};
2020-04-15 19:00:56 +02:00
2021-02-21 21:25:45 +01:00
outputs = { self, nixpkgs, secrets }:
let
forAllSystems = f:
nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ]
(system: f system);
in {
2021-02-21 21:25:45 +01:00
overlay = import ./nixpkgs-overlay;
2021-02-21 21:25:45 +01:00
legacyPackages = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
});
2020-08-04 17:15:07 +02:00
2021-02-21 21:25:45 +01:00
packages = forAllSystems (system:
let
pkgs = self.legacyPackages.${system};
2020-08-04 17:15:07 +02:00
2021-02-21 21:25:45 +01:00
mkDeploy =
# Generate a small script for copying this flake to the
# remote machine and bulding and switching there.
# Can be run with nix run c3d2#deploy-…
name: host:
let target = "root@${host}";
in pkgs.writeScriptBin "deploy-${name}" ''
#!${pkgs.runtimeShell}
set -ev
nix-copy-closure --to ${target} ${self}
exec ssh -t ${target} \
nix shell \
${self}#nixosConfigurations.${name}.config.system.build.toplevel \
--command switch-to-configuration $@
'';
in {
inherit (pkgs) bmxd;
inherit (pkgs.pile) ledball;
2020-08-04 17:15:07 +02:00
2021-02-21 21:25:45 +01:00
deploy-freifunk = mkDeploy "freifunk" "172.20.72.40";
deploy-glotzbert = mkDeploy "glotzbert" "glotzbert.hq.c3d2.de";
deploy-kibana = mkDeploy "kibana" "172.20.73.44";
deploy-ledstripes = mkDeploy "ledstripes" "172.22.99.168";
deploy-scrape = mkDeploy "scrape" "172.20.73.32";
});
2020-08-04 17:15:07 +02:00
2021-02-21 21:25:45 +01:00
nixosConfigurations = let
2021-02-21 21:25:45 +01:00
nixosSystem' =
# Our custom NixOS builder
{ modules, system ? "x86_64-linux", ... }@args:
nixpkgs.lib.nixosSystem (args // {
inherit system;
modules = modules ++ [
self.nixosModules.c3d2
({ pkgs, ... }: {
nix = {
package = pkgs.nixFlakes;
extraOptions = "experimental-features = nix-command flakes";
};
nixpkgs.overlays = [ self.overlay ];
})
];
});
2021-02-21 21:25:45 +01:00
in {
freifunk = nixosSystem' {
modules = [
(import ./hosts/containers/freifunk/configuration.nix {
inherit secrets;
})
];
};
glotzbert =
nixosSystem' { modules = [ ./hosts/glotzbert/configuration.nix ]; };
kibana = nixosSystem' {
modules = [ ./hosts/containers/kibana/configuration.nix ];
};
ledstripes = nixosSystem' {
modules = [ ./hosts/containers/ledstripes/configuration.nix ];
};
pulsebert =
nixosSystem' { modules = [ ./hosts/pulsebert/configuration.nix ]; };
scrape = nixosSystem' {
modules = [
(import ./hosts/containers/scrape/configuration.nix {
inherit secrets;
})
];
};
};
nixosModules.c3d2 = import ./lib;
};
}