{ description = "Org-roam export pipeline — Elixir escript"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; fs = pkgs.lib.fileset; # Emacs with ox-hugo — needed at runtime by the pipeline escript # (export_org_files calls `emacs --batch` with ox-hugo). emacsWithOxHugo = (pkgs.emacsPackagesFor pkgs.emacs-nox).emacsWithPackages (epkgs: [ epkgs.ox-hugo ]); # Pre-fetched Hex/Mix dependencies. # src is filtered to mix.exs + mix.lock so source edits don't # invalidate this derivation. mixDeps = pkgs.beamPackages.fetchMixDeps { pname = "pipeline-mix-deps"; version = "0.1.0"; src = fs.toSource { root = ./.; fileset = fs.unions [ ./mix.exs ./mix.lock ]; }; sha256 = "sha256-si7JAomY1HZ33m6ihUJP5i6PO39CE1clYvuMtn0CbPU="; }; # Compiled pipeline escript (without runtime wrappers). pipelineEscript = pkgs.beamPackages.mixRelease { pname = "pipeline"; version = "0.1.0"; src = ./.; escriptBinName = "pipeline"; mixFodDeps = mixDeps; stripDebug = true; }; # Wrapped pipeline that puts emacs (with ox-hugo) on PATH so # the escript's System.cmd("emacs", ...) calls succeed. pipelineApp = pkgs.writeShellApplication { name = "pipeline"; runtimeInputs = [ emacsWithOxHugo pkgs.inotify-tools ]; text = '' exec ${pipelineEscript}/bin/pipeline "$@" ''; }; in { packages.default = pipelineApp; packages.escript = pipelineEscript; devShells.default = pkgs.mkShell { buildInputs = [ pkgs.elixir pkgs.inotify-tools emacsWithOxHugo ]; }; }); }