From d0465e3837a71afae2f1a6f42eb923350d826e27 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 27 Jan 2021 10:45:51 -0500 Subject: shell.nix project.nix spine.nix mkDub.nix --- org/spine_build_scaffold.org | 82 ++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 29 deletions(-) (limited to 'org') diff --git a/org/spine_build_scaffold.org b/org/spine_build_scaffold.org index ace6bc7..79ecff7 100644 --- a/org/spine_build_scaffold.org +++ b/org/spine_build_scaffold.org @@ -1757,17 +1757,17 @@ make modificatons if desired #+BEGIN_SRC nix :tangle ../.envrc if type lorri &>/dev/null; then - echo "direnv: using lorri from PATH ($(type -p lorri))" - eval "$(lorri direnv)" + 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 + # 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 + source .envrc-local fi #+END_SRC @@ -1842,8 +1842,8 @@ nix-instantiate --find-file nixpkgs /nixpkgs-ra/nixpkgs/.gitworktree/ra/nixpkgs ./shell.nix - shell.nix - ./shell-packages.nix - - shell-packages.nix + ./pkgs/shell-pkgs.nix + - pkgs/shell-pkgs.nix - default.nix ./nix/mkDub.nix - mkdub.nix @@ -1852,15 +1852,14 @@ nix-instantiate --find-file nixpkgs nix develop +nix flake update --recreate-lock-file + #+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; @@ -1882,13 +1881,21 @@ nix develop flake = false; }; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.simpleFlake { - #flake-utils.lib.spine { - inherit self nixpkgs; + outputs = { self, d2sqlite3, tinyendian, dyaml, imageformats, dub2nix-src, nixpkgs, flake-utils }: + let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + in { + packages.x86_64-linux.spine = pkgs.stdenv.mkDerivation { name = "spine"; - #shell = ./shell.nix; + inherit self; + src = self; + shell = ./shell.nix; + installPhase = '' + install -m755 spine $out/bin/spine + ''; }; + defaultPackage.x86_64-linux = self.packages.x86_64-linux.spine; + }; } #+END_SRC @@ -1950,11 +1957,12 @@ nix develop { pkgs ? import {} }: pkgs.mkShell { buildInputs = with pkgs; [ - (import ./nix/shell-packages.nix { inherit pkgs; }) + (import ./nix/pkglst/shell-pkgs.nix { inherit pkgs; }) ]; shellHook = '' nix-build echo "built spine @ ./result/bin/spine" + nix-instantiate | nix show-derivation | jq ''; } #+END_SRC @@ -1972,7 +1980,7 @@ mkDubDerivation rec { version = "0.11.1"; src = ./.; buildInputs = with pkgs; [( - import ./nix/shell-packages.nix + import ./nix/pkglst/shell-pkgs.nix { inherit pkgs; } )]; meta = with stdenv.lib; { @@ -2059,7 +2067,7 @@ mkDubDerivation rec { src = ./.; buildInputs = [ pkgs.sqlite - (import ./nix/shell-packages.nix { inherit pkgs; }) + (import ./nix/pkglst/shell-pkgs.nix { inherit pkgs; }) ]; # installPhase = '' # install -m755 -D spine $out/bin/spine @@ -2104,9 +2112,11 @@ mkDubDerivation rec { #+BEGIN_SRC nix :tangle ../spine.nix :tangle-mode (identity #o755) :shebang "#!/usr/bin/env -S nix-build" { pkgs ? import {}, stdenv ? pkgs.stdenv, - ldc ? pkgs.ldc, + ldc ? null, + dcompiler ? pkgs.ldc, dub ? pkgs.dub }: +assert dcompiler != null; #with import ./nix/mkDub.nix { inherit pkgs; }; with ( # mkDub.nix <> @@ -2168,7 +2178,7 @@ aria2c https://raw.githubusercontent.com/lionello/dub2nix/master/mkDub.nix ./nix *** dub2nix -#+BEGIN_SRC nix :tangle ../nix/shell-packages.nix +#+BEGIN_SRC nix :tangle ../nix/pkglst/shell-pkgs.nix { pkgs ? import {} }: <> #+END_SRC @@ -2178,7 +2188,8 @@ aria2c https://raw.githubusercontent.com/lionello/dub2nix/master/mkDub.nix ./nix #+BEGIN_SRC nix :tangle ../nix/mkDub.nix { pkgs ? import {}, stdenv ? pkgs.stdenv, - ldc ? pkgs.ldc, + ldc ? null, + dcompiler ? pkgs.ldc, dub ? pkgs.dub }: <> @@ -2188,6 +2199,7 @@ aria2c https://raw.githubusercontent.com/lionello/dub2nix/master/mkDub.nix ./nix #+NAME: mkDub_nix #+BEGIN_SRC nix +assert dcompiler != null; with stdenv; let # Filter function to remove the .dub package folder from src @@ -2201,7 +2213,7 @@ let fromDub = dubDep: mkDerivation rec { name = "${src.name}-${version}"; version = rev-to-version dubDep.fetch.rev; - nativeBuildInputs = [ ldc dub ]; + nativeBuildInputs = [ dcompiler dub ]; src = dep2src dubDep; buildPhase = '' runHook preBuild @@ -2222,7 +2234,7 @@ let # 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: [ ldc dub ] ++ builtins.map dep2src deps; + disallowedReferences = deps: [ dcompiler dub ] ++ builtins.map dep2src deps; removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}''; in { inherit fromDub; @@ -2237,10 +2249,10 @@ in { ... } @ attrs: stdenv.mkDerivation (attrs // { pname = package.name; - nativeBuildInputs = [ ldc dub pkgs.removeReferencesTo ] ++ nativeBuildInputs; + nativeBuildInputs = [ dcompiler dub pkgs.removeReferencesTo ] ++ nativeBuildInputs; disallowedReferences = disallowedReferences deps; passthru = passthru // { - inherit dub ldc pkgs; + inherit dub dcompiler pkgs; }; src = lib.cleanSourceWith { filter = filterDub; @@ -2253,7 +2265,18 @@ in { runHook preBuild export HOME=$PWD ${lib.concatMapStringsSep "\n" dub-add-local deps} - dub build --compiler=ldc2 --build=release --combined --skip-registry=all + 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 $pname" + dub build --compiler=$dc --build=release --combined --skip-registry=all runHook postBuild ''; checkPhase = '' @@ -2312,6 +2335,7 @@ ldc sqlite nix-prefetch-git validatePkgConfig +jq #+END_SRC * .gitignore :gitignore: @@ -2766,7 +2790,7 @@ stdenv.mkDerivation rec { if [ "$dc" == "" ]; then exit "Error: could not find D compiler" fi - echo "$dc_ used as D compiler to build dub" + echo "$dc_ used as D compiler to build $pname" $dc ./build.d ./build ''; -- cgit v1.2.3