diff --git a/README.md b/README.md new file mode 100644 index 0000000..891d2ef --- /dev/null +++ b/README.md @@ -0,0 +1,55 @@ +# compose2nix + +[![codecov](https://codecov.io/gh/aksiksi/compose2nix/graph/badge.svg)](https://codecov.io/gh/aksiksi/compose2nix) +[![test](https://github.com/aksiksi/compose2nix/actions/workflows/test.yml/badge.svg)](https://github.com/aksiksi/compose2nix/actions/workflows/test.yml) + +A tool to automatically generate a NixOS config from a Docker Compose project. + +## Quickstart + +Install the `compose2nix` CLI via one of the following methods: + +1. Cloning this repo and running `make build` +2. Installing the Flake and adding the following to your Nix config: + ```nix + environment.systemPackages = with pkgs; [ + compose2nix.packages.x86_64-linux.default + ]; + ``` + +Run `compose2nix`. + +```bash +compose2nix +``` + +By default, the tool looks for `docker-compose.yml` in the **current directory** and outputs the NixOS config to `docker-compose.nix`. + +## Options + +```bash +$ compose2nix -h +Usage of compose2nix: + -auto_start + auto-start setting for generated container(s). (default true) + -env_files string + one or more comma-separated paths to .env file(s). + -env_files_only + only use env file(s) in the NixOS container definitions. + -generate_unused_resources + if set, unused resources (e.g., networks) will be generated even if no containers use them. + -inputs string + one or more comma-separated path(s) to Compose file(s). (default "docker-compose.yml") + -output string + path to output Nix file. (default "docker-compose.nix") + -project string + project name used as a prefix for generated resources. + -project_separator string + seperator for project prefix. (default "_") + -runtime string + one of: ["podman", "docker"]. (default "podman") + -service_include string + regex pattern for services to include. + -use_compose_log_driver + if set, always use the Docker Compose log driver. +``` diff --git a/cmd/compose2nix/main.go b/cmd/compose2nix/main.go index ee9ca4f..fb489a6 100644 --- a/cmd/compose2nix/main.go +++ b/cmd/compose2nix/main.go @@ -14,16 +14,16 @@ import ( "github.com/aksiksi/compose2nix" ) -var inputs = flag.String("inputs", "docker-compose.yml", "one or more comma-separated path(s) to Compose file(s)") -var envFiles = flag.String("env_files", "", "zero or more comma-separated paths to .env file(s)") -var envFilesOnly = flag.Bool("env_files_only", false, "only use env file(s) in the NixOS container definitions") -var output = flag.String("output", "docker-compose.nix", "path to output Nix file") -var project = flag.String("project", "", "project name used as a prefix for generated resources") -var projectSeparator = flag.String("project_separator", compose2nix.DefaultProjectSeparator, "seperator for project prefix") -var serviceInclude = flag.String("service_include", "", "regex pattern for services to include") -var autoStart = flag.Bool("auto_start", true, "auto-start setting for generated container(s)") -var runtime = flag.String("runtime", "podman", `"podman" or "docker"`) -var useComposeLogDriver = flag.Bool("use_compose_log_driver", false, "if set, always use the Docker Compose log driver") +var inputs = flag.String("inputs", "docker-compose.yml", "one or more comma-separated path(s) to Compose file(s).") +var envFiles = flag.String("env_files", "", "one or more comma-separated paths to .env file(s).") +var envFilesOnly = flag.Bool("env_files_only", false, "only use env file(s) in the NixOS container definitions.") +var output = flag.String("output", "docker-compose.nix", "path to output Nix file.") +var project = flag.String("project", "", "project name used as a prefix for generated resources.") +var projectSeparator = flag.String("project_separator", compose2nix.DefaultProjectSeparator, "seperator for project prefix.") +var serviceInclude = flag.String("service_include", "", "regex pattern for services to include.") +var autoStart = flag.Bool("auto_start", true, "auto-start setting for generated container(s).") +var runtime = flag.String("runtime", "podman", `one of: ["podman", "docker"].`) +var useComposeLogDriver = flag.Bool("use_compose_log_driver", false, "if set, always use the Docker Compose log driver.") var generateUnusedResources = flag.Bool("generate_unused_resources", false, "if set, unused resources (e.g., networks) will be generated even if no containers use them.") func main() {