From f76e2e42feb32b8623e1cdce932e2e093549a37a Mon Sep 17 00:00:00 2001 From: cinereal Date: Wed, 28 May 2025 22:56:15 +0200 Subject: [PATCH] document components --- lib.nix | 2 ++ pkgs/nix_templater/replace.py | 1 + tests/template.nix | 1 + 3 files changed, 4 insertions(+) diff --git a/lib.nix b/lib.nix index 0f34930..1d63182 100644 --- a/lib.nix +++ b/lib.nix @@ -1,10 +1,12 @@ { pkgs, nix_templater }: rec { + # placeholder to be substituted with the content of a secret file fileContents = file: { outPath = "<${builtins.placeholder "nix_template"}${toString file}${builtins.placeholder "nix_template"}>"; file = file; }; + # make a template with placeholders template_text = { name, text, outPath }: pkgs.runCommand name { textBeforeTemplate = text; diff --git a/pkgs/nix_templater/replace.py b/pkgs/nix_templater/replace.py index aa84127..50ff7c5 100644 --- a/pkgs/nix_templater/replace.py +++ b/pkgs/nix_templater/replace.py @@ -1,3 +1,4 @@ +# replace occurrences of a magic string in a template file import sys from pathlib import Path diff --git a/tests/template.nix b/tests/template.nix index 5fd22c6..8c737b8 100644 --- a/tests/template.nix +++ b/tests/template.nix @@ -1,3 +1,4 @@ +# test injecting a secret into a template { legacyPackages, system, nixpkgs }: let # this file would usually be outside of the store