diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-04-10 21:18:31 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-04-10 21:18:31 -0400 |
| commit | 6cff0e3c0bea4e7bee304c411d63de26a6a9af05 (patch) | |
| tree | cd1006d28b41eb08b4884c7976760ce807669efb /org | |
| parent | flake.nix tidy & use updated names in dlang flake (diff) | |
nix keeping: nix-shell, nix-build derivation.nix
Diffstat (limited to 'org')
| -rw-r--r-- | org/config_nix.org | 211 |
1 files changed, 58 insertions, 153 deletions
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: |
