cluster/flake.nix
Magic_RB 2391236a38
Change how we get the current branch name
Signed-off-by: Magic_RB <magic_rb@redalder.org>
2023-04-23 23:20:18 +02:00

102 lines
4.2 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
nixng = {
url = "github:nix-community/NixNG";
inputs.nixpkgs.follows = "nixpkgs";
};
website = {
url = "git+https://gitea.redalder.org/Magic_RB/website";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nixng, ... }@inputs:
with nixpkgs.lib;
let
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
forAllSystems' = systems: fun: nixpkgs.lib.genAttrs systems fun;
forAllSystems = forAllSystems' supportedSystems;
pkgsForSystem = system:
import nixpkgs { inherit system; };
in
{
nixngSystems =
let base = { nglib = nixng.nglib; inherit nixpkgs; };
in
{ hydra = (import ./containers/hydra.nix base).hydra;
hydraPostgresql = (import ./containers/hydra.nix base).postgresql;
ingressToothpick = import ./containers/ingress-toothpick.nix base;
ingressBlowhole = import ./containers/ingress-blowhole.nix base;
website = import ./containers/website.nix (base // { inherit (inputs.website) website; });
gitea = import ./containers/gitea.nix base;
minecraft = import ./containers/minecraft.nix base;
mosquitto = import ./containers/mosquitto.nix base;
dovecot = import ./containers/dovecot.nix base;
getmail = import ./containers/getmail base;
syncthing = import ./containers/syncthing.nix base;
zigbee2mqtt = import ./containers/zigbee2mqtt.nix base;
home-assistant = (import ./containers/home-assistant.nix base).home-assistant;
home-assistantPostgresql = (import ./containers/home-assistant.nix base).postgresql;
reicio = import ./containers/reicio.nix base;
baikal = import ./containers/baikal.nix base;
conduit = (import ./containers/conduit.nix base).synapse;
synapseFederationSender = (import ./containers/conduit.nix base).synapseFederationSender;
synapseFederationReceiver = (import ./containers/conduit.nix base).synapseFederationReceiver;
synapseClient = (import ./containers/conduit.nix base).synapseClient;
synapseSync = (import ./containers/conduit.nix base).synapseSync;
conduitPostgresql = (import ./containers/conduit.nix base).postgresql;
conduitRedis = (import ./containers/conduit.nix base).redis;
mautrix-facebook = import ./containers/mautrix-facebook.nix base;
heisenbridge = import ./containers/heisenbridge.nix base;
};
hydraJobs =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
makeJob = container:
container.config.system.build.toplevel;
in
nixpkgs.lib.mapAttrs (n: v: makeJob v) self.nixngSystems;
apps = forAllSystems (system:
let pkgs = pkgsForSystem system;
in
{
terraform = {
type = "app";
program = toString (pkgs.writeShellScript "terraform" ''
export PATH="${pkgs.lib.makeBinPath (with pkgs; [ terraform bash coreutils jq nix git ])}"
_flake_metadata="$(nix flake metadata git+file://$PWD?rev="$(git rev-parse HEAD)" --json)"
export TF_VAR_flake_rev="$(echo "$_flake_metadata" | jq .locked.rev -r)"
export TF_VAR_flake_sha="$(echo "$_flake_metadata" | jq .locked.narHash -r)"
export TF_VAR_flake_ref="$(git rev-parse --abbrev-ref HEAD)"
case "$1" in
"env")
shift 1
env
;;
*)
terraform "$@"
;;
esac
'');
};
}
);
devShell = forAllSystems (system:
let pkgs = pkgsForSystem system;
in
pkgs.mkShell {
nativeBuildInputs = with pkgs;
[ nomad_1_3 consul vault packer jq terraform
];
}
);
};
}