aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2026-04-10 21:18:31 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2026-04-10 21:18:31 -0400
commit6cff0e3c0bea4e7bee304c411d63de26a6a9af05 (patch)
treecd1006d28b41eb08b4884c7976760ce807669efb
parentflake.nix tidy & use updated names in dlang flake (diff)
nix keeping: nix-shell, nix-build derivation.nixHEADmain
-rwxr-xr-xdefault.nix3
-rwxr-xr-x[-rw-r--r--]derivation.nix12
-rw-r--r--devenv.nix47
-rw-r--r--flake.lock14
-rw-r--r--org/config_nix.org211
-rwxr-xr-xshell.nix85
6 files changed, 122 insertions, 250 deletions
diff --git a/default.nix b/default.nix
deleted file mode 100755
index 922b291..0000000
--- a/default.nix
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env -S nix-build
-{pkgs ? import <nixpkgs> {}}:
-pkgs.callPackage ./devenv.nix {}
diff --git a/derivation.nix b/derivation.nix
index 8f0364a..b40e95a 100644..100755
--- a/derivation.nix
+++ b/derivation.nix
@@ -1,3 +1,4 @@
+#!/usr/bin/env -S nix-build derivation.nix
{
pkgs ? import <nixpkgs> {},
stdenv ? pkgs.stdenv,
@@ -93,10 +94,13 @@ with (
mkDubDerivation rec {
pname = "spine";
version = "0.18.0";
- #zipfile = "spine-0.12.0-tag-0.11.2.r107.gf89a107.tar.gz";
- src = fetchTarball {
- url = "file:///home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/tarball/spine-0.12.0-tag-0.11.2.r107.gf89a107.tar.gz";
- sha256 = "sha256:03dr7dn7kq6arw4ry7qar13iqmi1caw70imfjwi8qr7g2j4mnk2q";
+ # fetched from the same upstream the flake's `inputs.spine` points at
+ # (git://git.sisudoc.org/software/sisudoc-spine). Unlike flake inputs,
+ # builtins.fetchGit is usable from a plain (non-flake) derivation.nix.
+ src = builtins.fetchGit {
+ url = "git://git.sisudoc.org/software/sisudoc-spine";
+ ref = "main";
+ shallow = true;
};
nativeBuildInputs = with pkgs; [dub ldc];
buildInputs = with pkgs; [nixVersions.latest sqlite];
diff --git a/devenv.nix b/devenv.nix
deleted file mode 100644
index 56e6613..0000000
--- a/devenv.nix
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- pkgs ? import <nixpkgs> {},
- name ? "user-env",
-}:
-with pkgs;
- buildEnv {
- inherit name;
- extraOutputsToInstall = ["out" "man" "lib"]; # to get all needed symlinks
- paths = [
- # ❯❯❯ nix_related
- #nix # if not on NixOS, this is needed
- direnv
- nix-direnv
- nixVersions.latest #nixVersions.latest #nixVersions.git
- 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
- # ❯❯❯ sqlite search related
- sqlite
- # this will create a script that will rebuild and upgrade your setup; using shell script syntax
- (writeScriptBin "nix-rebuild" ''
- #!${stdenv.shell}
- #cd <path-to-flake> || exit 1
- nix flake update
- nix profile upgrade '.*'
- '')
- # puts in your root the nixpkgs version
- (writeTextFile {
- name = "nixpkgs-version";
- destination = "/nixpkgs-version";
- text = lib.version;
- })
- ];
- }
diff --git a/flake.lock b/flake.lock
index 875a90b..3a0e1aa 100644
--- a/flake.lock
+++ b/flake.lock
@@ -22,11 +22,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1775639890,
- "narHash": "sha256-9O9gNidrdzcb7vgKGtff7QiLtr0IsVaCi0pAXm8anhQ=",
+ "lastModified": 1775793324,
+ "narHash": "sha256-omax7atcZbol+6HJ2RLpP+ZCFcPa5bZ65Hn71RufeWQ=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "456e8a9468b9d46bd8c9524425026c00745bc4d2",
+ "rev": "9d29d5f667d7467f98efc31881e824fa586c927e",
"type": "github"
},
"original": {
@@ -50,11 +50,11 @@
]
},
"locked": {
- "lastModified": 1773955194,
- "narHash": "sha256-cJH6IS/u04Cssy9mmRHE88+kgnRWW7p+QZW7WJaIu70=",
+ "lastModified": 1775741093,
+ "narHash": "sha256-O/w5qKNcj08PK+s6Bq6DIPgjzgvwLRLbcC3EcTnpRl4=",
"ref": "refs/heads/main",
- "rev": "49c5f0f0d6c43dc6840f45554dde08d3f3fa35a9",
- "revCount": 710,
+ "rev": "f125c5892ce48c60af00dc3114bf2aa8c2014a89",
+ "revCount": 713,
"type": "git",
"url": "git://git.sisudoc.org/software/sisudoc-spine"
},
diff --git a/org/config_nix.org b/org/config_nix.org
index dfbee32..a5b2839 100644
--- a/org/config_nix.org
+++ b/org/config_nix.org
@@ -239,47 +239,39 @@
#+HEADER: :shebang "#!/usr/bin/env -S nix-shell --pure\n#!nix-shell -i bash"
#+HEADER: :noweb yes
#+BEGIN_SRC nix
-{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
@@ -291,85 +283,40 @@ 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
'';
}
#+END_SRC
-** default.nix :default:
-
-#+HEADER: :tangle ../default.nix
-#+HEADER: :tangle-mode (identity #o755)
-#+HEADER: :shebang "#!/usr/bin/env -S nix-build"
-#+BEGIN_SRC nix
-{pkgs ? import <nixpkgs> {}}:
-pkgs.callPackage ./devenv.nix {}
-#+END_SRC
-
-* devEnv
-** devenv.nix :default:devenv:
-
-nix profile install .
-
-#+HEADER: :tangle ../devenv.nix
-#+HEADER: :tangle-mode (identity #o644)
-#+BEGIN_SRC nix
-{
- pkgs ? import <nixpkgs> {},
- name ? "user-env",
-}:
-with pkgs;
- buildEnv {
- inherit name;
- extraOutputsToInstall = ["out" "man" "lib"]; # to get all needed symlinks
- paths = [
- # ❯❯❯ nix_related
- #nix # if not on NixOS, this is needed
- direnv
- nix-direnv
- nixVersions.latest #nixVersions.latest #nixVersions.git
- 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
- # ❯❯❯ sqlite search related
- sqlite
- # this will create a script that will rebuild and upgrade your setup; using shell script syntax
- (writeScriptBin "nix-rebuild" ''
- #!${stdenv.shell}
- #cd <path-to-flake> || exit 1
- nix flake update
- nix profile upgrade '.*'
- '')
- # puts in your root the nixpkgs version
- (writeTextFile {
- name = "nixpkgs-version";
- destination = "/nixpkgs-version";
- text = lib.version;
- })
- ];
- }
-#+END_SRC
-
** derivation.nix :default:
#+HEADER: :tangle ../derivation.nix
-#+HEADER: :tangle-mode (identity #o644)
+#+HEADER: :tangle-mode (identity #o755)
+#+HEADER: :shebang "#!/usr/bin/env -S nix-build derivation.nix"
#+HEADER: :noweb yes
#+BEGIN_SRC nix
{
@@ -467,10 +414,13 @@ with (
mkDubDerivation rec {
pname = "spine";
version = "<<spine_version>>";
- #zipfile = "spine-0.12.0-tag-0.11.2.r107.gf89a107.tar.gz";
- src = fetchTarball {
- url = "<<spine_tarball_path_url>>";
- sha256 = "<<spine_tarball_sha256>>";
+ # fetched from the same upstream the flake's `inputs.spine` points at
+ # (git://git.sisudoc.org/software/sisudoc-spine). Unlike flake inputs,
+ # builtins.fetchGit is usable from a plain (non-flake) derivation.nix.
+ src = builtins.fetchGit {
+ url = "git://git.sisudoc.org/software/sisudoc-spine";
+ ref = "main";
+ shallow = true;
};
nativeBuildInputs = with pkgs; [dub ldc];
buildInputs = with pkgs; [nixVersions.latest sqlite];
@@ -493,46 +443,6 @@ with (
/srv/www/spine
#+END_SRC
-#+NAME: spine_tarball_path
-#+HEADER: :noweb yes
-#+BEGIN_SRC nix
-/home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/tarball
-#+END_SRC
-
-#+NAME: spine_tarball_path_url
-#+HEADER: :noweb yes
-#+BEGIN_SRC nix
-file://<<spine_tarball_path>>/<<spine_tarball_filename>>
-#+END_SRC
-
-#+NAME: spine_git_file_path
-#+HEADER: :noweb yes
-#+BEGIN_SRC nix
-/home/ralph/grotto/repo/git.repo/projects/doc-reform/code/software/sisudoc-spine
-#+END_SRC
-
-#+NAME: nixpkgs_local
-#+BEGIN_SRC shell
-/srv/nixpkgs-dev/nixpkgs
-#+END_SRC
-
-#+NAME: spine_git_file_path_url
-#+HEADER: :noweb yes
-#+BEGIN_SRC nix
-git+file://<<spine_git_file_path>>
-#+END_SRC
-
-#+NAME: spine_tarball_filename
-#+HEADER: :noweb yes
-#+BEGIN_SRC nix
-spine-0.12.0-tag-0.11.2.r107.gf89a107.tar.gz
-#+END_SRC
-
-#+NAME: spine_tarball_sha256
-#+HEADER: :noweb yes
-#+BEGIN_SRC nix
-sha256:03dr7dn7kq6arw4ry7qar13iqmi1caw70imfjwi8qr7g2j4mnk2q
-#+END_SRC
#+NAME: project_path_local_out_static_
#+BEGIN_SRC nix
@@ -557,11 +467,6 @@ github:NixOS/nixpkgs/nixpkgs-unstable
"nixpkgs/nixos-unstable";
#+END_SRC
-#+HEADER: :noweb yes
-#+BEGIN_SRC nix
-<<nixpkgs_path_local>>
-#+END_SRC
-
* SHARED
** version and other things shared
*** spine project VERSION :version:set:project:
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
'';
}