cluster/flake.nix
main e26c90bd2e
Fix home-assistant eval
Signed-off-by: main <magic_rb@redalder.org>
2022-10-27 15:48:38 +02:00

101 lines
3.9 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";
};
camptules = {
url = "git+https://gitea.redalder.org/ThyW/camptules";
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 nixpkgs.lib; 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; });
camptules = (import ./containers/camptules.nix (base // { inherit (inputs) camptules; }));
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;
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 name-rev --name-only 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
];
}
);
};
}