diff options
Diffstat (limited to 'dlang/flake.nix')
| -rw-r--r-- | dlang/flake.nix | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/dlang/flake.nix b/dlang/flake.nix new file mode 100644 index 0000000..554b8e0 --- /dev/null +++ b/dlang/flake.nix @@ -0,0 +1,67 @@ +{ + description = "ssp-reader: a reader for the .ssp document abstraction, in D"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = { self, nixpkgs }: + let + system = "x86_64-linux"; # adjust for aarch64-linux / darwin + pkgs = import nixpkgs { inherit system; }; + + name = "ssp-reader"; + + /* The reader has no dependencies beyond phobos, so there is nothing + to vendor and nothing to fetch: --skip-registry=all keeps dub from + reaching for a registry it does not need, which is also what lets + this build in a sandbox without network. + */ + mkReader = { compiler, compilerBin }: pkgs.stdenv.mkDerivation { + pname = name; + version = "2.0.0"; + src = self; + nativeBuildInputs = [ pkgs.dub compiler ]; + buildPhase = '' + runHook preBuild + export HOME=$TMPDIR + dub build \ + --cache=local \ + --compiler=$(type -P ${compilerBin}) \ + --build=release \ + --skip-registry=all + runHook postBuild + ''; + installPhase = '' + runHook preInstall + mkdir -p $out/bin + install -m755 bin/${name} $out/bin/${name} + runHook postInstall + ''; + meta = { + description = "reads a .ssp document abstraction and says what is in it"; + mainProgram = name; + }; + }; + in { + packages.${system} = { + default = self.packages.${system}.ssp-reader-ldc; + + ssp-reader-ldc = mkReader { + compiler = pkgs.ldc; + compilerBin = "ldmd2"; + }; + + /* dmd is given gcc14: GCC 15 introduced nullptr in its headers and + dmd's ImportC parser does not yet handle it. The same override + sisudoc-spine carries, for the same reason. + */ + ssp-reader-dmd = mkReader { + compiler = pkgs.dmd.override { stdenv = pkgs.gcc14Stdenv; }; + compilerBin = "dmd"; + }; + }; + + devShells.${system}.default = pkgs.mkShell { + packages = [ pkgs.ldc pkgs.dub pkgs.dtools ]; + }; + }; +} |
