From a615ba442e4c175e957dd0f07086b877268635df Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 23 Jan 2023 16:10:00 -0500 Subject: nix & build housekeeping, alternative D compilers - compilation status - dmd (@D2.100) ok, & has been fine - ldc (@D2.100) ok, & has been fine - gdc11 available in nixpkgs does not compile awaiting gdc12 (which would also be based on @D2.100 & just might) --- org/config_nix.org | 232 +++++++++++++++++++++++------------------------------ 1 file changed, 100 insertions(+), 132 deletions(-) (limited to 'org/config_nix.org') diff --git a/org/config_nix.org b/org/config_nix.org index df999ad..dd8c548 100644 --- a/org/config_nix.org +++ b/org/config_nix.org @@ -35,8 +35,8 @@ #+HEADER: :tangle ../.envrc #+BEGIN_SRC sh -# nix_direnv_watch_file provided-filename use flake . +#use flake .#default NIX_ENFORCE_PURITY=1 NixDirEnvVersion="2.2.0" if ! has nix_direnv_version || ! nix_direnv_version ${NixDirEnvVersion}; then @@ -44,9 +44,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-dmd --print-build-logs +- nix build .#spine-ldc --print-build-logs +- nix build .#spine-gdc --print-build-logs + +nix-shell '' -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 @@ -56,11 +79,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 PATH_add result/bin export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos #export NIX_PATH=/srv/nix/nixpkgs @@ -115,11 +133,68 @@ export PROG_VER_DECLARED="`cat ./views/version.txt | grep --color=never "enum" | meta.mainProgram = "spine"; executable = true; src = self; - shell = ./default.nix; - devEnv = ./devenv.nix; + #shell = ./shell.nix; # ./default.nix; + #devEnv = ./shell.nix; # ./default.nix; + buildInputs = [ sqlite ]; + 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 + ''; + <> + }; + spine-dmd = stdenv.mkDerivation { + pname = "spine"; + inherit version; + meta.mainProgram = "spine-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 + ''; + <> + }; + spine-ldc = stdenv.mkDerivation { + pname = "spine"; + inherit version; + meta.mainProgram = "spine-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 + ''; + <> + }; + spine-gdc = stdenv.mkDerivation { + pname = "spine"; + inherit version; + meta.mainProgram = "spine-gdc"; + executable = true; + src = self; buildInputs = [ sqlite ]; - nativeBuildInputs = [ dub dmd ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ]; - <> + nativeBuildInputs = [ dub gdc gnumake ]; + buildPhase = '' + runHook preBuild + dub build --compiler=$(type -P gdc) --build=gdc --combined --skip-registry=all + runHook postBuild + ''; + <> }; #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; }); @@ -132,132 +207,12 @@ export PROG_VER_DECLARED="`cat ./views/version.txt | grep --color=never "enum" | devShells = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in with pkgs; { - devShell = mkShell { buildInputs = [ git dub dmd ldc gdc sqlite ]; }; + devShell = mkShell { }; }); }; } #+END_SRC -**** some other possible flakes (samples) -***** flake 0 - -#+NAME: flake_0 -#+HEADER: :noweb yes -#+BEGIN_SRC nix -{ - description = "a sisu like parser & document generator"; - inputs.<> - outputs = { <> }: { - <> - <> - }; -} -#+END_SRC - -***** flake single system - -#+NAME: flake_single_sytem -#+HEADER: :tangle ../flake-1-single-system_.nix -#+HEADER: :noweb yes -#+BEGIN_SRC nix -{ - description = "a sisu like parser & document generator"; - inputs.<> - outputs = { <> }: { - packages.x86_64-linux.spine = - let - pkgs = import nixpkgs { - system = "x86_64-linux"; - }; - #targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}"; - in pkgs.stdenv.mkDerivation { - <> - inherit self; - src = self; - #shell = ./shell.nix; - shell = ./default.nix; - devEnv = ./devenv.nix; - <> - buildInputs = [ sqlite ]; - nativeBuildInputs = with pkgs; [ dub <> ]; # [ dmd dub ]; [ ldc dub ]; [ gdc dub ]; - }; - <> - }; -} -#+END_SRC - -***** flake 2 - -#+NAME: flake_2 -#+HEADER: :tangle ../flake-2_.nix -#+HEADER: :noweb yes -#+BEGIN_SRC nix -{ - description = "a sisu like parser & document generator"; - inputs.<> - outputs = { <> }: - let - system = "x86_64-linux"; - pkgs = import nixpkgs { - inherit system; - }; - #lib = nixpkgs.lib; - in { - packages.x86_64-linux.spine = pkgs.stdenv.mkDerivation { - inherit system; - <> - inherit self; - src = self; - #shell = ./shell.nix; - shell = ./default.nix; - devEnv = ./devenv.nix; - <> - buildInputs = [ sqlite ]; - nativeBuildInputs = with pkgs; [ dub <> ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ]; - }; - <> - }; -} -#+END_SRC - -***** flake (multi-system) - -#+NAME: flake_multi_system_possible -#+HEADER: :tangle ../flake-0-multi-system_.nix -#+HEADER: :noweb yes -#+BEGIN_SRC nix -{ - description = "a sisu like parser & document generator"; - inputs.<> - outputs = { <> }: - let - version = "<>"; - 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. - <> - in { - packages = forAllSystems (system: - let - pkgs = nixpkgsFor.${system}; - in { - default = pkgs.stdenv.mkDerivation { - pname = "spine"; - inherit version; - src = self; - shell = ./default.nix; - devEnv = ./devenv.nix; - <> - buildInputs = [ sqlite ]; - nativeBuildInputs = with pkgs; [ dub <> ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ]; - }; - #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; - }); - }; -} -#+END_SRC - *** flake :flake: **** notes? @@ -387,9 +342,14 @@ buildPhase = '' dub build --compiler=$DC --build=$DC_ --combined --skip-registry=all runHook postBuild ''; +<> +#+END_SRC + +#+NAME: flake_phases_other_than_build +#+HEADER: :noweb yes +#+BEGIN_SRC nix checkPhase = '' runHook preCheck - HOME="$PWD" dub test --combined --skip-registry=all runHook postCheck ''; @@ -578,12 +538,14 @@ src = fetchTarball { with pkgs; mkShell { buildInputs = [ + #nix direnv nixVersions.unstable #nixFlakes nix-prefetch-git validatePkgConfig nix-tree jq nix-output-monitor git + gnumake ps ### d_build_related dub @@ -665,6 +627,12 @@ mkShell { nix-build . --no-out-link | xargs -o nix-tree nix-tree --derivation .#default + nix flake update && nix flake check --show-trace && nix flake show && nix develop .#devShell + nix build .#default --print-build-logs + + - nix build .#spine-dmd --print-build-logs + - nix build .#spine-ldc --print-build-logs + - nix build .#spine-gdc --print-build-logs " #echo "ldc `${pkgs.ldc}/bin/ldc2 -v`" ''; -- cgit v1.2.3