diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2023-01-24 12:38:39 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2023-01-25 10:20:16 -0500 |
commit | 11a4034556f8611820025beee07672579b672389 (patch) | |
tree | f4ec1a3c2f940d7b3b30888f78c6fb9c6de0e933 /org | |
parent | 2023, year rollover, old habit (diff) |
nix & build housekeeping, alternative D compilers
Diffstat (limited to 'org')
-rw-r--r-- | org/config_nix.org | 117 |
1 files changed, 100 insertions, 17 deletions
diff --git a/org/config_nix.org b/org/config_nix.org index 5cbff2a..21aff72 100644 --- a/org/config_nix.org +++ b/org/config_nix.org @@ -79,6 +79,7 @@ nix show-derivation /nix/store/q7n14bm8j5vzm62qaraczdb4bpyf59vv-spine-0.11.1.drv #+HEADER: :tangle ../.envrc #+BEGIN_SRC sh use flake . +#use flake .#default NIX_ENFORCE_PURITY=1 NixDirEnvVersion="2.2.0" if ! has nix_direnv_version || ! nix_direnv_version ${NixDirEnvVersion}; then @@ -86,9 +87,32 @@ if ! has nix_direnv_version || ! nix_direnv_version ${NixDirEnvVersion}; then # source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-0000000000000000000000000000000000000000000=" source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-5EwyKnkJNQeXrRkYbwwRBcXbibosCJqyIUuz9Xq+LRc=" fi +# reload when these files change +watch_file flake.lock +watch_file flake.nix +nix flake update && nix flake check --show-trace && nix flake show if [ -f .envrc-local ]; then source_env_if_exists .envrc-local || source .envrc-local fi +echo " + +- nix flake update && nix flake check --show-trace && nix flake show && nix develop .#devShell + +- nix build .#default --print-build-logs +- nix build .#spine-search-ldc --print-build-logs +- nix build .#spine-search-dmd --print-build-logs +- nix build .#spine-search-gdc --print-build-logs + +nix-shell '<nixpkgs>' -A nix --pure + +nix run .#default --print-build-logs + +nix develop --build .#default --print-build-logs + +nix shell .#default --print-build-logs --command spine -v +nix shell .#default --print-build-logs --command spine --very-verbose --epub --html --html-link-search --html-link-curate --curate --output=\"\$SpineOUT\" ./markup/pod +nix shell .#default --print-build-logs --command spine --very-verbose --html --html-link-search --html-link-curate --curate --sqlite-update --sqlite-db-filename=\"spine.search.db\" --cgi-sqlite-search-filename=\"spine_search\" --sqlite-db-path=\"\$SpineDBpath\" --output=\"\$SpineOUT\" ./markup/pod +" #+END_SRC **** .envrc-local CHECK MODIFY @@ -98,11 +122,6 @@ fi #+HEADER: :tangle ../.envrc-local_ #+HEADER: :noweb yes #+BEGIN_SRC sh -# reload when these files change -watch_file flake.lock -watch_file flake.nix -nix flake update; nix flake check; nix flake show -#use flake .#default export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos #export NIX_PATH=nixpkgs=/srv/nix/nixpkgs export DFLAGS="-O2 -inline -boundscheck=on -color=on" @@ -172,8 +191,9 @@ postInstall: inputs.flake-utils.url = "github:numtide/flake-utils"; outputs = { self, nixpkgs, flake-utils }: let + pname = "spine_search"; version = "<<spine_version_set>>"; - supportedSystems = [ "x86_64-linux" ]; # [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + supportedSystems = [ "x86_64-linux" ]; # [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; forAllSystems = nixpkgs.lib.genAttrs supportedSystems; nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); # nixpkgs instantiated for supported system types. in { @@ -181,22 +201,80 @@ postInstall: let pkgs = nixpkgsFor.${system}; in with pkgs; { default = stdenv.mkDerivation { - pname = "spine_search"; + inherit pname; inherit version; executable = true; src = self; shell = ./default.nix; devEnv = ./devenv.nix; buildInputs = [ sqlite ]; - nativeBuildInputs = [ dub ldc ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ]; - <<flake_phases>> + nativeBuildInputs = [ dub dmd ldc gdc gnumake ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ]; + buildPhase = '' + runHook preBuild + for DC_ in dmd ldmd2 ldc2 gdc gdmd; do + echo "- check for D compiler $DC_" + DC=$(type -P $DC_ || echo "") + if [ ! "$DC" == "" ]; then break; fi + done + if [ "$DC" == "" ]; then exit "Error: could not find D compiler"; fi + echo "$DC_ used as D compiler to build $pname" + dub build --compiler=$DC --build=$DC_ --combined --skip-registry=all + runHook postBuild + ''; + <<flake_phases_other_than_buildPhase>> + }; + spine-search-dmd = stdenv.mkDerivation { + inherit pname; + inherit version; + meta.mainProgram = "spine_search-dmd"; + executable = true; + src = self; + buildInputs = [ sqlite ]; + nativeBuildInputs = [ dub dmd gnumake ]; + buildPhase = '' + runHook preBuild + dub build --compiler=$(type -P dmd) --build=dmd --combined --skip-registry=all + runHook postBuild + ''; + <<flake_phases_other_than_buildPhase>> + }; + spine-search-ldc = stdenv.mkDerivation { + inherit pname; + inherit version; + meta.mainProgram = "spine_search-ldc"; + executable = true; + src = self; + buildInputs = [ sqlite ]; + nativeBuildInputs = [ dub ldc gnumake ]; + buildPhase = '' + runHook preBuild + dub build --compiler=$(type -P ldc2) --build=ldc2 --combined --skip-registry=all + runHook postBuild + ''; + <<flake_phases_other_than_buildPhase>> + }; + spine-search-gdc = stdenv.mkDerivation { + inherit pname; + inherit version; + meta.mainProgram = "spine_search-gdc"; + executable = true; + src = self; + buildInputs = [ sqlite ]; + nativeBuildInputs = [ dub gdc gnumake ]; + buildPhase = '' + runHook preBuild + dub build --compiler=$(type -P gdc) --build=gdc --combined --skip-registry=all + runHook postBuild + ''; + <<flake_phases_other_than_buildPhase>> }; #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; }); devShells = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in with pkgs; { - devShell = mkShell { buildInputs = [ git dub dmd ldc gdc sqlite ]; }; + devShell = mkShell { }; + #devShell = mkShell { buildInputs = [ git dub dmd ldc gdc sqlite ]; }; }); }; } @@ -245,10 +323,10 @@ postInstall: outputs = { <<flake_outputs>> }: let version = "<<spine_version_set>>"; - supportedSystems = [ "x86_64-linux" ]; # [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; - # helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. + supportedSystems = [ "x86_64-linux" ]; # [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + # helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); # nixpkgs instantiated for supported system types. + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); # nixpkgs instantiated for supported system types. <<flake_devshells>> in { packages = forAllSystems (system: @@ -379,9 +457,14 @@ buildPhase = '' dub build --compiler=$DC --build=$DC_ --combined --skip-registry=all runHook postBuild ''; +<<flake_phases_other_than_buildPhase>> +#+END_SRC + +#+NAME: flake_phases_other_than_buildPhase +#+HEADER: :noweb yes +#+BEGIN_SRC nix checkPhase = '' runHook preCheck - HOME="$PWD" dub test --combined --skip-registry=all runHook postCheck ''; @@ -486,7 +569,7 @@ mkShell { nix shell --print-build-logs - nix develop - nix develop --build .#default --print-build-logs + nix develop --build .#default --print-build-logs nix develop --build -f derivation.nix -I .envrc --print-build-logs nix develop ; eval \$buildPhase @@ -765,10 +848,10 @@ pkgs.callPackage ./derivation.nix {} #+HEADER: :tangle ../devenv.nix #+HEADER: :tangle-mode (identity #o755) #+BEGIN_SRC nix -{ pkgs ? import <nixpkgs> { }, name ? "user-env" }: with pkgs; +{ pkgs ? import <nixpkgs> { }, name ? "user-env" }: with pkgs; buildEnv { inherit name; - extraOutputsToInstall = [ "out" "man" "lib" ]; # to get all needed symlinks + extraOutputsToInstall = [ "out" "man" "lib" ]; # to get all needed symlinks paths = [ #nix # if not on NixOS, this is needed direnv |