homelab-apps/flake.nix

52 lines
1.5 KiB
Nix
Raw Normal View History

2022-11-13 01:06:12 +00:00
{
description = "Homelab configuration tools";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = { self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit self; } {
systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }:
let
to-docker-compose = pkgs.writeShellApplication {
name = "to-docker-compose";
runtimeInputs = [ pkgs.jsonnet ];
2022-11-17 18:44:48 +00:00
text =
let
vars = [ "PLEX_CLAIM" "PLEX_ADVERTISE_IP" "FIREFLY_APP_KEY" ];
2022-11-17 19:43:28 +00:00
varRow = var: "${var}: '\$${var}',";
2022-11-17 18:44:48 +00:00
in
''
jsonnet services.jsonnet \
--tla-code secrets="{
${pkgs.lib.concatMapStrings varRow vars}
}"
'';
};
2022-11-29 02:24:21 +00:00
remote-docker-compose = pkgs.writeShellApplication {
name = "remote-docker-compose";
runtimeInputs = [ to-docker-compose ];
text = ''
host=$1
shift
cmd="docker compose -f - $*"
# shellcheck disable=SC2029
to-docker-compose | ssh "$host" "$cmd"
'';
};
in
{
devShells.default = pkgs.mkShell {
2022-11-29 02:24:21 +00:00
buildInputs = with pkgs; [
jsonnet
to-docker-compose
remote-docker-compose
];
};
2022-11-13 01:06:12 +00:00
};
};
}