volpe/nix/package.nix

71 lines
No EOL
1.5 KiB
Nix

{
lib,
stdenv,
nodejs_latest,
pnpm_10,
fetchPnpmDeps,
pnpmConfigHook,
git,
siteUrl,
sourcePath ? ./..
}: let
nodejs = nodejs_latest;
pnpm = pnpm_10;
# Filter source: use cleanSourceFilter as base, but include .git and exclude _site
filteredSrc = lib.cleanSourceWith {
src = sourcePath;
filter = path: type:
let
baseName = baseNameOf path;
# Always include .git directory
isGit = baseName == ".git" || lib.hasInfix "/.git/" path || lib.hasSuffix "/.git" path;
in
isGit || (
# Apply base cleanSourceFilter
lib.cleanSourceFilter path type &&
# Additional exclusions
baseName != "_site" &&
baseName != "node_modules"
);
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "volpe";
version = "1.0.0";
src = filteredSrc;
nativeBuildInputs = [
nodejs
pnpm
pnpmConfigHook
git
];
# fetchPnpmDeps creates the offline store
# Use clean source (excludes .git, _site, node_modules)
pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs) pname version;
src = lib.cleanSource sourcePath;
hash = "sha256-rN8P6g/Wuug+fv0rm/qbKN01NgcbpgEQmhDFe2X42uA=";
fetcherVersion = 3; # pnpm store version
};
buildPhase = ''
runHook preBuild
SITE_URL="${siteUrl}" pnpm build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r _site/* $out/
runHook postInstall
'';
})