homelab-apps/flake.nix

45 lines
1.3 KiB
Nix

{
description = "Homelab configuration tools";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }:
let
to-docker-compose = pkgs.writeShellApplication {
name = "to-docker-compose";
runtimeInputs = [ pkgs.go-jsonnet ];
text =
''
jsonnet services.jsonnet --tla-code-file secrets=.secrets.jsonnet
'';
};
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" "tee remote-docker-compose.json | $cmd"
'';
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
go-jsonnet
to-docker-compose
remote-docker-compose
];
};
};
};
}