26 lines
No EOL
773 B
Nix
26 lines
No EOL
773 B
Nix
let
|
|
pkgs = import <nixpkgs> {};
|
|
lib = pkgs.lib;
|
|
|
|
readData = builtins.fromJSON (builtins.readFile "/dev/stdin");
|
|
|
|
convertEnvsToStrings = envs: lib.mapAttrs (_: value:
|
|
if lib.isBool value then
|
|
if value then "true" else "false"
|
|
else
|
|
toString value) envs;
|
|
|
|
transformService = name: service:
|
|
let
|
|
serviceTransformed = lib.mapAttrs
|
|
(n: v: if n == "environment" then convertEnvsToStrings v else v)
|
|
service;
|
|
in
|
|
{ service = serviceTransformed; };
|
|
|
|
transformedConfig =
|
|
{ services = lib.mapAttrs transformService readData.services; }
|
|
// lib.optionalAttrs (readData ? networks) { networks = readData.networks; }
|
|
// lib.optionalAttrs (readData ? volumes) { volumes = readData.volumes; };
|
|
|
|
in transformedConfig |