diff --git a/.drone.jsonnet b/.drone.jsonnet index 97bcbf8..8b0e911 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,4 +1,23 @@ local Volume = { name: 'site', path: '/site' }; +local WhenProd(prod) = if prod then { + event: ['promote'], + target: ['production'], +} else { + target: { exclude: ['production'] }, +}; +local NixStep(env) = + local prod = env == 'production'; + local output = if prod then '' else ' .#staging-site'; + { + name: 'nix build ' + env, + image: 'nixos/nix', + volumes: [Volume], + commands: [ + '$NIX build' + output, + 'cp -r result/* /site/', + ], + when: WhenProd(prod), + }; local NetlifyStep(env) = local prod = env == 'production'; { @@ -11,12 +30,7 @@ local NetlifyStep(env) = path: '/site', prod: prod, }, - when: if prod then { - event: ['promote'], - target: ['production'], - } else { - target: { exclude: ['production'] }, - }, + when: WhenProd(prod), }; { kind: 'pipeline', @@ -30,15 +44,8 @@ local NetlifyStep(env) = volumes: [{ name: 'site', temp: {} }], steps: [ - { - name: 'nix build', - image: 'nixos/nix', - volumes: [Volume], - commands: [ - '$NIX build', - 'cp -r result/* /site/', - ], - }, + NixStep('staging'), + NixStep('production'), NetlifyStep('staging'), NetlifyStep('production'), ], diff --git a/flake.nix b/flake.nix index 46326eb..a278e93 100644 --- a/flake.nix +++ b/flake.nix @@ -36,6 +36,14 @@ 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 + ''; + }); devShells.default = with pkgs; mkShell { packages = [ optimize-images zola ]; shellHook = linkFonts;