mirror of
https://github.com/sstent/vmimages.git
synced 2026-04-28 15:53:10 +00:00
sync
This commit is contained in:
@@ -14,6 +14,10 @@ let
|
|||||||
# make flake inputs accessiable in NixOS
|
# make flake inputs accessiable in NixOS
|
||||||
{ _module.args.inputs = inputs; }
|
{ _module.args.inputs = inputs; }
|
||||||
{
|
{
|
||||||
|
_module.args = {
|
||||||
|
utils = import ./utils { inherit pkgs; };
|
||||||
|
|
||||||
|
};
|
||||||
imports = [
|
imports = [
|
||||||
({ pkgs, ... }: {
|
({ pkgs, ... }: {
|
||||||
nix.nixPath = [
|
nix.nixPath = [
|
||||||
|
|||||||
25
utils/default.nix
Normal file
25
utils/default.nix
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{ pkgs, ... }: {
|
||||||
|
renderMustache = name: template: data:
|
||||||
|
# Render handlebars `template` called `name` by converting `data` to JSON
|
||||||
|
pkgs.stdenv.mkDerivation {
|
||||||
|
|
||||||
|
name = "${name}";
|
||||||
|
|
||||||
|
# Disable phases which are not needed. In particular the unpackPhase will
|
||||||
|
# fail, if no src attribute is set
|
||||||
|
nativeBuildInpts = [ pkgs.mustache-go ];
|
||||||
|
|
||||||
|
# Pass Json as file to avoid escaping
|
||||||
|
passAsFile = [ "jsonData" ];
|
||||||
|
jsonData = builtins.toJSON data;
|
||||||
|
|
||||||
|
phases = [ "buildPhase" "installPhase" ];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
${pkgs.mustache-go}/bin/mustache $jsonDataPath ${template} > rendered_file
|
||||||
|
'';
|
||||||
|
installPhase = ''
|
||||||
|
cp rendered_file $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user