summaryrefslogtreecommitdiffhomepage
path: root/shell.nix
diff options
context:
space:
mode:
Diffstat (limited to 'shell.nix')
-rwxr-xr-xshell.nix81
1 files changed, 52 insertions, 29 deletions
diff --git a/shell.nix b/shell.nix
index 8af842e..814c915 100755
--- a/shell.nix
+++ b/shell.nix
@@ -1,41 +1,64 @@
#!/usr/bin/env -S nix-shell --pure
#!nix-shell -i bash
-{pkgs-nix ? import <nixpkgs> {}}:
-with pkgs-nix;
+# Development environment for sisudoc-spine-search-cgi.
+# Builds the spine_search CGI binary via ./package.nix.
+#
+# Build logic for the spine_search derivation lives in ./package.nix -
+# this file only describes the dev shell.
+#
+# Usage:
+# nix-shell # enters shell, builds spine_search
+# nix-shell --run 'echo $SPINE_SEARCH_BIN'
+{
+ pkgs ? import <nixpkgs> {},
+ spine-search ? pkgs.callPackage ./package.nix {},
+ # captured at eval time - nix-shell rewrites $SHELL at runtime,
+ # so we must remember the user's real login shell here.
+ userShell ? builtins.getEnv "SHELL",
+}:
+with pkgs;
mkShell {
- buildInputs = [
- # ❯❯❯ nix_related
- #nix
+ name = "spine_search base dev shell";
+ packages = [
+ # ❯❯❯ spine_search CGI binary built from ./package.nix
+ spine-search
+ # ❯❯❯ d_build_related
+ ldc
+ #dmd
+ dub
+ # ❯❯❯ dev
+ gnumake
+ git
+ # ❯❯❯ nix workflow
direnv
- nixVersions.latest #nixVersions.latest #nixVersions.git
+ nix-direnv
nix-prefetch-git
- validatePkgConfig
nix-output-monitor
nix-tree
- jq #gx
- #nixfmt-rfc-style
- git
- # ❯❯❯ dev
- gnumake
- ps
- # ❯❯❯ d_build_related
- # ❯❯ package manager
- #dub
- # ❯❯ compiler
- #dmd
- #ldc
- #rund
- # ❯❯ linker
- #lld
- #mold
- # ❯❯ builder
- #ninja
- #meson
- # ❯❯❯ sqlite search related
+ jq
+ # ❯❯❯ sqlite
sqlite
- # ❯❯❯ tools
- #aria #wget #curl
];
shellHook = ''
+ export Date=$(date "+%Y%m%d")
+ ## set local values in .envrc-local (or here if you must)
+ ## spine_search lives under cgi-bin, not bin - expose it via env
+ ## var and prepend cgi-bin to PATH for convenience.
+ export SPINE_SEARCH_BIN="${spine-search}/cgi-bin/spine_search"
+ export PATH="${spine-search}/cgi-bin:$PATH"
+ echo "spine_search: $SPINE_SEARCH_BIN"
+ ## hand off to the user's login shell (e.g. zsh) only when this
+ ## is an interactive nix-shell entry - not under `nix-shell --run`
+ ## or `--command`, where exec would swallow the command. Guard env
+ ## var prevents re-entry loops.
+ __spine_user_shell=${if userShell == "" then "" else "\"" + userShell + "\""}
+ if [ -z "$__SPINE_SEARCH_SHELL_HANDOFF" ] \
+ && [ -n "$__spine_user_shell" ] \
+ && [ "$(basename "$__spine_user_shell")" != "bash" ] \
+ && [[ $- == *i* ]]; then
+ export __SPINE_SEARCH_SHELL_HANDOFF=1
+ exec "$__spine_user_shell"
+ fi
+ unset __spine_user_shell
'';
}