From d34c527372e0a6b8dcb0d9796451b987c953a88e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 25 Mar 2021 20:14:48 +0200 Subject: [PATCH] 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 Tested-by: BuildkiteCI --- nix/tailscale/default.nix | 4 ++-- ops/besadii/default.nix | 4 +--- users/tazjin/blog/fragments.nix | 10 +++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/nix/tailscale/default.nix b/nix/tailscale/default.nix index a21af7d11..8d6a0f661 100644 --- a/nix/tailscale/default.nix +++ b/nix/tailscale/default.nix @@ -2,7 +2,7 @@ # # https://tailscale.com/kb/1018/install-acls -{ depot, ... }: +{ depot, pkgs, ... }: with depot.nix.yants; @@ -27,4 +27,4 @@ let # Actual ACL entries ACLs = list acl; }; -in config: toFile "tailscale-acl.json" (toJSON (aclConfig config)) +in config: pkgs.writeText "tailscale-acl.json" (toJSON (aclConfig config)) diff --git a/ops/besadii/default.nix b/ops/besadii/default.nix index c3e2310b6..1199c56cf 100644 --- a/ops/besadii/default.nix +++ b/ops/besadii/default.nix @@ -2,9 +2,7 @@ # Buildkite, Sourcegraph reindexing and other maintenance tasks. { depot, ... }: -let - inherit (builtins) toFile toJSON; -in depot.nix.buildGo.program { +depot.nix.buildGo.program { name = "besadii"; srcs = [ ./main.go ]; } diff --git a/users/tazjin/blog/fragments.nix b/users/tazjin/blog/fragments.nix index fb750a729..78a64afa3 100644 --- a/users/tazjin/blog/fragments.nix +++ b/users/tazjin/blog/fragments.nix @@ -10,7 +10,7 @@ { depot, lib, ... }: let - inherit (builtins) filter map hasAttr replaceStrings toFile; + inherit (builtins) filter map hasAttr replaceStrings; inherit (depot.third_party) runCommandNoCC writeText; inherit (depot.users.tazjin) renderMarkdown; @@ -51,7 +51,7 @@ let ''; - draftWarning = toFile "draft.html" '' + draftWarning = writeText "draft.html" ''

Note: This post is a draft! Please do not share the link to it without asking me first. @@ -59,7 +59,7 @@ let


''; - unlistedWarning = toFile "unlisted.html" '' + unlistedWarning = writeText "unlisted.html" ''

Note: This post is unlisted! Please do not share the link to it without asking me first. @@ -68,7 +68,7 @@ let ''; 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 echo '

${escape post.title}

' >> $out @@ -89,7 +89,7 @@ let cat ${renderMarkdown post.content} >> $out echo '
' >> $out - cat ${toFile "footer.html" footer} >> $out + cat ${writeText "footer.html" footer} >> $out ''; in { inherit renderPost isDraft isUnlisted;