From 124782c1745c4dbfd3dc84f5e50e0214899e39f7 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 26 Sep 2020 14:44:34 -0400 Subject: nixify step --- .envrc | 2 + .gitignore | 16 +-- dub.json | 51 +++++++++ dub.sdl | 87 --------------- nixDevEnv/overlays/dmdVersion.nix | 17 +++ nixDevEnv/overlays/ldcVersion.nix | 16 +++ nixDevEnv/shells/dmd.nix | 10 ++ nixDevEnv/shells/ldc.nix | 10 ++ org/spine_build_scaffold.org | 222 +++++++++++++++++++++++++++++++++----- shell.nix | 32 +++--- 10 files changed, 322 insertions(+), 141 deletions(-) create mode 100644 .envrc create mode 100644 dub.json delete mode 100755 dub.sdl create mode 100644 nixDevEnv/overlays/dmdVersion.nix create mode 100644 nixDevEnv/overlays/ldcVersion.nix create mode 100644 nixDevEnv/shells/dmd.nix create mode 100644 nixDevEnv/shells/ldc.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..bbd4e2b --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +use nix +NIX_ENFORCE_PURITY=0 diff --git a/.gitignore b/.gitignore index 734dcaf..510501a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ # git ls-files --others --exclude-from=.git/info/exclude -#./.dub/** * !.gitignore !README.md @@ -15,7 +14,6 @@ !*.d !*.rb !conf.sdl -!shell.nix !doc !doc/** !man @@ -23,12 +21,10 @@ !org !misc !misc/** -#!*.nix -#!nix -#!nix/** -#!nix-devEnv -#!nix-devEnv/** -#!.envrc +!*.nix +!nixDevEnv +!nixDevEnv/** +!.envrc !src !src/** !data @@ -67,12 +63,10 @@ tmp/** *_ *.swp *~ +*~ \#* *.\#* #!*/ -#*~ #\#* #*.\#* -#!debian -#!debian/** #.reggae/** diff --git a/dub.json b/dub.json new file mode 100644 index 0000000..0a2707f --- /dev/null +++ b/dub.json @@ -0,0 +1,51 @@ +{ + "authors": [ + "Ralph Amissah" + ], + "copyright": "Copyright © 2015 - 2020 Ralph Amissah", + "name": "spine", + "description": "a sisu like document parser", + "homepage": "http://sisudoc.org", + "license": "AGPL-3.0+", + "targetPath": "./bin", + "sourcePaths": [ "./src/doc_reform" ], + "stringImportPaths": [ "./views" ], + "buildRequirements": [ "allowWarnings" ], + "targetType": "executable", + "platforms": [ "posix" ], + "dependencies": { + "d2sqlite3": "~>0.19.1", + "imageformats": "~>7.0.2", + "dyaml": "~>0.8.0", + "tinyendian": "~>0.2.0" + }, + "subConfigurations": { + "d2sqlite3": "all-included" + }, + "configurations": [ + { + "name": "default", + "targetName": "spine" + }, + { + "name": "ldc", + "targetName": "spine-ldc" + }, + { + "name": "dmd", + "targetName": "spine-dmd" + } + ], + "buildTypes": { + "dmd": { + "dflags": [ "-J=views", "-I=src/doc_reform" ], + "buildOptions": [ "verbose", "inline" ], + "buildRequirements": [ "allowWarnings" ] + }, + "ldc": { + "dflags": [ "-O2", "-J=views", "-I=src/doc_reform" ], + "buildOptions": [ "verbose", "optimize", "inline" ], + "buildRequirements": [ "allowWarnings" ] + } + } +} diff --git a/dub.sdl b/dub.sdl deleted file mode 100755 index 3fc29da..0000000 --- a/dub.sdl +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env dub -name "spine" -description "sisu document parser" -homepage "http://sisudoc.org" -authors "Ralph Amissah" -copyright "Copyright (C) 2016 - 2020 Ralph Amissah" -license "AGPL-3.0+" -targetPath "./bin" -#sourcePath "./src/doc_reform" -stringImportPaths "./views" -buildRequirements "allowWarnings" -targetType "executable" -platforms "posix" -dependency "d2sqlite3" version="~>0.18.3" # https://code.dlang.org/packages/d2sqlite3 http://biozic.github.io/d2sqlite3/d2sqlite3 - subconfiguration "d2sqlite3" "all-included" -dependency "imageformats" version="~>7.0.2" # https://code.dlang.org/packages/imageformats https://github.com/lgvz/imageformats -dependency "dyaml" version="~>0.8.0" # https://code.dlang.org/packages/dyaml https://github.com/dlang-community/D-YAML -dependency "tinyendian" version="~>0.2.0" # http://code.dlang.org/packages/tinyendian https://github.com/dlang-community/tinyendian // dyaml dependency -configuration "default" { - targetName "spine" - #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine'" -} -configuration "dmd" { - targetName "spine-dmd" - #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine-dmd'" -} -buildType "dmd" { - dflags "-J=views" "-I=src/doc_reform" - buildOptions "verbose" "inline" - buildRequirements "allowWarnings" -} -buildType "dmd-release" { - dflags "-J=views" "-I=src/doc_reform" - buildOptions "verbose" "releaseMode" "optimize" "inline" -} -configuration "dmd-version" { - dflags "-J=views" "-I=src/doc_reform" - buildOptions "verbose" "optimize" - targetName "spine-dmd-ver" - #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine-dmd-ver'" -} -configuration "ldc" { - targetName "spine-ldc" - #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine-ldc'" -} -buildType "ldc" { - dflags "-O2" "-J=views" "-I=src/doc_reform" - buildOptions "verbose" "optimize" "inline" - buildRequirements "allowWarnings" -} -buildType "ldc-local" { - dflags "-O2" "-J=views" "-I=src/doc_reform" "-mcpu=native" - buildOptions "verbose" "optimize" "inline" - buildRequirements "allowWarnings" -} -buildType "ldc-release" { - dflags "-O2" "-J=views" "-I=src/doc_reform" - buildOptions "verbose" "optimize" "inline" "releaseMode" -} -configuration "ldc-version" { - dflags "-O2" "-J=views" "-I=src/doc_reform" - buildOptions "verbose" "optimize" "inline" "releaseMode" - targetName "spine-ldc-ver" - #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine-ldc-ver'" -} -configuration "gdc" { - targetName "spine-gdc" - #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine-gdc'" -} -buildType "gdc" { - dflags "-O" "-J=views" "-I=src/doc_reform" - lflags "-lz" - buildOptions "inline" - buildRequirements "allowWarnings" -} -buildType "gdc-release" { - dflags "-O2" "-J=views" "-I=src/doc_reform" - lflags "-lz" - buildOptions "verbose" "optimize" "inline" "releaseMode" -} -configuration "gdc-version" { - dflags "-O2" "-J=views" "-I=src/doc_reform" - lflags "-lz" - buildOptions "verbose" "optimize" "inline" "releaseMode" - targetName "spine-gdc-ver" - #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine-gdc-ver'" -} diff --git a/nixDevEnv/overlays/dmdVersion.nix b/nixDevEnv/overlays/dmdVersion.nix new file mode 100644 index 0000000..51e1f67 --- /dev/null +++ b/nixDevEnv/overlays/dmdVersion.nix @@ -0,0 +1,17 @@ +self: super: rec { + version = "2.094.0"; + sha256 = "0xhm8m46ahfx3hcibi3vws02zaplny3226f3x8cd8584gzfqyzxp"; + year = "2020"; + dmd = super.dmd.overrideAttrs(oldAttrs: rec { + inherit year version sha256; + pname = oldAttrs.pname; + name = "${pname}-${version}"; + src = super.fetchurl { + url = "http://downloads.dlang.org/releases/${year}/dmd.${version}.linux.tar.xz"; + sha256 = sha256; + }; + # postUnpack = '' + # patchShebangs . + # ''; + }); +} diff --git a/nixDevEnv/overlays/ldcVersion.nix b/nixDevEnv/overlays/ldcVersion.nix new file mode 100644 index 0000000..c241a1f --- /dev/null +++ b/nixDevEnv/overlays/ldcVersion.nix @@ -0,0 +1,16 @@ +self: super: rec { + version = "1.23.0"; + sha256 = "1fdgj222x29as466vdxy9c0m82zzlsb7vnvvh89n2riszcrx463d"; + ldc = super.ldc.overrideAttrs(oldAttrs: rec { + inherit version sha256; + pname = oldAttrs.pname; + 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 . + ''; + }); +} diff --git a/nixDevEnv/shells/dmd.nix b/nixDevEnv/shells/dmd.nix new file mode 100644 index 0000000..f3d126c --- /dev/null +++ b/nixDevEnv/shells/dmd.nix @@ -0,0 +1,10 @@ +{ pkgs ? import { overlays = [ (import ../overlays/dmdVersion.nix) ]; } }: + pkgs.mkShell { + buildInputs = with pkgs; [ + dub + ninja + dmd + sqlite + validatePkgConfig + ]; +} diff --git a/nixDevEnv/shells/ldc.nix b/nixDevEnv/shells/ldc.nix new file mode 100644 index 0000000..1900112 --- /dev/null +++ b/nixDevEnv/shells/ldc.nix @@ -0,0 +1,10 @@ +{ pkgs ? import { overlays = [ (import ../overlays/ldcVersion.nix) ]; } }: + pkgs.mkShell { + buildInputs = with pkgs; [ + dub + ninja + ldc + sqlite + validatePkgConfig + ]; +} diff --git a/org/spine_build_scaffold.org b/org/spine_build_scaffold.org index f998647..6a00b30 100644 --- a/org/spine_build_scaffold.org +++ b/org/spine_build_scaffold.org @@ -962,11 +962,67 @@ gitsnapshot: distclean tangle tangle gitsnapshot #+END_SRC +* dub.json TODO (subproject versions) :dub:json:config: + +#+BEGIN_SRC sh :tangle ../dub.json +{ + "authors": [ + "Ralph Amissah" + ], + "copyright": "Copyright © 2015 - 2020 Ralph Amissah", + "name": "spine", + "description": "a sisu like document parser", + "homepage": "http://sisudoc.org", + "license": "AGPL-3.0+", + "targetPath": "./bin", + "sourcePaths": [ "./src/doc_reform" ], + "stringImportPaths": [ "./views" ], + "buildRequirements": [ "allowWarnings" ], + "targetType": "executable", + "platforms": [ "posix" ], + "dependencies": { + "d2sqlite3": "~>0.19.1", + "imageformats": "~>7.0.2", + "dyaml": "~>0.8.0", + "tinyendian": "~>0.2.0" + }, + "subConfigurations": { + "d2sqlite3": "all-included" + }, + "configurations": [ + { + "name": "default", + "targetName": "spine" + }, + { + "name": "ldc", + "targetName": "spine-ldc" + }, + { + "name": "dmd", + "targetName": "spine-dmd" + } + ], + "buildTypes": { + "dmd": { + "dflags": [ "-J=views", "-I=src/doc_reform" ], + "buildOptions": [ "verbose", "inline" ], + "buildRequirements": [ "allowWarnings" ] + }, + "ldc": { + "dflags": [ "-O2", "-J=views", "-I=src/doc_reform" ], + "buildOptions": [ "verbose", "optimize", "inline" ], + "buildRequirements": [ "allowWarnings" ] + } + } +} +#+END_SRC + * dub.sdl :dub:sdl:config: 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]]) ** header (including dependencies) :header: -#+BEGIN_SRC sh :tangle ../dub.sdl :tangle-mode (identity #o755) :shebang #!/usr/bin/env dub +#+BEGIN_SRC sh :NO-tangle ../dub.sdl :tangle-mode (identity #o755) :shebang #!/usr/bin/env dub name "spine" description "sisu document parser" homepage "http://sisudoc.org" @@ -992,7 +1048,7 @@ time (dub --compiler=dmd --build=release) time (dub --compiler=ldc2 --build=release) time (dub --compiler=gdc --build=release) -#+BEGIN_SRC sh :tangle ../dub.sdl +#+BEGIN_SRC sh :NO-tangle ../dub.sdl configuration "default" { targetName "spine" #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine'" @@ -1001,10 +1057,10 @@ configuration "default" { ** dmd -time (dub --compiler=dmd --config=dmd --build=dmd) -time (dub --compiler=dmd --config=dmd --build=dmd-release) +time (dub --compiler=dmd -color --config=dmd --build=dmd) +time (dub --compiler=dmd -color --config=dmd --build=dmd-release) -#+BEGIN_SRC sh :tangle ../dub.sdl +#+BEGIN_SRC sh :NO-tangle ../dub.sdl configuration "dmd" { targetName "spine-dmd" #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine-dmd'" @@ -1032,10 +1088,10 @@ configuration "dmd-version" { ** ldc -time (dub --compiler=ldc2 --config=ldc --build=ldc) -time (dub --compiler=ldc2 --config=ldc --build=ldc-release) +time (dub --compiler=ldc2 -color --config=ldc --build=ldc) +time (dub --compiler=ldc2 -color --config=ldc --build=ldc-release) -#+BEGIN_SRC sh :tangle ../dub.sdl +#+BEGIN_SRC sh :NO-tangle ../dub.sdl configuration "ldc" { targetName "spine-ldc" #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine-ldc'" @@ -1067,7 +1123,7 @@ configuration "ldc-version" { time (dub --compiler=gdc --config=gdc --build=gdc) time (dub --compiler=gdc --config=gdc --build=gdc-release) -#+BEGIN_SRC sh :tangle ../dub.sdl +#+BEGIN_SRC sh :NO-tangle ../dub.sdl configuration "gdc" { targetName "spine-gdc" #postGenerateCommands "notify-send -t 0 'D executable ready' 'spine-gdc'" @@ -1507,8 +1563,69 @@ tinyendian_dep = declare_dependency( #+END_SRC * nix +** envrc + +#+BEGIN_SRC nix :tangle ../.envrc +use nix +NIX_ENFORCE_PURITY=0 +#+END_SRC + +** shells +*** nix-shell shell.nix #+BEGIN_SRC nix :tangle ../shell.nix +{ pkgs ? import { + overlays = [ + (import ./nixDevEnv/overlays/ldcVersion.nix) + (import ./nixDevEnv/overlays/dmdVersion.nix) + ]; } +}: + pkgs.mkShell { + buildInputs = with pkgs; [ + dub + ninja + #meson + dmd + ldc + sqlite + validatePkgConfig + ]; +} +#+END_SRC + +*** ldc shell + +#+BEGIN_SRC nix :tangle ../nixDevEnv/shells/ldc.nix +{ pkgs ? import { overlays = [ (import ../overlays/ldcVersion.nix) ]; } }: + pkgs.mkShell { + buildInputs = with pkgs; [ + dub + ninja + ldc + sqlite + validatePkgConfig + ]; +} +#+END_SRC + +*** dmd shell + +#+BEGIN_SRC nix :tangle ../nixDevEnv/shells/dmd.nix +{ pkgs ? import { overlays = [ (import ../overlays/dmdVersion.nix) ]; } }: + pkgs.mkShell { + buildInputs = with pkgs; [ + dub + ninja + dmd + sqlite + validatePkgConfig + ]; +} +#+END_SRC + +**** OLD nix-shell shell.nix + +#+BEGIN_SRC nix :NO-tangle ../shell.nix { pkgs ? import {} }: with pkgs; @@ -1521,6 +1638,7 @@ mkShell { sqlite validatePkgConfig #gnumake gcc gdc cmake + #clang #dzen2 ]; shellHook = '' @@ -1530,19 +1648,76 @@ mkShell { } #+END_SRC -#% ldc -dub --compiler=ldc2 -color --config=ldc --build=release -make ldc +** overlays +*** ldcVersion.nix overlay + +#+BEGIN_SRC nix :tangle ../nixDevEnv/overlays/ldcVersion.nix +self: super: rec { + <> + ldc = super.ldc.overrideAttrs(oldAttrs: rec { + inherit version sha256; + pname = oldAttrs.pname; + 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 + +#+BEGIN_SRC nix :tangle ../nixDevEnv/overlays/dmdVersion.nix +self: super: rec { + <> + dmd = super.dmd.overrideAttrs(oldAttrs: rec { + inherit year version sha256; + pname = oldAttrs.pname; + 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 TODO +https://dlang.org/download.html -#% dmd -dub --compiler=dmd -color --config=dmd --build=release -make dmd +*** ldc TODO +https://github.com/ldc-developers/ldc/releases + +#+NAME: ldc_version_info +#+BEGIN_SRC nix +version = "1.23.0"; +sha256 = "1fdgj222x29as466vdxy9c0m82zzlsb7vnvvh89n2riszcrx463d"; +#+END_SRC + +*** dmd TODO +https://dlang.org/changelog/index.html +https://dlang.org/changelog/pending.html +http://downloads.dlang.org/releases/ +http://downloads.dlang.org/releases/2.x/ + +#+NAME: dmd_version_info +#+BEGIN_SRC nix +version = "2.094.0"; +sha256 = "0xhm8m46ahfx3hcibi3vws02zaplny3226f3x8cd8584gzfqyzxp"; +year = "2020"; +#+END_SRC * .gitignore :gitignore: #+BEGIN_SRC sh :tangle ../.gitignore # git ls-files --others --exclude-from=.git/info/exclude -#./.dub/** * !.gitignore !README.md @@ -1558,7 +1733,6 @@ make dmd !*.d !*.rb !conf.sdl -!shell.nix !doc !doc/** !man @@ -1566,12 +1740,10 @@ make dmd !org !misc !misc/** -#!*.nix -#!nix -#!nix/** -#!nix-devEnv -#!nix-devEnv/** -#!.envrc +!*.nix +!nixDevEnv +!nixDevEnv/** +!.envrc !src !src/** !data @@ -1610,14 +1782,12 @@ tmp/** *_ *.swp *~ +*~ \#* *.\#* #!*/ -#*~ #\#* #*.\#* -#!debian -#!debian/** #.reggae/** #+END_SRC diff --git a/shell.nix b/shell.nix index 5b97ffe..b226cd3 100644 --- a/shell.nix +++ b/shell.nix @@ -1,19 +1,17 @@ -{ pkgs ? import {} }: - -with pkgs; - -mkShell { - buildInputs = with pkgs; [ - ninja dub - meson git - ldc #ldc dmd gdc - sqlite - validatePkgConfig - #gnumake gcc gdc cmake - #dzen2 +{ pkgs ? import { + overlays = [ + (import ./nixDevEnv/overlays/ldcVersion.nix) + (import ./nixDevEnv/overlays/dmdVersion.nix) + ]; } +}: + pkgs.mkShell { + buildInputs = with pkgs; [ + dub + ninja + #meson + dmd + ldc + sqlite + validatePkgConfig ]; - shellHook = '' - echo `ldc2 --version` - ''; - COMPILER = "ldc2"; } -- cgit v1.2.3