From ca590402ad0d3aefd35d51bdfc016cac9453a47c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 9 Mar 2024 20:10:02 -0500 Subject: nix flake & env upkeep --- .envrc-nix | 11 +++-- derivation.nix | 4 +- devenv.nix | 4 +- flake.nix | 95 +++++++++++++++++++++++++++++++------------ org/config_env.org | 11 +++-- org/config_nix.org | 116 ++++++++++++++++++++++++++++++++++++----------------- shell.nix | 13 +++--- 7 files changed, 176 insertions(+), 78 deletions(-) diff --git a/.envrc-nix b/.envrc-nix index d4cc0e8..87adf1c 100644 --- a/.envrc-nix +++ b/.envrc-nix @@ -7,6 +7,7 @@ if ! has nix_direnv_version || ! nix_direnv_version ${NixDirEnvVersion}; then fi watch_file flake.lock watch_file flake.nix +watch_file shell.nix watch_file makefile watch_file nixDevEnv.sh watch_file .envrc-local @@ -14,7 +15,7 @@ watch_file .envrc-nix PATH_add result/bin use flake . #use flake .#default -echo " +echo ' - consider running: ❯❯ nix flake show ❯❯ nix flake update && nix flake check && nix flake show @@ -24,11 +25,15 @@ echo " ❯❯ nix develop ".#" --print-build-logs -c zsh - to build project: + ❯❯ nix build --print-build-logs + ❯❯ nix build ".#" --print-build-logs + ❯❯ nix build ".#spine-search-nixpkgs-dmd" --print-build-logs + ❯❯ nix build ".#spine-search-overlay-dmd" --print-build-logs ❯❯ nix build ".#spine-search-nixpkgs-ldc" --print-build-logs - ❯❯ nix build ".#spine-search-ovlerlay-ldc" --print-build-logs + ❯❯ nix build ".#spine-search-overlay-ldc" --print-build-logs - (see nix other/additional build options): ❯❯ nix flake show ❯❯ nix flake update && nix flake check --show-trace && nix flake show && nix develop ".#devShell" -c zsh ❯❯ dub build --compiler=ldmd --build=release --combined --skip-registry=all -" +' diff --git a/derivation.nix b/derivation.nix index c136ae1..5ca32a0 100644 --- a/derivation.nix +++ b/derivation.nix @@ -97,7 +97,7 @@ with ( buildInputs = [ pkgs.sqlite ( - with pkgs; [ + with pkgs-nix; [ nixVersions.unstable #nixFlakes ## package manager dub @@ -108,7 +108,7 @@ with ( ] ) ]; - meta = with pkgs.lib; { + meta = with pkgs-nix.lib; { pname = "spine-search"; version = "0.14.0"; homepage = "https://sisudoc.org"; diff --git a/devenv.nix b/devenv.nix index aea6cec..54de1c8 100644 --- a/devenv.nix +++ b/devenv.nix @@ -15,8 +15,8 @@ with pkgs; validatePkgConfig nix-output-monitor nix-tree - jq - alejandra + jq #gx + #alejandra git # ❯❯❯ dev gnumake diff --git a/flake.nix b/flake.nix index 3f7b609..968ad5f 100644 --- a/flake.nix +++ b/flake.nix @@ -52,7 +52,7 @@ in { packages = forAllSystems (system: let pkgs-ovl = pkgsForSystem system; - pkgs = nixpkgsFor.${system}; + pkgs-nix = nixpkgsFor.${system}; in with pkgs-ovl; { default = stdenv.mkDerivation { @@ -73,7 +73,10 @@ done if [ "$DC" == "" ]; then exit "Error: could not find D compiler"; fi echo "$DC_ used as D compiler to build $pname" - dub build --cache=local --compiler=$DC --build=$DC_ --combined --skip-registry=all + buildCMD="dub build --cache=local --compiler=$DC --build=$DC_ --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD runHook postBuild ''; inherit preBuild; @@ -81,7 +84,7 @@ inherit installPhase; inherit postInstall; }; - spine-search-ovlerlay-dmd = stdenv.mkDerivation { + spine-search-nixpkgs-dmd = stdenv.mkDerivation { inherit pname; inherit version; meta.mainProgram = "spine_search-dmd"; @@ -89,11 +92,14 @@ src = self; inherit shell; inherit devEnv; - buildInputs = [sqlite]; - nativeBuildInputs = [dub dmd gnumake]; + buildInputs = with pkgs-nix; [sqlite]; + nativeBuildInputs = with pkgs-nix; [dub dmd gnumake]; buildPhase = '' runHook preBuild - dub build --cache=local --compiler=$(type -P dmd) --build=dmd --combined --skip-registry=all + buildCMD="dub build --cache=local --compiler=$(type -P dmd) --build=dmd --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD runHook postBuild ''; inherit preBuild; @@ -101,7 +107,7 @@ inherit installPhase; inherit postInstall; }; - spine-search-ovlerlay-ldc = stdenv.mkDerivation { + spine-search-nixpkgs-ldc = stdenv.mkDerivation { inherit pname; inherit version; meta.mainProgram = "spine_search-ldc"; @@ -109,11 +115,37 @@ src = self; inherit shell; inherit devEnv; + buildInputs = with pkgs-nix; [sqlite]; + nativeBuildInputs = with pkgs-nix; [dub ldc gnumake]; + buildPhase = '' + runHook preBuild + buildCMD="dub build --cache=local --compiler=$(type -P ldc2) --build=ldc2 --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD + runHook postBuild + ''; + inherit preBuild; + inherit checkPhase; + inherit installPhase; + inherit postInstall; + }; + spine-search-overlay-dmd = stdenv.mkDerivation { + inherit pname; + inherit version; + meta.mainProgram = "spine_search-dmd"; + executable = true; + src = self; + inherit shell; + inherit devEnv; buildInputs = [sqlite]; - nativeBuildInputs = [dub ldc gnumake]; + nativeBuildInputs = [dub dmd gnumake]; buildPhase = '' runHook preBuild - dub build --cache=local --compiler=$(type -P ldc2) --build=ldc2 --combined --skip-registry=all + buildCMD="dub build --cache=local --compiler=$(type -P dmd) --build=dmd --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD runHook postBuild ''; inherit preBuild; @@ -121,7 +153,7 @@ inherit installPhase; inherit postInstall; }; - spine-search-nixpkgs-ldc = stdenv.mkDerivation { + spine-search-overlay-ldc = stdenv.mkDerivation { inherit pname; inherit version; meta.mainProgram = "spine_search-ldc"; @@ -129,11 +161,14 @@ src = self; inherit shell; inherit devEnv; - buildInputs = with pkgs; [sqlite]; - nativeBuildInputs = with pkgs; [dub ldc gnumake]; + buildInputs = [sqlite]; + nativeBuildInputs = [dub ldc gnumake]; buildPhase = '' runHook preBuild - dub build --cache=local --compiler=$(type -P ldc2) --build=ldc2 --combined --skip-registry=all + buildCMD="dub build --cache=local --compiler=$(type -P ldc2) --build=ldc2 --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD runHook postBuild ''; inherit preBuild; @@ -141,7 +176,7 @@ inherit installPhase; inherit postInstall; }; - #spine-search-ovl-gdc = stdenv.mkDerivation { + #spine-search-overlay-gdc = stdenv.mkDerivation { # inherit pname; # inherit version; # meta.mainProgram = "spine_search-gdc"; @@ -165,7 +200,7 @@ }); devShells = forAllSystems (system: let pkgs-ovl = pkgsForSystem system; - pkgs = nixpkgsFor.${system}; + pkgs-nix = nixpkgsFor.${system}; shellHook = '' export DFLAGS="-O2 -boundscheck=on" export Date=`date "+%Y%m%d"` @@ -177,25 +212,22 @@ name = "spine base dev shell"; inherit shell; inherit devEnv; - #nativeBuildInputs = [ ldc dub gnumake ]; - #buildInputs = [ sqlite ]; packages = [ - sqlite ldc #dmd dub gnumake + sqlite ]; inherit shellHook; }; dsh-d-overlay = d-overlay.devShells.${system}.default; - dsh-sqlite = mkShell { - name = "spine dev shell for latex & pdf output"; + dsh-overlay-dmd-dub = mkShell { + name = "spine base dev shell"; inherit shell; inherit devEnv; packages = [ - ldc - #dmd + dmd dub gnumake sqlite @@ -206,17 +238,28 @@ name = "nixpkgs - ldc - dub"; inherit shell; inherit devEnv; - #nativeBuildInputs = [ ldc dub gnumake ]; - #buildInputs = [ sqlite ]; - packages = with pkgs; [ + packages = with pkgs-nix; [ + ldc + dub + gnumake + sqlite + ]; + inherit shellHook; + }; + dsh-sqlite = mkShell { + name = "spine dev shell for latex & pdf output"; + inherit shell; + inherit devEnv; + packages = [ ldc + #dmd dub gnumake sqlite ]; inherit shellHook; }; - default = import ./shell.nix {inherit pkgs;}; + default = import ./shell.nix {inherit pkgs-nix;}; }); }; } diff --git a/org/config_env.org b/org/config_env.org index 229b404..23e2111 100644 --- a/org/config_env.org +++ b/org/config_env.org @@ -63,6 +63,7 @@ if ! has nix_direnv_version || ! nix_direnv_version ${NixDirEnvVersion}; then fi watch_file flake.lock watch_file flake.nix +watch_file shell.nix watch_file makefile watch_file nixDevEnv.sh watch_file .envrc-local @@ -70,7 +71,7 @@ watch_file .envrc-nix PATH_add result/bin use flake . #use flake .#default -echo " +echo ' - consider running: ❯❯ nix flake show ❯❯ nix flake update && nix flake check && nix flake show @@ -80,14 +81,18 @@ echo " ❯❯ nix develop ".#" --print-build-logs -c zsh - to build project: + ❯❯ nix build --print-build-logs + ❯❯ nix build ".#" --print-build-logs + ❯❯ nix build ".#spine-search-nixpkgs-dmd" --print-build-logs + ❯❯ nix build ".#spine-search-overlay-dmd" --print-build-logs ❯❯ nix build ".#spine-search-nixpkgs-ldc" --print-build-logs - ❯❯ nix build ".#spine-search-ovlerlay-ldc" --print-build-logs + ❯❯ nix build ".#spine-search-overlay-ldc" --print-build-logs - (see nix other/additional build options): ❯❯ nix flake show ❯❯ nix flake update && nix flake check --show-trace && nix flake show && nix develop ".#devShell" -c zsh ❯❯ dub build --compiler=ldmd --build=release --combined --skip-registry=all -" +' #+END_SRC *** 3.0.0 diff --git a/org/config_nix.org b/org/config_nix.org index 60232a6..45dcb2c 100644 --- a/org/config_nix.org +++ b/org/config_nix.org @@ -79,7 +79,7 @@ in { packages = forAllSystems (system: let pkgs-ovl = pkgsForSystem system; - pkgs = nixpkgsFor.${system}; + pkgs-nix = nixpkgsFor.${system}; in with pkgs-ovl; { default = stdenv.mkDerivation { @@ -100,7 +100,10 @@ done if [ "$DC" == "" ]; then exit "Error: could not find D compiler"; fi echo "$DC_ used as D compiler to build $pname" - dub build --cache=local --compiler=$DC --build=$DC_ --combined --skip-registry=all + buildCMD="dub build --cache=local --compiler=$DC --build=$DC_ --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD runHook postBuild ''; inherit preBuild; @@ -108,7 +111,7 @@ inherit installPhase; inherit postInstall; }; - spine-search-ovlerlay-dmd = stdenv.mkDerivation { + spine-search-nixpkgs-dmd = stdenv.mkDerivation { inherit pname; inherit version; meta.mainProgram = "spine_search-dmd"; @@ -116,11 +119,14 @@ src = self; inherit shell; inherit devEnv; - buildInputs = [sqlite]; - nativeBuildInputs = [dub dmd gnumake]; + buildInputs = with pkgs-nix; [sqlite]; + nativeBuildInputs = with pkgs-nix; [dub dmd gnumake]; buildPhase = '' runHook preBuild - dub build --cache=local --compiler=$(type -P dmd) --build=dmd --combined --skip-registry=all + buildCMD="dub build --cache=local --compiler=$(type -P dmd) --build=dmd --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD runHook postBuild ''; inherit preBuild; @@ -128,7 +134,7 @@ inherit installPhase; inherit postInstall; }; - spine-search-ovlerlay-ldc = stdenv.mkDerivation { + spine-search-nixpkgs-ldc = stdenv.mkDerivation { inherit pname; inherit version; meta.mainProgram = "spine_search-ldc"; @@ -136,11 +142,37 @@ src = self; inherit shell; inherit devEnv; + buildInputs = with pkgs-nix; [sqlite]; + nativeBuildInputs = with pkgs-nix; [dub ldc gnumake]; + buildPhase = '' + runHook preBuild + buildCMD="dub build --cache=local --compiler=$(type -P ldc2) --build=ldc2 --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD + runHook postBuild + ''; + inherit preBuild; + inherit checkPhase; + inherit installPhase; + inherit postInstall; + }; + spine-search-overlay-dmd = stdenv.mkDerivation { + inherit pname; + inherit version; + meta.mainProgram = "spine_search-dmd"; + executable = true; + src = self; + inherit shell; + inherit devEnv; buildInputs = [sqlite]; - nativeBuildInputs = [dub ldc gnumake]; + nativeBuildInputs = [dub dmd gnumake]; buildPhase = '' runHook preBuild - dub build --cache=local --compiler=$(type -P ldc2) --build=ldc2 --combined --skip-registry=all + buildCMD="dub build --cache=local --compiler=$(type -P dmd) --build=dmd --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD runHook postBuild ''; inherit preBuild; @@ -148,7 +180,7 @@ inherit installPhase; inherit postInstall; }; - spine-search-nixpkgs-ldc = stdenv.mkDerivation { + spine-search-overlay-ldc = stdenv.mkDerivation { inherit pname; inherit version; meta.mainProgram = "spine_search-ldc"; @@ -156,11 +188,14 @@ src = self; inherit shell; inherit devEnv; - buildInputs = with pkgs; [sqlite]; - nativeBuildInputs = with pkgs; [dub ldc gnumake]; + buildInputs = [sqlite]; + nativeBuildInputs = [dub ldc gnumake]; buildPhase = '' runHook preBuild - dub build --cache=local --compiler=$(type -P ldc2) --build=ldc2 --combined --skip-registry=all + buildCMD="dub build --cache=local --compiler=$(type -P ldc2) --build=ldc2 --combined --skip-registry=all" + echo $buildCMD + $buildCMD + echo $buildCMD runHook postBuild ''; inherit preBuild; @@ -168,7 +203,7 @@ inherit installPhase; inherit postInstall; }; - #spine-search-ovl-gdc = stdenv.mkDerivation { + #spine-search-overlay-gdc = stdenv.mkDerivation { # inherit pname; # inherit version; # meta.mainProgram = "spine_search-gdc"; @@ -192,7 +227,7 @@ }); devShells = forAllSystems (system: let pkgs-ovl = pkgsForSystem system; - pkgs = nixpkgsFor.${system}; + pkgs-nix = nixpkgsFor.${system}; shellHook = '' export DFLAGS="-O2 -boundscheck=on" export Date=`date "+%Y%m%d"` @@ -204,25 +239,22 @@ name = "spine base dev shell"; inherit shell; inherit devEnv; - #nativeBuildInputs = [ ldc dub gnumake ]; - #buildInputs = [ sqlite ]; packages = [ - sqlite ldc #dmd dub gnumake + sqlite ]; inherit shellHook; }; dsh-d-overlay = d-overlay.devShells.${system}.default; - dsh-sqlite = mkShell { - name = "spine dev shell for latex & pdf output"; + dsh-overlay-dmd-dub = mkShell { + name = "spine base dev shell"; inherit shell; inherit devEnv; packages = [ - ldc - #dmd + dmd dub gnumake sqlite @@ -233,17 +265,28 @@ name = "nixpkgs - ldc - dub"; inherit shell; inherit devEnv; - #nativeBuildInputs = [ ldc dub gnumake ]; - #buildInputs = [ sqlite ]; - packages = with pkgs; [ + packages = with pkgs-nix; [ + ldc + dub + gnumake + sqlite + ]; + inherit shellHook; + }; + dsh-sqlite = mkShell { + name = "spine dev shell for latex & pdf output"; + inherit shell; + inherit devEnv; + packages = [ ldc + #dmd dub gnumake sqlite ]; inherit shellHook; }; - default = import ./shell.nix {inherit pkgs;}; + default = import ./shell.nix {inherit pkgs-nix;}; }); }; } @@ -256,8 +299,8 @@ #+HEADER: :shebang "#!/usr/bin/env -S nix-shell --pure\n#!nix-shell -i bash" #+HEADER: :noweb yes #+BEGIN_SRC nix -{pkgs ? import {}}: -with pkgs; +{pkgs-nix ? import {}}: +with pkgs-nix; mkShell { buildInputs = [ # ❯❯❯ nix_related @@ -268,17 +311,18 @@ with pkgs; validatePkgConfig nix-output-monitor nix-tree - jq - alejandra + jq #gx + #alejandra git # ❯❯❯ dev gnumake ps # ❯❯❯ d_build_related # ❯❯ package manager - dub + #dub # ❯❯ compiler - ldc + #dmd + #ldc #rund # ❯❯ linker #lld @@ -337,8 +381,8 @@ with pkgs; validatePkgConfig nix-output-monitor nix-tree - jq - alejandra + jq #gx + #alejandra git # ❯❯❯ dev gnumake @@ -473,7 +517,7 @@ with ( buildInputs = [ pkgs.sqlite ( - with pkgs; [ + with pkgs-nix; [ nixVersions.unstable #nixFlakes ## package manager dub @@ -484,7 +528,7 @@ with ( ] ) ]; - meta = with pkgs.lib; { + meta = with pkgs-nix.lib; { pname = "spine-search"; version = "<>"; homepage = "https://sisudoc.org"; diff --git a/shell.nix b/shell.nix index 7aa977b..e44c85e 100755 --- a/shell.nix +++ b/shell.nix @@ -1,7 +1,7 @@ #!/usr/bin/env -S nix-shell --pure #!nix-shell -i bash -{pkgs ? import {}}: -with pkgs; +{pkgs-nix ? import {}}: +with pkgs-nix; mkShell { buildInputs = [ # ❯❯❯ nix_related @@ -12,17 +12,18 @@ with pkgs; validatePkgConfig nix-output-monitor nix-tree - jq - alejandra + jq #gx + #alejandra git # ❯❯❯ dev gnumake ps # ❯❯❯ d_build_related # ❯❯ package manager - dub + #dub # ❯❯ compiler - ldc + #dmd + #ldc #rund # ❯❯ linker #lld -- cgit v1.2.3