use more common naming scheme

This commit is contained in:
Kiara Grouwstra 2025-06-19 10:10:57 +02:00
parent 23b90152a1
commit 0fbea43150
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU
3 changed files with 10 additions and 10 deletions

16
lib.nix
View file

@ -11,7 +11,7 @@ rec {
};
# make a template with placeholders
template_text = { name, text, outPath }:
templateText = { name, text, outPath }:
pkgs.runCommand name {
textBeforeTemplate = text;
script = ''
@ -26,15 +26,15 @@ rec {
chmod +x $out/bin/${name}
'';
template_generator = generator: { name, value, outPath }: template_text {
templateGenerator = generator: { name, value, outPath }: templateText {
inherit name outPath;
text = generator value;
};
template_json = options: template_generator (lib.generators.toJSON options);
template_yaml = options: template_generator (lib.generators.toYAML options); # just json
template_ini = options: template_generator (lib.generators.toINI options);
template_json' = template_json { };
template_yaml' = template_yaml { };
template_ini' = template_ini { };
templateJsonWith = options: templateGenerator (lib.generators.toJSON options);
templateYamlWith = options: templateGenerator (lib.generators.toYAML options); # just json
templateIniWith = options: templateGenerator (lib.generators.toINI options);
templateJson = templateJsonWith { };
templateYaml = templateYamlWith { };
templateIni = templateIniWith { };
}

View file

@ -12,7 +12,7 @@ in (nixpkgs.lib.nixos.runTest {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStartPre = "${legacyPackages.${system}.template_json {} {
ExecStartPre = "${legacyPackages.${system}.templateJson {
name = "test";
value = {
foo = "text";

View file

@ -14,7 +14,7 @@ in (nixpkgs.lib.nixos.runTest {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStartPre = "${legacyPackages.${system}.template_text {
ExecStartPre = "${legacyPackages.${system}.templateText {
name = "test";
text = ''
public text