69 lines
1.9 KiB
Nix
69 lines
1.9 KiB
Nix
{
|
|
description = "folliehiyuki's personal blog";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
inherit (nixpkgs) lib;
|
|
pkgs = nixpkgs.legacyPackages."${system}";
|
|
|
|
hugoBuildInputs = with pkgs; [ hugo dart-sass ];
|
|
|
|
tasks = with pkgs; {
|
|
serve = {
|
|
runtimeInputs = hugoBuildInputs;
|
|
script = "hugo server -D";
|
|
};
|
|
|
|
# NOTE: either CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN need to be set outside (.e.g CI/CD variable)
|
|
# or run `wrangler login` first
|
|
publish = {
|
|
runtimeInputs = [ nodePackages.wrangler git ];
|
|
script = ''
|
|
wrangler pages deploy \
|
|
--project-name=folliehiyuki \
|
|
--branch="$(git branch --show-current)" \
|
|
result/
|
|
'';
|
|
};
|
|
};
|
|
in
|
|
{
|
|
apps = (lib.attrsets.mapAttrs
|
|
(k: v: flake-utils.lib.mkApp {
|
|
drv = pkgs.writeShellApplication {
|
|
name = k;
|
|
runtimeInputs = v.runtimeInputs;
|
|
text = v.script;
|
|
};
|
|
})
|
|
tasks);
|
|
|
|
packages.default = with pkgs; stdenv.mkDerivation {
|
|
name = "folliehiyuki.com";
|
|
src = lib.cleanSource ./.;
|
|
buildInputs = hugoBuildInputs;
|
|
|
|
buildPhase = ''
|
|
export HUGO_CACHEDIR="$TMPDIR/.hugo_cache"
|
|
hugo --gc --panicOnWarning
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p "$out"
|
|
cp -r public/* "$out"/
|
|
'';
|
|
};
|
|
|
|
devShells.default = with pkgs; mkShell {
|
|
packages = hugoBuildInputs ++ [ git nodePackages.wrangler ];
|
|
};
|
|
}
|
|
);
|
|
}
|