-*- mode: org -*-
#+TITLE:       D related overlays
#+DESCRIPTION: ldc, dub, dtools: dlang compiler build tool and tools
#+FILETAGS:    :dlang:build:tools:
#+AUTHOR:      Ralph Amissah
#+EMAIL:       [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]]
#+COPYRIGHT:   Copyright (C) 2022 - 2024 Ralph Amissah
#+LANGUAGE:    en
#+STARTUP:     content hideblocks hidestars noindent entitiespretty

* README for D related dev shells with overlays
** in emacs write (tangle) this (org) file for its output

This org file: "dlang-nix-flakes.org" when using emacs and saved (tangling output)
it creates and writes output to the subdirectory path:

  ..

and writes output there, this is to prevent accidentally writing over anything
in the directory in which the dlang-nix-flakes.org file happens to be saved.

.. becomes your nix flake work directory.

** dlang-nix-flakes.org

the file dlang-nix-flakes.org contains nix related files for producing more
recent versions of the dlang compiler and build tools: ldc, dub and dtools, than
exist in nixpkgs at the time of publishing, in some cases with additional fixes.

.envrc files

nix control files
  - default.nix
  - shell.nix
  - flake.nix

nix overlays for (updates nixpkgs, more recent versions of):
  - ldc     ( 1.30.0 -> 1.40.0 )
  - dub     ( 1.23.0 -> 1.38.1 ) [for nix versions 1.31.0 ... 1.33.0 broken]
  - dtools  ( 2.095.1 -> 2.103.1 )

  - dmd     ( 2.100.2 -> 2.110.0 )
  - gdc     [not yet available]

(updates nixpkgs circa 2023-05-12)

dlang-nix-flakes.org --❯
  .
  └── dlang-nix-flakes
      ├── #default.nix
      ├── flake.lock
      ├── flake.nix
      ├── README
      ├── shell.nix
      └── nix-overlays
          ├── dmd [not working]
          │   ├── binary.nix
          │   ├── bootstrap.nix
          │   ├── default.nix
          │   └── generic.nix
          ├── dtools
          │   └── default.nix
          ├── dub
          │   └── default.nix
          └── ldc
              ├── binary.nix
              ├── bootstrap.nix
              ├── default.nix
              └── generic.nix

search nixpkgs here:

- https://search.nixos.org/packages?channel=unstable&from=0&size=100&sort=relevance&query=

** compilers
*** ldc OK ✓ ( 1.30.0 -> 1.40.0 )

- https://wiki.dlang.org/LDC

- https://github.com/ldc-developers/ldc
  - https://github.com/ldc-developers/ldc/releases
    nix-prefetch-url --unpack https://github.com/ldc-developers/ldc/archive/refs/tags/v1.40.0.tar.gz
  - https://github.com/ldc-developers/ldc/issues

- version in nixpkgs:
  - https://search.nixos.org/packages?channel=unstable&show=ldc&from=0&size=100&sort=relevance&type=packages&query=ldc

*** dmd OK ✓ ( 2.100.2 -> 2.110.0 )

- https://dlang.org/
  - https://wiki.dlang.org/LDC

- https://github.com/dlang/dmd
  - https://github.com/dlang/dmd/tags
    nix-prefetch-url --unpack https://github.com/dlang/dmd/archive/refs/tags/v2.110.0.tar.gz
  - https://github.com/dlang/dmd/pulls

- version in nixpkgs:
  - https://search.nixos.org/packages?channel=unstable&show=dmd&from=0&size=100&sort=relevance&type=packages&query=dmd

- dmd nixpkg modified and appears to build ok, but it appears my overlay does
  not get things right REVIEW

- dmd on nixos FAILS to build (my working projects), appears not to find parts
  of itself

*** gdc ( not provided yet with gcc12 in nixpkgs )

not yet provided in nixpkgs with gcc12, no attempt made

- https://wiki.dlang.org/GDC
  - https://wiki.dlang.org/GDC_Development

- https://github.com/D-Programming-GDC/gdc

** build tool
*** dub ( 1.23.0 -> 1.38.1 )

- https://code.dlang.org/packages/dub

- https://github.com/dlang/dub
  - https://github.com/dlang/dub/releases
    nix-prefetch-url --unpack https://github.com/dlang/dub/archive/refs/tags/v1.38.1.tar.gz
  - https://github.com/dlang/dub/issues

- version in nixpkgs:
  - https://search.nixos.org/packages?channel=unstable&show=dub&from=0&size=100&sort=relevance&type=packages&query=dub

- dub nixpkg overlay is updated and runs most dub tests correctly

- dub OK ✓ ( 1.30.0 -> 1.38.1 )

  from v1.31.0 requires seeting of pwd in buildPhase else fails to build
  packages with nix tools that previous version of dub built;

** tools
*** dtools OK ✓ ( 2.095.1 -> 2.103.1 )

- https://code.dlang.org/packages/dtools

- https://github.com/dlang/tools
  - https://github.com/dlang/tools/tags
    nix-prefetch --unpack https://github.com/dlang/tools/archive/refs/tags/v2.103.1.tar.gz
  - https://github.com/dlang/tools/issues

- version in nixpkgs
  - https://search.nixos.org/packages?channel=unstable&show=dtools&from=0&size=100&sort=relevance&type=packages&query=dtools

** nixpkgs

It is possible to work directly against a local copy of nixpkgs. To do so you
would clone nixpkgs and point to the local nixpkgs as your build source.

git clone --depth=1 --branch master https://github.com/nixos/nixpkgs nixpkgs

- ./nixpkgs/pkgs/development/compilers/ldc
- ./nixpkgs/pkgs/development/compilers/dmd
- ./nixpkgs/pkgs/development/tools/build-managers/dub
- ./nixpkgs/pkgs/development/tools/dtools

- ./nixpkgs/pkgs/development/compilers/gcc

Note the overlays if copied to the nixpkgs path locations should work as they do
in the overlay, with a pointer to the cloned nixpkgs as nixpkgs repository
source. In fact the starting point for the overlays was to take verbatim what
was in nixpkgs and then to update and fix where necessary those packages.

It is possible to compare the changes made by the overlays here directly against
what is currently available in nixpkgs.

- https://search.nixos.org/packages?channel=unstable&size=100&sort=relevance&query=

nix flake update && nix flake check --show-trace && nix flake info && echo "" && nix flake show
  │
  ├───devShells
  │   └───x86_64-linux
  │       ├───default: development environment 'nix-shell'
  │       ├───dsh-nixpkgs-ldc-dub: development environment 'nixpkgs---ldc---dub'
  │       ├───dsh-overlay-dmd-dub: development environment 'overlay---dmd-2.104.0---dub-1.30.0---broken'
  │       ├───dsh-overlay-dtest-tilix: development environment 'overlay---ldc-1.32.2---dub-1.30.0---tilix---gtkd'
  │       ├───dsh-overlay-dtools: development environment 'overlay---ldc-1.32.2---dub-1.30.0---dtools-2.103.1'
  │       └───dsh-overlay-ldc-dub: development environment 'overlay---ldc-1.32.2---dub-1.30.0'
  └───packages
      └───x86_64-linux
          ├───check-local-dir-build: package 'dummy-0.1.0'
          ├───check-tilix: package 'tilix-1.9.5'
          └───default: package 'tilix-1.9.5'