{ description = "A flake to process YAML files through a series of transformations"; # Defines the inputs for this flake. inputs = { nixfmt.url = "github:serokell/nixfmt"; flake-utils.url = "github:numtide/flake-utils"; }; # Leverage flake-utils to easily support multiple systems. outputs = { self, nixpkgs, nixfmt, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let # Import nixpkgs for the specified system. pkgs = import nixpkgs { inherit system; }; # The wrapper script that chains the commands. processYAML = pkgs.writeShellScriptBin "process-yaml" '' #!/usr/bin/env bash set -euo pipefail if [[ $# -eq 0 ]]; then echo "Usage: $0 " exit 1 fi ${pkgs.yq}/bin/yq . $1 | nix eval --file ./convert.nix | ${pkgs.nixfmt}/bin/nixfmt ''; in { # A simple package that installs the script, making it usable. packages.process-yaml = processYAML; # Expose our script as an application for `nix run`. apps.process-yaml = flake-utils.lib.mkApp { drv = processYAML; }; # Let's also make a defaultPackage for convenience. defaultPackage = processYAML; } ); }