homelab-apps/flake.nix

45 lines
1.3 KiB
Nix
Raw Permalink 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";
};
2023-07-24 01:12:11 +00:00
outputs = inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
2022-11-13 01:06:12 +00:00
systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }:
let
to-docker-compose = pkgs.writeShellApplication {
name = "to-docker-compose";
2023-07-24 01:12:11 +00:00
runtimeInputs = [ pkgs.go-jsonnet ];
2022-11-17 18:44:48 +00:00
text =
''
2023-07-24 01:12:11 +00:00
jsonnet services.jsonnet --tla-code-file secrets=.secrets.jsonnet
2022-11-17 18:44:48 +00:00
'';
};
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
2023-03-11 22:37:22 +00:00
to-docker-compose | ssh "$host" "tee remote-docker-compose.json | $cmd"
2022-11-29 02:24:21 +00:00
'';
};
in
{
devShells.default = pkgs.mkShell {
2022-11-29 02:24:21 +00:00
buildInputs = with pkgs; [
2023-07-24 01:12:11 +00:00
go-jsonnet
2022-11-29 02:24:21 +00:00
to-docker-compose
remote-docker-compose
];
};
2022-11-13 01:06:12 +00:00
};
};
}