aboutsummaryrefslogtreecommitdiffhomepage
path: root/shell.nix
blob: 29b6577bca5507a5c45b76f3b54c695a204e0871 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env -S nix-shell --pure
#!nix-shell -i bash
# Development environment for sisudoc-spine.
# Builds the spine binary via ./package.nix and puts it on PATH.
#
# Build logic for the spine derivation lives in ./package.nix
# this file only describes the dev shell.
#
# Usage:
#   nix-shell                         # enters shell, builds spine
#   nix-shell --run 'spine --version' # runs spine after build
{
  pkgs ? import <nixpkgs> {},
  spine ? 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 {
    name = "spine base dev shell";
    packages = [
      # ❯❯❯ spine binary built from ./package.nix
      spine
      # ❯❯❯ d_build_related
      ldc
      #dmd
      dub
      # ❯❯❯ dev
      gnumake
      git
      # ❯❯❯ nix_related
      direnv
      nix-direnv
      nix-prefetch-git
      nix-output-monitor
      nix-tree
      jq
      # ❯❯❯ sqlite search related
      sqlite
      # ❯❯❯ xml_and_epub_related
      # libxml2
      # html-tidy
      # xmlstarlet
      # epubcheck
      # ebook_tools
      # epr
      # sigil
      # calibre #(suite includes: ebook-viewer)
      # koreader
      # foliate
      # ❯❯❯ pdf reader
      # evince
      # ❯❯❯ pdf_latex_related
      # source-sans-pro
      # source-serif-pro
      # source-code-pro
      # texlive.combined.scheme-full
      # ❯❯❯ 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
    '';
  }