From 4437c10fad8925d6322c83bf1553daa9a36ceb31 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 2 Jan 2021 14:06:16 -0500 Subject: nix, work on build --- org/spine_build_scaffold.org | 1062 ++++++++++++++++++++++++------------------ 1 file changed, 615 insertions(+), 447 deletions(-) (limited to 'org') diff --git a/org/spine_build_scaffold.org b/org/spine_build_scaffold.org index dd043e2..e06bbc6 100644 --- a/org/spine_build_scaffold.org +++ b/org/spine_build_scaffold.org @@ -999,30 +999,6 @@ tangle_maker: (kill-buffer)) '($$ORGFILES)))" 2>&1 #+END_SRC -#+NAME: make_nix_project_shell -#+BEGIN_SRC makefile -nixsh_dmd_nixpkg: - ln -sf nixEnv/shells/shell-dmd-verNix.nix shell.nix; \ - ln -sf nixEnv/dub/mkDub-dmd.nix mkDub.nix; \ - ls -la shell.nix mkDub.nix | cut -d " " -f 9-; \ - nix-shell; -nixsh_dmd_user: - ln -sf nixEnv/shells/shell-dmd-verUser.nix shell.nix; \ - ln -sf nixEnv/dub/mkDub-dmd.nix mkDub.nix; \ - ls -la shell.nix mkDub.nix | cut -d " " -f 9-; \ - nix-shell; -nixsh_ldc_nixpkg: - ln -sf nixEnv/shells/shell-ldc-verNix.nix shell.nix; \ - ln -sf nixEnv/dub/mkDub-ldc.nix mkDub.nix; \ - ls -la shell.nix mkDub.nix | cut -d " " -f 9-; \ - nix-shell; -nixsh_ldc_user: - ln -sf nixEnv/shells/shell-ldc-verUser.nix shell.nix; \ - ln -sf nixEnv/dub/mkDub-ldc.nix mkDub.nix; \ - ls -la shell.nix mkDub.nix | cut -d " " -f 9-; \ - nix-shell; -#+END_SRC - *** git snapshot #+NAME: make_git_snapshot @@ -1045,7 +1021,7 @@ gitsnapshot: distclean tangle #+BEGIN_SRC json :NO-tangle ../dub.settings.json { "defaultArchitecture": "x86_64", - "defaultCompiler": "ldc" + "defaultCompiler": "ldc" } #+END_SRC @@ -1163,7 +1139,7 @@ gitsnapshot: distclean tangle } #+END_SRC -* dub.sdl :dub:config:sdl: +* dub.sdl REFERENCE :dub:config:sdl: Every DUB package should contain a [[http://code.dlang.org/package-format?lang=json][dub.json]] (or [[http://code.dlang.org/package-format?lang=sdl][dub.sdl]]) not configured here using dub.json for the moment @@ -1183,11 +1159,11 @@ stringImportPaths "./views" buildRequirements "allowWarnings" targetType "executable" platforms "posix" -dependency "d2sqlite3" version="~><>" # https://code.dlang.org/packages/d2sqlite3 http://biozic.github.io/d2sqlite3/d2sqlite3 +dependency "d2sqlite3" version="~><>" # https://code.dlang.org/packages/d2sqlite3 http://biozic.github.io/d2sqlite3/d2sqlite3 subconfiguration "d2sqlite3" "all-included" -dependency "imageformats" version="~><>" # https://code.dlang.org/packages/imageformats https://github.com/lgvz/imageformats -dependency "dyaml" version="~><>" # https://code.dlang.org/packages/dyaml https://github.com/dlang-community/D-YAML -dependency "tinyendian" version="~><>" # http://code.dlang.org/packages/tinyendian https://github.com/dlang-community/tinyendian // dyaml dependency +dependency "imageformats" version="~><>" # https://code.dlang.org/packages/imageformats https://github.com/lgvz/imageformats +dependency "dyaml" version="~><>" # https://code.dlang.org/packages/dyaml https://github.com/dlang-community/D-YAML +dependency "tinyendian" version="~><>" # http://code.dlang.org/packages/tinyendian https://github.com/dlang-community/tinyendian // dyaml dependency #+END_SRC ** default @@ -1311,7 +1287,7 @@ configuration "build" { } #+END_SRC -* meson :meson:build: +* meson REVISIT :meson:build: ** notes http://mesonbuild.com/D.html @@ -1722,20 +1698,6 @@ tinyendian_dep = declare_dependency( - see shell.nix minimal content: -#+BEGIN_SRC nix :NO-tangle shell.nix -with import {}; -let - dub2nix-src = fetchTarball { - url = "https://github.com/lionello/dub2nix/archive/master.tar.gz"; - }; - dub2nix = (import dub2nix-src) { inherit pkgs; }; -in mkShell { - buildInputs = [ - dub dmd rdmd sqlite dub2nix nix-prefetch-git - ]; -} -#+END_SRC - - run: nix-shell - run: dub init @@ -1743,7 +1705,7 @@ in mkShell { - add d2sqlite3 dependency (provide as dependency during “dub init” or add it to the dub.json manually) -#+BEGIN_SRC json :NO-tangle dub.json +#+BEGIN_SRC json :NO-tangle ../dub.json { "authors": [ "Ralph Amissah" @@ -1791,6 +1753,7 @@ make modificatons if desired nix-build -I nixpkgs=[path-to]/nixpkgs ** envrc :envrc: +*** .envrc #+BEGIN_SRC nix :tangle ../.envrc if type lorri &>/dev/null; then @@ -1808,231 +1771,259 @@ if [ -e .envrc-local ]; then fi #+END_SRC -** shells shell.nix SELECT :shell: - - nix-shell - nix-shell --pure -I nixpkgs=/nixpkgs-ra/nixpkgs - nix-shell --pure -p "with import /nixpkgs-ra/nixpkgs {}; ldc" - -*** dmd shell :dmd: +- enable flakes -- ln -sf nixEnv/shells/shell-dmd-verNix.nix shell.nix -- ln -sf nixEnv/shells/shell-dmd-verUser.nix shell.nix - -- ln -sf nixEnv/dub/mkDub-dmd.nix mkDub.nix - -**** nixpkg - -- ln -sf nixEnv/shells/shell-dmd-verNix.nix shell.nix -- ln -sf nixEnv/dub/mkDub-dmd.nix mkDub.nix - -#+BEGIN_SRC nix :tangle ../nixEnv/shells/shell-dmd-verNix.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-shell" -{ pkgs ? import {} }: -<> +#+BEGIN_SRC nix :NO-tangle ../.envrc +if [ -f flake.lock ] && [ -f flake.nix ]; then + # reload when these files change + watch_file flake.nix + watch_file flake.lock + # load the flake devShell + if [ ! -d $(direnv_layout_dir) ]; then + mkdir $(direnv_layout_dir) + fi + eval "$(nix --experimental-features 'nix-command flakes' print-dev-env --profile "$(direnv_layout_dir)/flake-profile")" +else + # fall back to using direnv's builtin nix support + # to prevent bootstrapping problems. + # use nix + if type lorri &>/dev/null; then + echo "direnv: using lorri from PATH ($(type -p lorri))" + eval "$(lorri direnv)" + else + # fall back to using direnv's builtin nix support + # to prevent bootstrapping problems. + use nix + NIX_ENFORCE_PURITY=0 + fi + # source an additional user-specific .envrc in ./.envrc-local + if [ -e .envrc-local ]; then + source .envrc-local + fi +fi #+END_SRC -**** user +*** .envrc-local CHECK MODIFY -- ln -sf nixEnv/shells/shell-dmd-verUser.nix shell.nix -- ln -sf nixEnv/dub/mkDub-dmd.nix mkDub.nix +- bespoke modify appropriately and generate if needed -#+BEGIN_SRC nix :tangle ../nixEnv/shells/shell-dmd-verUser.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-shell" -<> -<> +#+BEGIN_SRC nix :NO-tangle ../.envrc-local +export NIX_PATH=nixpkgs=<> +nix-instantiate --find-file nixpkgs #+END_SRC -*** ldc shell :ldc: - -- ln -sf nixEnv/shells/shell-ldc-verNix.nix shell.nix -- ln -sf nixEnv/shells/shell-ldc-verUser.nix shell.nix - -- ln -sf nixEnv/dub/mkDub-ldc.nix mkDub.nix - -**** nixpkg - -- ln -sf nixEnv/shells/shell-ldc-verNix.nix shell.nix -- ln -sf nixEnv/dub/mkDub-ldc.nix mkDub.nix +**** nixpkgs_path SETUP +***** nixpkgs select path SELECT -#+BEGIN_SRC nix :tangle ../nixEnv/shells/shell-ldc-verNix.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-shell" -{ pkgs ? import {} }: -<> +#+NAME: nixpkgs_path +#+BEGIN_SRC nix +<> #+END_SRC -**** user +***** nixpkgs path options -- ln -sf nixEnv/shells/shell-ldc-verUser.nix shell.nix -- ln -sf nixEnv/dub/mkDub-ldc.nix mkDub.nix +- -#+BEGIN_SRC nix :tangle ../nixEnv/shells/shell-ldc-verUser.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-shell" -<> -<> +#+NAME: nixpkgs_path_default +#+BEGIN_SRC nix + #+END_SRC -***** (import ./nixEnv/overlays/ldcVersion.nix) +- local path -#+NAME: nix_shell_overlay_user_version_ldc +#+NAME: nixpkgs_path_local #+BEGIN_SRC nix -{ pkgs ? import { - overlays = [ (import ../overlays/ldcVersion.nix) ]; -} }: +/nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs #+END_SRC -**** mkShell with build inputs +** flake :flake: -#+NAME: nix_shell_mkshell_with_buildInputs_ldc -#+BEGIN_SRC nix -pkgs.mkShell { - buildInputs = with pkgs; [ - (import ./packages-ldc.nix { inherit pkgs; }) - ]; - shellHook = '' - # nix-build - ## nix-build -I nixpkgs= - ## nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs - ''; -} -#+END_SRC +- flake.nix + /nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs + ./shell.nix + - shell.nix + ./shell-packages.nix + - shell-packages.nix + - default.nix + ./nix/mkDub.nix + - mkdub.nix + ./nix/dub.selections.nix + - dub.selections.nix -- overlay header +nix develop -*** parts -**** dub2nix +#+BEGIN_SRC nix :tangle ../flake.nix +{ + description = "a sisu like document parser"; + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "/nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs"; + # pkgs /nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs {} + #spine.url = "/grotto-ra/repo/git.repo/projects/project-spine/doc-reform"; + #spine.url = "./."; + d2sqlite3 = { + url = "github:dlang-community/d2sqlite3"; + flake = false; + }; + tinyendian = { + url = "github:kiith-sa/tinyendian"; + flake = false; + }; + dyaml = { + url = "github:dlang-community/D-YAML"; + flake = false; + }; + imageformats = { + url = "github:lgvz/imageformats"; + flake = false; + }; + dub2nix-src = { + url = "github:lionello/dub2nix"; + flake = false; + }; + }; + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.simpleFlake { + #flake-utils.lib.spine { + inherit self nixpkgs; + name = "spine"; + #shell = ./shell.nix; + }; +} +#+END_SRC -#+NAME: nix_shell_dub2nix -#+BEGIN_SRC nix -dub2nix-src = fetchTarball { - url = "https://github.com/lionello/dub2nix/archive/master.tar.gz"; -}; -dub2nix = (import dub2nix-src) { inherit pkgs; }; +#+BEGIN_SRC nix :NO-tangle ../flake.nix +{ + description = "a sisu like document parser"; + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "/nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs"; + # pkgs /nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs {} + #spine.url = "/grotto-ra/repo/git.repo/projects/project-spine/doc-reform"; + #spine.url = "./."; + }; + outputs = { self, nixpkgs, flake-utils }: + #flake-utils.lib.eachSystem [ "x86_64-linux" "defaultPackage.x86_64-linux" "packages.x86_64-linux.defaultPackage.x86_64-linux" ] (system: + flake-utils.lib.eachDefaultSystem (system: + let + #pkgs = ${system}; + pkgs = nixpkgs.legacyPackages.${system}; + # project = pkgs.spine.project' { + # src = ./.; + # compiler-nix-name = "ldc"; + # }; + in { #project.flake {} // { + #devShell = project.shellFor { + # (import ./shell.nix self { inherit pkgs; }); + #}; + devShell = import ./default.nix self { inherit pkgs; }; + } + ); +} #+END_SRC -**** overlays :overlays: +** shell.nix :shell: -#+NAME: nix_shell_overlay_none -#+BEGIN_SRC nix -{ overlays = [ ]; } -#+END_SRC + nix-shell -***** (import ./nixEnv/overlays/dmdVersion.nix) + shell.nix --pure + shell.nix --pure -I .envrc -no working overlay, default none: + nix-shell --pure -I nixpkgs=/nixpkgs-ra/nixpkgs + nix-shell --pure -p "with import /nixpkgs-ra/nixpkgs {}; ldc" + nix-shell --pure -p "with import /nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs {}; [dub ldc]" -#+NAME: nix_shell_overlay_user_version_dmd -#+BEGIN_SRC nix -{ pkgs ? import - { overlays = [ ]; } -}: -#+END_SRC + shell.nix direnv: export +IN_NIX_SHELL -use if working overlay: + nix-shell -p nixFlakes + nix-shell -p nixFlakes --pure + nix-shell -p nixFlakes --pure -p "with import /nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs {}; [dub ldc]" -#+BEGIN_SRC nix -{ overlays = [ - (import ../overlays/dmdVersion.nix) -]; } -#+END_SRC + shell.nix -I .envrc + shell.nix -**** build inputs + nix-build + nix-build -I nixpkgs= + nix-build -I .envrc -#+NAME: nix_shell_mkshell_with_buildInputs_dmd -#+BEGIN_SRC nix +#+BEGIN_SRC nix :tangle ../shell.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-shell" +{ pkgs ? import {} }: pkgs.mkShell { buildInputs = with pkgs; [ - nix - dub - dmd - rdmd - sqlite - dub2nix - nix-prefetch-git + (import ./nix/shell-packages.nix { inherit pkgs; }) ]; + shellHook = '' + nix-build + echo "built spine @ ./result/bin/spine" + ''; } #+END_SRC -**** build inputs ldc +- combining shell.nix & default.nix to build package: -#+BEGIN_SRC nix :tangle ../nixEnv/shells/packages-ldc.nix -{ pkgs ? import {} }: -let - dub2nix-src = fetchTarball { - url = "https://github.com/lionello/dub2nix/archive/master.tar.gz"; - }; - dub2nix = (import dub2nix-src) { inherit pkgs; }; -in -with pkgs; [ - nix - ldc - sqlite - nix-prefetch-git - validatePkgConfig -] -#+END_SRC - -*** shell with dmd & ldc :shell: - -#+NAME: nix_shell_with_compilers_dmd_and_ldc -#+BEGIN_SRC nix -{ pkgs ? import { - overlays = [ - (import ./nixEnv/overlays/ldcVersion.nix) - ]; } +#+BEGIN_SRC nix :NO-tangle ../shell.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-shell" +#!/usr/bin/env -S nix-shell +{ pkgs ? import {}, + stdenv ? pkgs.stdenv, }: -let - dub2nix-src = fetchTarball { - url = "https://github.com/lionello/dub2nix/archive/master.tar.gz"; +with import ./nix/mkDub.nix { inherit pkgs; }; +mkDubDerivation rec { + name = "spine-${version}"; + version = "0.11.1"; + src = ./.; + buildInputs = with pkgs; [( + import ./nix/shell-packages.nix + { inherit pkgs; } + )]; + meta = with stdenv.lib; { + homepage = http://sisudoc.org; + description = "a sisu like document parser"; + license = licenses.agpl3Plus; + platforms = platforms.linux; + maintainers = [ RalphAmissah ]; }; - dub2nix = (import dub2nix-src) { inherit pkgs; }; -in pkgs.mkShell { - buildInputs = with pkgs; [ - nix - dub - dmd - ldc - rdmd - sqlite - dub2nix - nix-prefetch-git - ]; } #+END_SRC -*** dub2nix version :dub2nix: - -#+BEGIN_SRC nix - dub2nix-src = fetchTarball { - url = "https://github.com/lionello/dub2nix/archive/8e7c65f1fd8c1ef5b32e2bf63ba80fe4f059ec15.tar.gz"; - sha256 = "0imlbpv40h303h4mq4vijc9psl401n4sdxn3yp6k4gp2n0853xpm"; - }; -#+END_SRC - -** default.nix :default: - -- default.nix -I nixpkgs= - e.g. default.nix -I nixpkgs=/nixpkgs-ra/nixpkgs -- nix-build -I nixpkgs= - e.g. nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs - -#+BEGIN_SRC txt :tangle ../default.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-build" -<> -#+END_SRC - -#+BEGIN_SRC txt :tangle ../project.nix -<> -#+END_SRC +- package import incorporated, all in one file -#+NAME: nix_project -#+BEGIN_SRC nix +#+BEGIN_SRC nix :NO-tangle ../shell.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-shell" { pkgs ? import {}, stdenv ? pkgs.stdenv, }: -with import ./mkDub.nix { inherit pkgs; }; +with import ./nix/mkDub.nix { inherit pkgs; }; mkDubDerivation rec { name = "spine-${version}"; - version = "<>"; + version = "0.11.1"; src = ./.; buildInputs = [ pkgs.sqlite + ( + let + dub2nix-src = fetchTarball { + url = "https://github.com/lionello/dub2nix/archive/master.tar.gz"; + }; + dub2nix = (import dub2nix-src) { inherit pkgs; }; + in + with pkgs; [ + nixFlakes + dub + ldc + sqlite + nix-prefetch-git + validatePkgConfig + ] + ) ]; + shellHook = '' + # nix-build -I nixpkgs= + nix-build + echo "built spine" + ''; + installPhase = '' + install -m755 -D spine $out/bin/spine + echo "built $out/bin/spine" + ''; meta = with stdenv.lib; { homepage = http://sisudoc.org; description = "a sisu like document parser"; @@ -2043,143 +2034,113 @@ mkDubDerivation rec { } #+END_SRC -** mkDub.nix :mkDub: +** default.nix :default: -Get current mkDub.nix from the dub2nix project: +- default.nix -I nixpkgs= + e.g. default.nix -I nixpkgs=/nixpkgs-ra/nixpkgs -#+BEGIN_SRC sh -aria2c https://raw.githubusercontent.com/lionello/dub2nix/master/mkDub.nix -#+END_SRC +- nix-build -I nixpkgs= + e.g. nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs -*** mkDub dmd + nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs + nix-build -I .envrc-local + nix-build -I .envrc + default.nix -I .envrc + default.nix -#+BEGIN_SRC nix :tangle ../nixEnv/dub/mkDub-dmd.nix +#+BEGIN_SRC nix :tangle ../default.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-build" { pkgs ? import {}, stdenv ? pkgs.stdenv, - rdmd ? pkgs.rdmd, - dmd ? pkgs.dmd, - dub ? pkgs.dub }: - -with stdenv; -let - # Filter function to remove the .dub package folder from src - filterDub = name: type: let baseName = baseNameOf (toString name); in ! ( - type == "directory" && baseName == ".dub" - ); - - # Convert a GIT rev string (tag) to a simple semver version - rev-to-version = builtins.replaceStrings ["v" "refs/tags/v"] ["" ""]; - - dep2src = dubDep: pkgs.fetchgit { inherit (dubDep.fetch) url rev sha256 fetchSubmodules; }; - - # Fetch a dependency (source only for now) - fromDub = dubDep: mkDerivation rec { - name = "${src.name}-${version}"; - version = rev-to-version dubDep.fetch.rev; - nativeBuildInputs = [ rdmd dmd dub ]; - src = dep2src dubDep; - - buildPhase = '' - runHook preBuild - export HOME=$PWD - dub build -b=release - runHook postBuild - ''; - - # outputs = [ "lib" ]; - - # installPhase = '' - # runHook preInstall - # mkdir -p $out/bin - # runHook postInstall - # ''; - }; - - # Adds a local package directory (e.g. a git repository) to Dub - dub-add-local = dubDep: "dub add-local ${(fromDub dubDep).src.outPath} ${rev-to-version dubDep.fetch.rev}"; - - # The target output of the Dub package - targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}"; - - # Remove reference to build tools and library sources - disallowedReferences = deps: [ dmd rdmd dub ] ++ builtins.map dep2src deps; - - removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}''; - -in { - inherit fromDub; - - mkDubDerivation = lib.makeOverridable ({ - src, - nativeBuildInputs ? [], - dubJSON ? src + "/dub.json", - selections ? src + "/dub.selections.nix", - deps ? import selections, - passthru ? {}, - package ? lib.importJSON dubJSON, - ... - } @ attrs: stdenv.mkDerivation (attrs // { - - pname = package.name; - - nativeBuildInputs = [ rdmd dmd dub pkgs.removeReferencesTo ] ++ nativeBuildInputs; - disallowedReferences = disallowedReferences deps; - - passthru = passthru // { - inherit dub dmd rdmd pkgs; - }; - - src = lib.cleanSourceWith { - filter = filterDub; - src = lib.cleanSource src; - }; +}: +with import ./nix/mkDub.nix { inherit pkgs; }; +mkDubDerivation rec { + name = "spine-${version}"; + version = "<>"; + src = ./.; + buildInputs = [ + pkgs.sqlite + (import ./nix/shell-packages.nix { inherit pkgs; }) + ]; + # installPhase = '' + # install -m755 -D spine $out/bin/spine + # echo "built $out/bin/spine" + # ''; + <> +} +#+END_SRC - preFixup = '' - find $out/bin -type f -exec ${removeExpr (disallowedReferences deps)} '{}' + || true - ''; +** project.nix :project: - buildPhase = '' - runHook preBuild +#+BEGIN_SRC nix :tangle ../project.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-build" +{ pkgs ? import {}, + stdenv ? pkgs.stdenv, +}: +with import ./nix/mkDub.nix { inherit pkgs; }; +mkDubDerivation rec { + name = "spine-${version}"; + version = "<>"; + src = ./.; + buildInputs = [ + pkgs.sqlite + ( + <> + ) + ]; + shellHook = '' + # nix-build -I nixpkgs= + nix-build + echo "built spine" + ''; + installPhase = '' + install -m755 -D spine $out/bin/spine + echo "built $out/bin/spine" + ''; + <> +} +#+END_SRC - export HOME=$PWD - ${lib.concatMapStringsSep "\n" dub-add-local deps} - dub build --build=release --combined --skip-registry=all +- unused + - installPhase - runHook postBuild - ''; +#+BEGIN_SRC txt +installPhase = '' + mkdir -p $out/bin + cp spine $out/bin + chmod +x $out/bin/spine +''; +#+END_SRC - checkPhase = '' - runHook preCheck +** project meta - export HOME=$PWD - ${lib.concatMapStringsSep "\n" dub-add-local deps} - dub test --combined --skip-registry=all +#+NAME: nix_project_meta +#+BEGIN_SRC nix +meta = with stdenv.lib; { + homepage = http://sisudoc.org; + description = "a sisu like document parser"; + license = licenses.agpl3Plus; + platforms = platforms.linux; + maintainers = [ RalphAmissah ]; +}; +#+END_SRC - runHook postCheck - ''; +** mkDub.nix :mkDub: - installPhase = '' - runHook preInstall +Get current mkDub.nix from the dub2nix project: - mkdir -p $out/bin - cp -r "${targetOf package}" $out/bin +#+BEGIN_SRC sh +aria2c https://raw.githubusercontent.com/lionello/dub2nix/master/mkDub.nix ./nix/. +#+END_SRC - runHook postInstall - ''; +*** dub2nix - meta = lib.optionalAttrs (package ? description) { - description = package.description; - } // attrs.meta or {}; - } // lib.optionalAttrs (!(attrs ? version)) { - # Use name from dub.json, unless pname and version are specified - name = package.name; - })); -} +#+BEGIN_SRC nix :tangle ../nix/shell-packages.nix +{ pkgs ? import {} }: +<> #+END_SRC -*** mkDub ldc HACK +*** mkDub -#+BEGIN_SRC nix :tangle ../nixEnv/dub/mkDub-ldc.nix +#+BEGIN_SRC nix :tangle ../nix/mkDub.nix { pkgs ? import {}, stdenv ? pkgs.stdenv, ldc ? pkgs.ldc, @@ -2239,7 +2200,7 @@ in { src, nativeBuildInputs ? [], dubJSON ? src + "/dub.json", - selections ? src + "/dub.selections.nix", + selections ? src + "/nix/dub.selections.nix", deps ? import selections, passthru ? {}, package ? lib.importJSON dubJSON, @@ -2303,93 +2264,39 @@ in { } #+END_SRC -** overlays :overlay: -*** compilers (latest versions) [version information set elsewhere] -**** ldcVersion.nix overlay :ldc:version: +** dub2nix & shared pkgs SHARED +*** dub2nix with pkgs shared -#+BEGIN_SRC nix :tangle ../nixEnv/overlays/ldcVersion.nix -self: super: rec { - ldc = super.ldc.overrideAttrs(oldAttrs: rec { - pname = "ldc"; - <> - name = "${pname}-${version}"; - src = super.fetchurl { - url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"; - sha256 = sha256; - }; - postUnpack = '' - patchShebangs . - ''; - }); -} -#+END_SRC - -**** dmdVersion.nix overlay HACK :dmd:version: - -no working overlay, tangle to work on - -#+BEGIN_SRC nix :NO-tangle ../nixEnv/overlays/dmdVersion.nix -self: super: rec { - pname = "dmd"; - <> - dmd = super.dmd.overrideAttrs(oldAttrs: rec { - inherit pname year version sha256; - name = "${pname}-${version}"; - src = super.fetchurl { - url = "http://downloads.dlang.org/releases/${year}/dmd.${version}.linux.tar.xz"; - sha256 = sha256; - }; - # postUnpack = '' - # patchShebangs . - # ''; - }); -} -#+END_SRC - -** version info REVIEW :version: - -- https://dlang.org/download.html - -*** compilers (set latest versions) :compiler:version: -**** ldc VERSION :version:set:ldc: - -- https://github.com/ldc-developers/ldc/releases - -***** 1.24.0 HACK - -- https://github.com/ldc-developers/ldc/releases/tag/v1.24.0 - - nix-prefetch-url https://github.com/ldc-developers/ldc/releases/download/v1.24.0/ldc-1.24.0-src.tar.gz - -#+NAME: ldc_version_info +#+NAME: nix_dub2nix_with_pkgs #+BEGIN_SRC nix -version = "1.24.0"; -sha256 = "0g5svf55i0kq55q49awmwqj9qi1n907cyrn1vjdjgs8nx6nn35gx"; +let + <> +in +with pkgs; [ + <> +] #+END_SRC -- ldc-1.24.0 overlay does not build with latest nixos version, nixos-20.09 - nixos at ldc-1.20.0 - -***** 1.23.0 - -- https://github.com/ldc-developers/ldc/releases/tag/v1.23.0 - - nix-prefetch-url https://github.com/ldc-developers/ldc/releases/download/v1.23.0/ldc-1.23.0-src.tar.gz +*** get dub2nix +#+NAME: nix_shell_dub2nix #+BEGIN_SRC nix -version = "1.23.0"; -sha256 = "1fdgj222x29as466vdxy9c0m82zzlsb7vnvvh89n2riszcrx463d"; +dub2nix-src = fetchTarball { + url = "https://github.com/lionello/dub2nix/archive/master.tar.gz"; +}; +dub2nix = (import dub2nix-src) { inherit pkgs; }; #+END_SRC -**** dmd :dmd: -https://dlang.org/changelog/index.html -https://dlang.org/changelog/pending.html -http://downloads.dlang.org/releases/ -http://downloads.dlang.org/releases/2.x/ +*** with pkgs list -#+NAME: dmd_version_info +#+NAME: nix_shell_with_pkgs_list #+BEGIN_SRC nix -version = "2.094.0"; -sha256 = "0xhm8m46ahfx3hcibi3vws02zaplny3226f3x8cd8584gzfqyzxp"; -year = "2020"; +nixFlakes +dub +ldc +sqlite +nix-prefetch-git +validatePkgConfig #+END_SRC * .gitignore :gitignore: @@ -2419,8 +2326,8 @@ year = "2020"; !misc !misc/** !*.nix -!nixEnv -!nixEnv/** +!nix +!nix/** !.envrc !src !src/** @@ -2469,7 +2376,8 @@ tmp/** #.reggae/** #+END_SRC -* sh script to batch process _emacs org babel tangle_ :shell_script:tangle: +* misc +** sh script to batch process _emacs org babel tangle_ :shell_script:tangle: [[http://orgmode.org/manual/Batch-execution.html]] creates a shell batch script called "tangle", that will tangle (emacs org babel tangle) org files in ./org/ to create .d source files in ./src/doc_reform/ @@ -2504,23 +2412,66 @@ emacs --batch -Q -q \ #+END_SRC ** build +*** nix +**** nix-shell + +- default.nix + +#+BEGIN_SRC sh +nix-shell +nix-build +#+END_SRC + +- project.nix + +#+BEGIN_SRC sh +nix-shell +nix-build project.nix +#+END_SRC + +**** nix-shell --pure + +- default.nix + +#+BEGIN_SRC sh +nix-shell --pure +nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs +#+END_SRC + +- project.nix + +#+BEGIN_SRC sh +nix-shell --pure +nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs project.nix +#+END_SRC + +**** derivation .drv + +#+BEGIN_SRC sh +nix show-derivation /nix/store/q7n14bm8j5vzm62qaraczdb4bpyf59vv-spine-0.11.1.drv +#+END_SRC + *** dub -#+BEGIN_SRC sh :tangle no +#+BEGIN_SRC sh dub build -h #+END_SRC #+BEGIN_SRC sh -time (dub --compiler=dmd --config=spine-dmd --debug=steps) +time dub --compiler=ldc2 -v --force time (dub --compiler=ldc2 --config=spine-ldc --debug=steps) -time (dub --compiler=gdc --config=spine-gdc --debug=steps) - time (dub --compiler=ldc2 --config=spine-ldc --debug=checkdoc --debug=summary --debug=dumpdoc) time (dub --compiler=ldc2 --config=spine-ldc --debug=io) time (dub --compiler=ldc2 --config=spine-ldc --debug=checkdoc --debug=summary --debug=dumpdoc --debug=io) time (dub --compiler=ldc2 --config=spine-ldc-debug --debug=io) -time (dub --compiler=gdc --config=spine-gdc-debug --debug=io) + +time dub --compiler=dmd -v --force +time (dub --compiler=dmd --config=spine-dmd --debug=steps) time (dub --compiler=dmd --config=spine-dmd-debug --debug=io) + +time dub --compiler=gdc -v --force +time (dub --compiler=gdc --config=spine-gdc --debug=steps) +time (dub --compiler=gdc --config=spine-gdc-debug --debug=io) #+END_SRC *** make @@ -2541,36 +2492,26 @@ time make tangle ldc time make ldc_testrun_find_pod_epub #+END_SRC -** dub zfunc :zfunc: -*** ,dubdmd :dmd: - -#+BEGIN_SRC sh :tangle no -time dub --compiler=dmd -v --force -#+END_SRC - -*** ,dubldc :ldc: - -#+BEGIN_SRC sh :tangle no -time dub --compiler=ldc2 -v --force -#+END_SRC - -*** ,dubgdc :gdc: - -#+BEGIN_SRC sh :tangle no -time dub --compiler=gdc -v --force -#+END_SRC - ** git *** project version +#+BEGIN_SRC sh echo $(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g') +#+END_SRC *** what files changed + +#+BEGIN_SRC sh git whatchanged --since="1 day ago" --oneline --name-only --pretty=format: | sort -u git log --since="1 day ago" --name-only --pretty=format: | sort -u +#+END_SRC ** test run *** e.g. + +#+BEGIN_SRC sh +time (./result/bin/spine --source --html -v --output-dir=tmp/program-output data/pod/sisu-manual/media/text/en/sisu_markup.sst ) + time (./bin/spine-ldc --source --html -v --output-dir=tmp/program-output data/pod/sisu-manual/media/text/en/sisu_markup.sst ) time (./bin/spine-ldc --source --html -v --output-dir=tmp/program-output data/pod/sisu-manual ) @@ -2596,6 +2537,43 @@ time ( find data/sisudir/media/text -name *.ss[tm] | sort | xargs ./bin/spine-ld find data/pod -maxdepth 2 -name pod.manifest | sort | xargs find data/sisudir/media/text -name *.ss[tm] | sort | xargs +#+END_SRC + +*** sort + +#+BEGIN_SRC sh +~dr/bin/spine-ldc -v --sqlite-db-create --sqlite-filename="spine.search.db" --cgi-sqlite-search-filename="spine-search" --output=/var/www/html \ + ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod/* + +~dr/bin/spine-ldc -v --sqlite-update --sqlite-filename="spine.search.db" --output=/var/www/html \ + ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod/* + +~dr/bin/spine-ldc -v --html --harvest-link --output=/var/www/html \ + ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod/* + +~dr/bin/spine-ldc -q --show-config --html --output=/var/www/html ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod + +~dr/bin/spine-ldc -q --show-config ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod + +~dr/result/bin/spine --html --output=/var/www/html /grotto-ra/repo/git.repo/projects/project-spine/doc-reform-markup/markup_samples/markup/pod/* + +~dr/result/bin/spine --very-verbose --sqlite-db-create --sqlite-filename="spine.search.db" --cgi-sqlite-search-filename="spine-search" --output=/var/www /grotto-ra/repo/git.repo/projects/project-spine/doc-reform-markup/markup_samples/markup/pod/* + +~dr/result/bin/spine --very-verbose --sqlite-update --sqlite-filename="spine.search.db" --cgi-sqlite-search-filename="spine-search" --output=/var/www /grotto-ra/repo/git.repo/projects/project-spine/doc-reform-markup/markup_samples/markup/pod/* +#+END_SRC + +- produces: + - sqlite db @: /var/www/html/sqlite/spine.search.db + - search script in D @: /var/www/html/cgi/src/spine_search.d + - html output * /var/www/html/en/html/[filename] + +#+BEGIN_SRC sh +cd /var/www/html/cgi + +cp arsd/cgi.d /var/www/html/cgi/. *-[needs to be implemented as part of code] + +dub --force --compiler=ldc2 && sudo cp -v cgi-bin/spine-search /usr/lib/cgi-bin/. +#+END_SRC *** list markup files find data/pod -name pod.manifest | sort @@ -2606,8 +2584,8 @@ time make ldc_testrun_paths_pod_pod | ag "^\".+\"|NOT found" time make ldc_testrun_find_pod_pod time make ldc_testrun_find_dir_pod time make ldc_testrun_filelist_dir_pod -** misc -*** compilers + +** compilers - [X] Set D_COMPILER (one of DMD LDC or GDC) - [X] Set debug flags (using DMD standard flag -deb @@ -2615,14 +2593,44 @@ time make ldc_testrun_filelist_dir_pod [[http://wiki.dlang.org/Compilers][D Compilers wiki https://wiki.dlang.org/Compilers]] [[http://dlang.org/download.html][D Compilers download http://dlang.org/download.html]] -*** dub :dub: +** version info REVIEW :version: + +- https://dlang.org/download.html + +*** compilers (set latest versions) :compiler:version: +**** ldc VERSION :version:set:ldc: + +- https://github.com/ldc-developers/ldc/releases + +***** 1.24.0 HACK + +- https://github.com/ldc-developers/ldc/releases/tag/v1.24.0 + - nix-prefetch-url https://github.com/ldc-developers/ldc/releases/download/v1.24.0/ldc-1.24.0-src.tar.gz + +#+NAME: ldc_version_info +#+BEGIN_SRC nix +version = "1.24.0"; +sha256 = "0g5svf55i0kq55q49awmwqj9qi1n907cyrn1vjdjgs8nx6nn35gx"; +#+END_SRC + +- ldc-1.24.0 overlay does not build with latest nixos version, nixos-20.09 + nixos at ldc-1.20.0 + +**** dmd :dmd: + +- https://dlang.org/changelog/index.html +- https://dlang.org/changelog/pending.html +- http://downloads.dlang.org/releases/ +- http://downloads.dlang.org/releases/2.x/ + +** dub :dub: https://github.com/dlang/dub/ http://code.dlang.org/getting_started http://code.dlang.org/docs/commandline -**** setup -***** dub json or sdlang +*** setup +**** dub json or sdlang Every DUB package should contain a [[http://code.dlang.org/package-format?lang=json][dub.json]] or [[http://code.dlang.org/package-format?lang=sdl][dub.sdl]] https://code.dlang.org/package-format?lang=sdl @@ -2631,7 +2639,7 @@ https://github.com/Abscissa/SDLang-D/blob/master/HOWTO.md https://code.dlang.org/docs/commandline -***** dub dependencies +**** dub dependencies dub list dub upgrade @@ -2642,8 +2650,8 @@ dub fetch unit-threaded ? sdp ~master: /home/ralph/grotto/repo/git.repo/utils/spine-x/ /home/ralph/.dub/packages/* -**** build -***** debug flags +*** build +**** debug flags #+BEGIN_SRC sh biblio @@ -2696,3 +2704,163 @@ summary table toc #+END_SRC + +*** dub (using ldc rather than dmd) overlay REFERENCE :overlay: + +#+BEGIN_SRC nix :NO-tangle ~/nixpkgs/pkgs/development/tools/build-managers/dub/default.nix +{ stdenv, fetchFromGitHub, curl, libevent, rsync , ldc ? null, dcompiler ? ldc }: + +assert dcompiler != null; + +stdenv.mkDerivation rec { + pname = "dub"; + version = "1.23.0"; + + enableParallelBuilding = true; + + src = fetchFromGitHub { + owner = "dlang"; + repo = "dub"; + rev = "v${version}"; + sha256 = "vqn6QlPMFc/sVbwHeU/eQ/1jB3KRW5PABMDUQDXkRBk="; + # nix-prefetch-url https://github.com/dlang/dub/archive/v1.23.0.tar.gz + }; + + postUnpack = '' + patchShebangs . + ''; + + # Can be removed with https://github.com/dlang/dub/pull/1368 + dubvar = "\\$DUB"; + postPatch = '' + substituteInPlace test/fetchzip.sh \ + --replace "dub remove" "\"${dubvar}\" remove" + ''; + + nativeBuildInputs = [ dcompiler libevent rsync ]; + buildInputs = [ curl ]; + + buildPhase = '' + for dc_ in dmd ldmd2 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 dub" + $dc ./build.d + ./build + ''; + + doCheck = !stdenv.isDarwin; + + checkPhase = '' + export DUB=$NIX_BUILD_TOP/source/bin/dub + export PATH=$PATH:$NIX_BUILD_TOP/source/bin/ + export DC=${dcompiler.out}/bin/${dcompiler.pname} + echo "DC out --> $DC" + export HOME=$TMP + #rm -rf test/* + rm -rf test/issue502-root-import + rm test/issue990-download-optional-selected.sh + rm test/timeout.sh + rm test/issue674-concurrent-dub.sh + rm test/issue672-upgrade-optional.sh + rm test/issue1574-addcommand.sh + rm test/issue1524-maven-upgrade-dependency-tree.sh + rm test/issue1416-maven-repo-pkg-supplier.sh + rm test/issue1037-better-dependency-messages.sh + rm test/interactive-remove.sh + rm test/fetchzip.sh + rm test/feat663-search.sh + rm test/ddox.sh + rm test/0-init-multi.sh + rm test/4-describe-data-1-list.sh + rm test/4-describe-data-3-zero-delim.sh + rm test/4-describe-import-paths.sh + rm test/4-describe-string-import-paths.sh + rm test/4-describe-json.sh + rm test/5-convert-stdout.sh + rm test/0-init-multi-json.sh + rm test/issue1003-check-empty-ld-flags.sh + rm test/issue103-single-file-package.sh + rm test/issue1040-run-with-ver.sh + rm test/issue1091-bogus-rebuild.sh + rm test/issue1180-local-cache-broken.sh + rm test/issue1194-warn-wrong-subconfig.sh + rm test/issue1277.sh + rm test/issue1372-ignore-files-in-hidden-dirs.sh + rm test/issue1447-build-settings-vars.sh + rm test/issue1531-toolchain-requirements.sh + rm test/issue1773-lint.sh + rm test/issue346-redundant-flags.sh + rm test/issue361-optional-deps.sh + rm test/issue564-invalid-upgrade-dependency.sh + rm test/issue586-subpack-dep.sh + rm test/issue616-describe-vs-generate-commands.sh + rm test/issue686-multiple-march.sh + rm test/issue813-fixed-dependency.sh + rm test/issue813-pure-sub-dependency.sh + rm test/issue820-extra-fields-after-convert.sh + rm test/issue877-auto-fetch-package-on-run.sh + rm test/issue923-subpackage-deps.sh + rm test/single-file-sdl-default-name.sh + rm test/subpackage-common-with-sourcefile-globbing.sh + rm test/issue934-path-dep.sh + rm test/version-spec.sh + rm -rf test/1-dynLib-simple + rm -rf test/1-exec-simple-package-json + rm -rf test/1-exec-simple + rm -rf test/1-staticLib-simple + rm -rf test/2-dynLib-dep + rm -rf test/2-staticLib-dep + rm -rf test/2-dynLib-with-staticLib-dep + rm -rf test/2-sourceLib-dep/ + rm -rf test/3-copyFiles + rm -rf test/custom-source-main-bug487 + rm -rf test/custom-unittest + rm -rf test/issue1262-version-inheritance-diamond + rm -rf test/git-dependency + rm -rf test/issue1003-check-empty-ld-flags + rm -rf test/ignore-hidden-1 + rm -rf test/ignore-hidden-2 + rm -rf test/issue1427-betterC + rm -rf test/issue130-unicode-* + rm -rf test/issue1262-version-inheritance + rm -rf test/issue1372-ignore-files-in-hidden-dirs + rm -rf test/issue1350-transitive-none-deps + rm -rf test/issue1775 + rm -rf test/issue1447-build-settings-vars + rm -rf test/issue1408-inherit-linker-files + rm -rf test/issue1551-var-escaping + rm -rf test/issue754-path-selection-fail + rm -rf test/issue1788-incomplete-string-import-override + rm -rf test/subpackage-ref + rm -rf test/issue777-bogus-path-dependency + rm -rf test/issue959-path-based-subpack-dep + rm -rf test/issue97-targettype-none-nodeps + rm -rf test/issue97-targettype-none-onerecipe + rm -rf test/path-subpackage-ref + rm -rf test/sdl-package-simple + ./test/run-unittest.sh + ''; + + installPhase = '' + mkdir -p $out/bin + cp bin/dub $out/bin + #cp $NIX_BUILD_TOP/dub $out/bin + ''; + + meta = with stdenv.lib; { + description = "Package and build manager for D applications and libraries"; + homepage = "https://code.dlang.org/"; + license = licenses.mit; + maintainers = with maintainers; [ ThomasMader ]; + platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ]; + }; +} +#+END_SRC -- cgit v1.2.3