66 lines
1.7 KiB
Nix
Raw Normal View History

{
# Uses a local `path:` input to consume pure data from another flake.
description = "A minimal local path input example";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
catalog.url = "path:./catalog";
};
outputs =
{
self,
nixpkgs,
catalog,
...
}:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
inherit (catalog.lib)
releaseName
serviceOwners
rolloutWaves
;
renderWave =
wave:
"${wave.name}: ${builtins.concatStringsSep ", " wave.services} with approvals ${builtins.concatStringsSep ", " wave.approvals}";
ownerLines = pkgs.lib.mapAttrsToList (service: owner: "${service}: ${owner}") serviceOwners;
planText = builtins.concatStringsSep "\n" (
[
"release: ${releaseName}"
"owners:"
]
++ ownerLines
++ [
"waves:"
]
++ map renderWave rolloutWaves
);
in
{
packages.${system}.default = pkgs.writeShellApplication {
name = "show-local-plan";
text = ''
cat <<'EOF'
${planText}
EOF
'';
};
checks.${system}.catalog-is-used = pkgs.runCommand "local-path-input-check" { } ''
plan="$(${pkgs.lib.getExe self.packages.${system}.default})"
printf '%s\n' "$plan" | grep -q '^release: checkout-2026-05$'
printf '%s\n' "$plan" | grep -q '^billing: team-revenue$'
printf '%s\n' "$plan" | grep -q '^production: api, billing, worker with approvals change-advisory, finance-signoff$'
echo ok > "$out"
'';
};
}