aboutsummaryrefslogtreecommitdiffhomepage
path: root/shell.nix
diff options
context:
space:
mode:
Diffstat (limited to 'shell.nix')
-rwxr-xr-xshell.nix85
1 files changed, 49 insertions, 36 deletions
diff --git a/shell.nix b/shell.nix
index 077228a..6c7a694 100755
--- a/shell.nix
+++ b/shell.nix
@@ -1,46 +1,38 @@
#!/usr/bin/env -S nix-shell --pure
#!nix-shell -i bash
-{pkgs ? import <nixpkgs> {}}:
+# Development environment for sisudoc-spine-samples.
+# Basic dev shell mirroring the flake's default devShell (`dsh`),
+# with the flake's default package (spine) built and put on PATH.
+#
+# Usage:
+# nix-shell # enters shell, builds spine via the flake
+# nix-shell --run 'spine --version' # runs spine after build
+#
+# Requires: experimental-features = nix-command flakes
+{
+ pkgs ? import <nixpkgs> {},
+ flake ? builtins.getFlake (toString ./.),
+ # 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",
+}:
+let
+ spine = flake.packages.${pkgs.stdenv.hostPlatform.system}.default;
+in
with pkgs;
mkShell {
- buildInputs = [
- # ❯❯❯ nix_related
- ##nix
- #direnv
- #nix-direnv
- #nixVersions.latest #nixVersions.latest #nixVersions.git
- #nix-prefetch-git
- #validatePkgConfig
- nix-output-monitor
- #nix-tree
- #jq
- #nixfmt-rfc-style
- #git
- # ❯❯❯ dev
- #gnumake
- #ps
+ name = "spine base dev shell";
+ packages = [
+ # ❯❯❯ flake default build (spine binary)
+ spine
# ❯❯❯ d_build_related
- # ❯❯ package manager
- #dub
- # ❯❯ compiler
+ ldc
#dmd
- #ldc
- #rund
- # ❯❯ linker
- #lld
- #mold
- # ❯❯ builder
- #ninja
- #meson
- # ❯❯ tools
- #dtools
+ dub
+ # ❯❯❯ dev
+ gnumake
# ❯❯❯ sqlite search related
- #sqlite
- # ❯❯❯ pdf_latex_related
- # source-sans-pro
- # source-serif-pro
- # source-code-pro
- # texlive.combined.scheme-full
+ sqlite
# ❯❯❯ xml_and_epub_related
# libxml2
# html-tidy
@@ -52,9 +44,30 @@ with pkgs;
# calibre #(suite includes: ebook-viewer)
# koreader
# foliate
+ # ❯❯❯ pdf reader
+ # evince
# ❯❯❯ i18n translation related
# perlPackages.Po4a
];
shellHook = ''
+ export DFLAGS="-O2 -boundscheck=on"
+ export Date=$(date "+%Y%m%d")
+ ## set local values in .envrc-local (or here if you must)
+ echo "spine: $(command -v spine)"
+ ## 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_SHELL_HANDOFF" ] \
+ && [ -n "$__spine_user_shell" ] \
+ && [ "$(basename "$__spine_user_shell")" != "bash" ] \
+ && [[ $- == *i* ]]; then
+ export __SPINE_SHELL_HANDOFF=1
+ spine --version
+ exec "$__spine_user_shell"
+ fi
+ unset __spine_user_shell
+ spine --version
'';
}