From 4410b4beaec9d5e8e0a19db4cd2aeeabd51b4f81 Mon Sep 17 00:00:00 2001 From: Assil Ksiksi Date: Tue, 7 Nov 2023 23:01:12 -0500 Subject: [PATCH] revert NixOS module; does not work --- flake.nix | 89 +----------------------------------- templates/container.nix.tmpl | 2 +- templates/main.nix.tmpl | 8 ---- 3 files changed, 3 insertions(+), 96 deletions(-) diff --git a/flake.nix b/flake.nix index 7fe63e1..c0b0725 100644 --- a/flake.nix +++ b/flake.nix @@ -4,7 +4,7 @@ # https://nixos.org/manual/nixos/stable/#sec-writing-modules # https://nixos.org/manual/nixpkgs/stable/#ssec-language-go { - description = "minimal configuration for compose2nix"; + description = "Convert Docker Compose to Nix"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -14,6 +14,7 @@ supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; forAllSystems = function: nixpkgs.lib.genAttrs supportedSystems (system: function nixpkgs.legacyPackages.${system}); pname = "compose2nix"; + owner = "aksiksi"; version = "0.0.1"; in { # Nix package @@ -33,91 +34,5 @@ buildInputs = [ pkgs.go pkgs.gopls ]; }; }); - - # NixOS module - nixosModules = forAllSystems (pkgs: { - default = { config, lib, pkgs, ... }: - with lib; let - cfg = config.compose2nix; - in { - options.compose2nix = { - # https://nixos.org/manual/nixos/stable/#sec-option-declarations - enable = mkOption { - type = types.bool; - default = false; - description = lib.mdDoc "Enable compose2nixos."; - }; - paths = mkOption { - type = types.listOf types.path; - description = lib.mdDoc "One or more paths to Docker Compose files."; - }; - runtime = mkOption { - type = types.enum [ "docker" "podman" ]; - default = "podman"; - description = lib.mdDoc "Container runtime to use."; - }; - project = mkOption { - type = types.str; - default = ""; - description = lib.mdDoc "Project name. Used as a prefix for all generated resources."; - }; - projectSeparator = mkOption { - type = types.str; - default = "_"; - description = lib.mdDoc "Defines the prefix between the project and resource name - i.e., [project][sep][resource]."; - }; - env = mkOption { - type = types.attrsOf types.str; - default = {}; - description = lib.mdDoc "Environment to use. Note that these will be merged with environment files, if any."; - }; - envFiles = mkOption { - type = types.listOf types.path; - default = []; - description = lib.mdDoc "One or more paths to environment files."; - }; - envFilesOnly = mkOption { - type = types.bool; - default = false; - description = lib.mdDoc "Only include env files in the output Nix file. Useful in cases where env variables contain secrets."; - }; - serviceInclude = mkOption { - type = types.str; - default = ""; - description = lib.mdDoc "Regex pattern for Docker Compose services to include."; - }; - autoStart = mkOption { - type = types.bool; - default = true; - description = lib.mdDoc "Auto-start all containers."; - }; - output = mkOption { - type = types.anything; - description = lib.mdDoc "Output config."; - }; - }; - config = { - # runCommandLocal ensures that we always build this derivation on the local machine. - # This allows us to circumvent the Nix binary cache and minimize the time spent outside - # of building the derivation. - # https://nixos.org/manual/nixpkgs/stable/#trivial-builder-runCommandLocal - compose2nix.output = mkIf (cfg.enable) (import pkgs.runCommandLocal "compose2nix" { - env = cfg.env; - buildInputs = [ pkgs.compose2nix ]; - } '' - ${pkgs.compose2nix}/bin/compose2nix \ - -paths='${concatStringsSep "," cfg.paths}' \ - -runtime=${cfg.runtime} \ - -project=${cfg.project} \ - -project_separator='${cfg.projectSeparator}' \ - -env_files='${concatStringsSep "," cfg.envFiles}' \ - -env_files_only=${cfg.envFilesOnly} \ - -service_include='${cfg.serviceInclude}' \ - -auto_start=${cfg.autoStart} \ - -output=$out - ''); - }; - }; - }); }; } diff --git a/templates/container.nix.tmpl b/templates/container.nix.tmpl index 4d41e71..5a60b90 100644 --- a/templates/container.nix.tmpl +++ b/templates/container.nix.tmpl @@ -55,7 +55,7 @@ virtualisation.oci-containers.containers."{{.Name}}" = { {{- end}} {{- if .LogDriver}} - logDriver = "{{.LogDriver}}"; + log-driver = "{{.LogDriver}}"; {{- end}} {{- if not .AutoStart}} diff --git a/templates/main.nix.tmpl b/templates/main.nix.tmpl index 7499347..a2a8c19 100644 --- a/templates/main.nix.tmpl +++ b/templates/main.nix.tmpl @@ -39,12 +39,4 @@ {{execTemplate "volume.nix.tmpl" . | indent 2}} {{- end}} {{- end}} - - # Scripts - up = writeShellScript "compose-{{.Project.With "up"}}.sh" '' - echo "TODO: Create resources." - ''; - down = writeShellScript "compose-{{.Project.With "down"}}.sh" '' - echo "TODO: Remove resources." - ''; }