refactor: Replace some uses of builtins.toFile with pkgs.writeText

I'm looking at removing some of these because they can cause
unnecessary build steps during CI pipeline generation.

Change-Id: I84742968918090c050d2eedab8a1b42692632a42
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2655
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2021-03-25 20:14:48 +02:00 committed by tazjin
parent d01d6bb63d
commit d34c527372
3 changed files with 8 additions and 10 deletions

View file

@ -2,7 +2,7 @@
# #
# https://tailscale.com/kb/1018/install-acls # https://tailscale.com/kb/1018/install-acls
{ depot, ... }: { depot, pkgs, ... }:
with depot.nix.yants; with depot.nix.yants;
@ -27,4 +27,4 @@ let
# Actual ACL entries # Actual ACL entries
ACLs = list acl; ACLs = list acl;
}; };
in config: toFile "tailscale-acl.json" (toJSON (aclConfig config)) in config: pkgs.writeText "tailscale-acl.json" (toJSON (aclConfig config))

View file

@ -2,9 +2,7 @@
# Buildkite, Sourcegraph reindexing and other maintenance tasks. # Buildkite, Sourcegraph reindexing and other maintenance tasks.
{ depot, ... }: { depot, ... }:
let depot.nix.buildGo.program {
inherit (builtins) toFile toJSON;
in depot.nix.buildGo.program {
name = "besadii"; name = "besadii";
srcs = [ ./main.go ]; srcs = [ ./main.go ];
} }

View file

@ -10,7 +10,7 @@
{ depot, lib, ... }: { depot, lib, ... }:
let let
inherit (builtins) filter map hasAttr replaceStrings toFile; inherit (builtins) filter map hasAttr replaceStrings;
inherit (depot.third_party) runCommandNoCC writeText; inherit (depot.third_party) runCommandNoCC writeText;
inherit (depot.users.tazjin) renderMarkdown; inherit (depot.users.tazjin) renderMarkdown;
@ -51,7 +51,7 @@ let
</body> </body>
''; '';
draftWarning = toFile "draft.html" '' draftWarning = writeText "draft.html" ''
<p class="cheddar-callout cheddar-warning"> <p class="cheddar-callout cheddar-warning">
<b>Note:</b> This post is a <b>draft</b>! Please do not share <b>Note:</b> This post is a <b>draft</b>! Please do not share
the link to it without asking me first. the link to it without asking me first.
@ -59,7 +59,7 @@ let
<hr> <hr>
''; '';
unlistedWarning = toFile "unlisted.html" '' unlistedWarning = writeText "unlisted.html" ''
<p class="cheddar-callout cheddar-warning"> <p class="cheddar-callout cheddar-warning">
<b>Note:</b> This post is <b>unlisted</b>! Please do not share <b>Note:</b> This post is <b>unlisted</b>! Please do not share
the link to it without asking me first. the link to it without asking me first.
@ -68,7 +68,7 @@ let
''; '';
renderPost = post: runCommandNoCC "${post.key}.html" {} '' renderPost = post: runCommandNoCC "${post.key}.html" {} ''
cat ${toFile "header.html" (header post.title)} > $out cat ${writeText "header.html" (header post.title)} > $out
# Write the post title & date # Write the post title & date
echo '<article><h2 class="inline">${escape post.title}</h2>' >> $out echo '<article><h2 class="inline">${escape post.title}</h2>' >> $out
@ -89,7 +89,7 @@ let
cat ${renderMarkdown post.content} >> $out cat ${renderMarkdown post.content} >> $out
echo '</article>' >> $out echo '</article>' >> $out
cat ${toFile "footer.html" footer} >> $out cat ${writeText "footer.html" footer} >> $out
''; '';
in { in {
inherit renderPost isDraft isUnlisted; inherit renderPost isDraft isUnlisted;