From 36214b9ba6e7b1ddb333f31d96f6c3198b86cb23 Mon Sep 17 00:00:00 2001 From: mat ess Date: Thu, 20 Oct 2022 19:48:14 -0400 Subject: [PATCH] Use drone env var --- flake.nix | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index a278e93..7e42b88 100644 --- a/flake.nix +++ b/flake.nix @@ -18,31 +18,29 @@ inherit (gitignore.lib) gitignoreSource; inherit (pkgs.callPackage ./nix { }) fonts optimize-images; inherit (fonts) copyFonts linkFonts; + buildSite = { prod }: + let inherit (pkgs.lib) optionalString; in '' + optimize-images + ${optionalString (!prod) "BASE_URL=https://$DRONE_COMMIT_SHA--mat-services.netlify.app"} + zola build --drafts ${optionalString (!prod) "--base-url $BASE_URL"} + # zola's ignored_content setting doesn't work in static/ + rm -rf public/image/_favicon.svg + ''; in { packages.default = with pkgs; stdenv.mkDerivation { pname = "personal-site"; version = "2022-10-10"; src = gitignoreSource ./.; - nativeBuildInputs = [ optimize-images zola ]; + nativeBuildInputs = [ git optimize-images zola ]; configurePhase = copyFonts; - buildPhase = '' - optimize-images - zola build --drafts - # zola's ignored_content setting doesn't work in static/ - rm -rf public/image/_favicon.svg - ''; + buildPhase = buildSite { prod = true; }; installPhase = '' cp -r public $out ''; }; packages.staging-site = config.packages.default.overrideAttrs (_: { - buildPhase = '' - optimize-images - zola build --drafts --base_url $DEPLOY_PRIME_URL - # zola's ignored_content setting doesn't work in static/ - rm -rf public/image/_favicon.svg - ''; + buildPhase = buildSite { prod = false; }; }); devShells.default = with pkgs; mkShell { packages = [ optimize-images zola ];