Skip to content

Instantly share code, notes, and snippets.

@marcusramberg
Last active April 2, 2024 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusramberg/f9a63236a4cf124eb7e586e21c7a60eb to your computer and use it in GitHub Desktop.
Save marcusramberg/f9a63236a4cf124eb7e586e21c7a60eb to your computer and use it in GitHub Desktop.
with import <nixpkgs> { };
with builtins;
rec {
yaml2nix = path:
let
jsonOutputDrv =
runCommand "from-yaml" { nativeBuildInputs = [ remarshal ]; }
''remarshal -if yaml -i "${path}" -of json -o "$out"'';
in fromJSON (readFile jsonOutputDrv);
run = state: env:
let
folder = "helm/${state}";
hf = import ../${folder}/helmfile.nix;
var = {
values = lib.mergeAttrs (yaml2nix ../${folder}/env/defaults.yaml)
(yaml2nix ../${folder}/env/${env}.yaml);
environment.name = env;
};
vals = val: "TODO: fetch ${val} using ${pkgs.vals}";
in hf { inherit lib var vals; };
}
@marcusramberg
Copy link
Author

Running it with

nix eval --json --impure --expr '(import ../../nixhf/default.nix).run "atlantis" "prod"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment