Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiksi committed Nov 10, 2023
1 parent 507edb4 commit 4a73bd6
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 10 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
```
20 changes: 10 additions & 10 deletions cmd/compose2nix/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 4a73bd6

Please sign in to comment.