Embed SHA in build
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details

pull/1/head
mat ess 2022-10-20 20:04:25 -04:00
parent 36214b9ba6
commit e47fd1903c
1 changed files with 9 additions and 5 deletions

View File

@ -12,16 +12,20 @@
outputs = { self, flake-parts, gitignore, ... }@inputs: outputs = { self, flake-parts, gitignore, ... }@inputs:
flake-parts.lib.mkFlake { inherit self; } { flake-parts.lib.mkFlake { inherit self; } {
imports = [ ]; imports = [ ];
systems = inputs.nixpkgs.lib.systems.flakeExposed; systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }: perSystem = { config, self', inputs', pkgs, system, ... }:
let let
inherit (gitignore.lib) gitignoreSource; inherit (gitignore.lib) gitignoreSource;
inherit (pkgs.callPackage ./nix { }) fonts optimize-images; inherit (pkgs.callPackage ./nix { }) fonts optimize-images;
inherit (fonts) copyFonts linkFonts; inherit (fonts) copyFonts linkFonts;
buildSite = { prod }: buildSite = { prod }:
let inherit (pkgs.lib) optionalString; in '' let
inherit (pkgs.lib) optionalString;
rev = if (self ? rev) then self.rev else "dirty";
in
''
optimize-images optimize-images
${optionalString (!prod) "BASE_URL=https://$DRONE_COMMIT_SHA--mat-services.netlify.app"} ${optionalString (!prod) "BASE_URL=https://${rev}--mat-services.netlify.app"}
zola build --drafts ${optionalString (!prod) "--base-url $BASE_URL"} zola build --drafts ${optionalString (!prod) "--base-url $BASE_URL"}
# zola's ignored_content setting doesn't work in static/ # zola's ignored_content setting doesn't work in static/
rm -rf public/image/_favicon.svg rm -rf public/image/_favicon.svg
@ -30,9 +34,9 @@
{ {
packages.default = with pkgs; stdenv.mkDerivation { packages.default = with pkgs; stdenv.mkDerivation {
pname = "personal-site"; pname = "personal-site";
version = "2022-10-10"; version = "2022-10-20";
src = gitignoreSource ./.; src = gitignoreSource ./.;
nativeBuildInputs = [ git optimize-images zola ]; nativeBuildInputs = [ optimize-images zola ];
configurePhase = copyFonts; configurePhase = copyFonts;
buildPhase = buildSite { prod = true; }; buildPhase = buildSite { prod = true; };
installPhase = '' installPhase = ''