43 lines
No EOL
1.3 KiB
Nix
43 lines
No EOL
1.3 KiB
Nix
{
|
|
description = "Converts docker-compose.yaml files to arion-compose.nix";
|
|
|
|
# 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 <path/to/docker-compose.yaml>"
|
|
exit 1
|
|
fi
|
|
|
|
${pkgs.yq}/bin/yq . $1 | nix eval --file ${self}/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;
|
|
}
|
|
);
|
|
} |