initial flake app
This commit is contained in:
73
flake.nix
73
flake.nix
@@ -1,5 +1,5 @@
|
||||
{
|
||||
description = "Quartz org-roam dev shell";
|
||||
description = "Quartz org-roam dev shell and build app";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
@@ -10,13 +10,76 @@
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
|
||||
# Emacs with ox-hugo — shared between devShell and buildApp
|
||||
emacsWithOxHugo = (pkgs.emacsPackagesFor pkgs.emacs-nox).emacsWithPackages
|
||||
(epkgs: [ epkgs.ox-hugo ]);
|
||||
|
||||
# Pre-fetched npm dependency tree (node_modules)
|
||||
quartzDeps = pkgs.buildNpmPackage {
|
||||
pname = "quartz-deps";
|
||||
version = "4.5.2";
|
||||
src = ./.;
|
||||
npmDepsHash = "sha256-7u+VlIx44B3/ivM9vLMIOn+e4TL4eS6B682vhS+Ikb4=";
|
||||
dontBuild = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r node_modules $out/node_modules
|
||||
'';
|
||||
};
|
||||
|
||||
# Pre-fetched Hex/Mix dependencies for scripts/pipeline
|
||||
pipelineMixDeps = pkgs.beamPackages.fetchMixDeps {
|
||||
pname = "pipeline-mix-deps";
|
||||
version = "0.1.0";
|
||||
src = ./scripts/pipeline;
|
||||
sha256 = "sha256-E79X+nUy86G1Jrwv3T7dXekoGv8Hd14ZgJSKWjvlmAw=";
|
||||
};
|
||||
|
||||
# The build application wrapper script
|
||||
buildApp = pkgs.writeShellApplication {
|
||||
name = "build";
|
||||
runtimeInputs = [ pkgs.nodejs_22 pkgs.elixir emacsWithOxHugo ];
|
||||
text = ''
|
||||
NOTES_DIR="''${1:?Usage: build <path-to-notes-dir>}"
|
||||
NOTES_DIR=$(realpath "$NOTES_DIR")
|
||||
ORIG_CWD=$(pwd)
|
||||
|
||||
# Set up a writable working copy of the repo in a temp dir
|
||||
WORK=$(mktemp -d)
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
cp -r ${self}/. "$WORK/repo"
|
||||
chmod -R u+w "$WORK/repo"
|
||||
|
||||
# Drop in pre-built node_modules
|
||||
ln -s ${quartzDeps}/node_modules "$WORK/repo/node_modules"
|
||||
|
||||
# Drop in pre-fetched Mix deps so mix compile runs offline
|
||||
cp -r ${pipelineMixDeps} "$WORK/repo/scripts/pipeline/deps"
|
||||
chmod -R u+w "$WORK/repo/scripts/pipeline/deps"
|
||||
|
||||
# ox-hugo requires static/ to exist before it can copy image assets
|
||||
mkdir -p "$WORK/repo/static"
|
||||
|
||||
# Run the export pipeline (org → md, citations transform)
|
||||
NOTES_DIR="$NOTES_DIR" elixir "$WORK/repo/scripts/export.exs"
|
||||
|
||||
# Build the static site from within the repo copy so relative paths
|
||||
# (e.g. ./package.json in constants.js) resolve correctly.
|
||||
# --output is absolute so the result lands in the caller's cwd.
|
||||
cd "$WORK/repo"
|
||||
node quartz/bootstrap-cli.mjs build \
|
||||
--directory "$WORK/repo/content" \
|
||||
--output "$ORIG_CWD/public"
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
pkgs.nodejs_22
|
||||
pkgs.elixir
|
||||
((pkgs.emacsPackagesFor pkgs.emacs-nox).emacsWithPackages (epkgs: [ epkgs.ox-hugo ]))
|
||||
emacsWithOxHugo
|
||||
pkgs.mcp-nixos
|
||||
];
|
||||
|
||||
@@ -26,5 +89,11 @@
|
||||
echo "Emacs $(emacs --version | head -1)"
|
||||
'';
|
||||
};
|
||||
|
||||
packages.default = buildApp;
|
||||
packages.build = buildApp;
|
||||
|
||||
apps.default = { type = "app"; program = "${buildApp}/bin/build"; };
|
||||
apps.build = { type = "app"; program = "${buildApp}/bin/build"; };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ must handle.
|
||||
An image hosted on the web — ox-hugo passes the URL through as-is and no
|
||||
local file handling is needed.
|
||||
|
||||
[[https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSkzsTuLOt8esM6enoKwkzqA52G3p9hldlf2g&s][file:quartz-logo-external.png]]
|
||||
#+attr_html: :link "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSkzsTuLOt8esM6enoKwkzqA52G3p9hldlf2g&s"
|
||||
[[file:quartz-logo-external.png]]
|
||||
|
||||
* Scenario 2: Local image (same notes directory)
|
||||
|
||||
@@ -29,4 +30,4 @@ shared assets folder or a system path. ox-hugo still copies it into =static/=
|
||||
and rewrites the reference.
|
||||
|
||||
#+CAPTION: Quartz logo (outside notes dir)
|
||||
[[file:/home/ignaciobll/code/quartz-org-roam/notes-external/external-location-image.png]]
|
||||
[[file:../notes-external/external-location-image.png]]
|
||||
|
||||
Reference in New Issue
Block a user