From 0810c406b71157c6a72737585a11b10b3de8bb18 Mon Sep 17 00:00:00 2001 From: justinwoo Date: Wed, 20 Mar 2019 00:16:40 +0200 Subject: [PATCH 1/6] purescript: fix purescript derivation using easy-purescript-nix For the past couple of years, there has continued to be problems with having the PureScript compiler on nixpkgs building from Haskell packages it is not built against in its actual development and release. We have seen this issue come up multiple times here on nixpkgs, but this also causes numerous issues to be filed against the PureScript compiler repository. One example of an exchange that has occurred multiple times in the past: https://github.com/NixOS/nixpkgs/issues/53597 https://github.com/purescript/purescript/issues/3571. As noted, the PureScript compiler is not on Stackage because it is not meant to be used as a library, and it does not update itself to the latest LTS and cut releases to match LTS releases. Instead, I have begun maintaining my own derivation for the PureScript compiler (among other tools) in a small project here: https://github.com/justinwoo/easy-purescript-nix. Within are other reference and derivations for other tools commonly used in the PureScript ecosystem, updated to their respective newest releases. These derivations use the same releases that other Linux and OSX users use, along with the standard application of patchELF to provide for runtime dependencies such as zlib, gmp, and ncurses5. These derivations are now used by a variety of NixOS, non-NixOS Linux, and OSX users. This commit then consumes the easy-purescript-nix derivation for the PureScript compiler and provides it in all-packages for consumption. --- .../compilers/purescript/purescript/default.nix | 11 +++++++++++ pkgs/top-level/all-packages.nix | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/compilers/purescript/purescript/default.nix diff --git a/pkgs/development/compilers/purescript/purescript/default.nix b/pkgs/development/compilers/purescript/purescript/default.nix new file mode 100644 index 00000000000..2b6518eef91 --- /dev/null +++ b/pkgs/development/compilers/purescript/purescript/default.nix @@ -0,0 +1,11 @@ +{ fetchFromGitHub }: + +let + easyPS = import (fetchFromGitHub { + owner = "justinwoo"; + repo = "easy-purescript-nix"; + rev = "d383972c82620a712ead4033db14110497bc2c9c"; + sha256 = "0hj85y3k0awd21j5s82hkskzp4nlzhi0qs4npnv172kaac03x8ms"; + }); + +in easyPS.purs diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 90daabcf890..5fa67857d06 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7137,8 +7137,8 @@ in all-cabal-hashes = callPackage ../data/misc/hackage { }; - # Build with ghc 8.4 due to https://github.com/NixOS/nixpkgs/issues/53597 - purescript = haskell.lib.justStaticExecutables haskell.packages.ghc844.purescript; + purescript = callPackage ../development/compilers/purescript/purescript {}; + psc-package = haskell.lib.justStaticExecutables (haskellPackages.callPackage ../development/compilers/purescript/psc-package { }); From ee1e16453ffcd4eb87090868eaa42d5458b59b15 Mon Sep 17 00:00:00 2001 From: justinwoo Date: Wed, 20 Mar 2019 10:20:05 +0200 Subject: [PATCH 2/6] purescript: inline referenced derivation --- .../purescript/purescript/default.nix | 58 ++++++++++++++++--- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/pkgs/development/compilers/purescript/purescript/default.nix b/pkgs/development/compilers/purescript/purescript/default.nix index 2b6518eef91..fd20e17ca1d 100644 --- a/pkgs/development/compilers/purescript/purescript/default.nix +++ b/pkgs/development/compilers/purescript/purescript/default.nix @@ -1,11 +1,53 @@ -{ fetchFromGitHub }: +{ pkgs ? import {} }: + +# from justinwoo/easy-purescript-nix +# https://github.com/justinwoo/easy-purescript-nix/blob/d383972c82620a712ead4033db14110497bc2c9c/purs.nix let - easyPS = import (fetchFromGitHub { - owner = "justinwoo"; - repo = "easy-purescript-nix"; - rev = "d383972c82620a712ead4033db14110497bc2c9c"; - sha256 = "0hj85y3k0awd21j5s82hkskzp4nlzhi0qs4npnv172kaac03x8ms"; - }); + dynamic-linker = pkgs.stdenv.cc.bintools.dynamicLinker; -in easyPS.purs + patchelf = libPath : + if pkgs.stdenv.isDarwin + then "" + else + '' + chmod u+w $PURS + patchelf --interpreter ${dynamic-linker} --set-rpath ${libPath} $PURS + chmod u-w $PURS + ''; + +in pkgs.stdenv.mkDerivation rec { + name = "purs-simple"; + version = "v0.12.3"; + + src = + if pkgs.stdenv.isDarwin + then + pkgs.fetchurl { + url = "https://github.com/purescript/purescript/releases/download/v0.12.3/macos.tar.gz"; + sha256 = "1f916gv4fz571l4jvr15xjnsvjyy4nljv2ii9njwlm7k6yr5m0qn"; + } + else + pkgs.fetchurl { + url = "https://github.com/purescript/purescript/releases/download/v0.12.3/linux64.tar.gz"; + sha256 = "1fad862a2sv4njxbbcfzibbi585m6is3ywb94nmjl8ax254baj3i"; + }; + + + buildInputs = [ pkgs.zlib + pkgs.gmp + pkgs.ncurses5]; + libPath = pkgs.lib.makeLibraryPath buildInputs; + dontStrip = true; + + installPhase = '' + mkdir -p $out/bin + PURS="$out/bin/purs" + + install -D -m555 -T purs $PURS + ${patchelf libPath} + + mkdir -p $out/etc/bash_completion.d/ + $PURS --bash-completion-script $PURS > $out/etc/bash_completion.d/purs-completion.bash + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5fa67857d06..e5cab6e7917 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7137,7 +7137,7 @@ in all-cabal-hashes = callPackage ../data/misc/hackage { }; - purescript = callPackage ../development/compilers/purescript/purescript {}; + purescript = callPackage ../development/compilers/purescript/purescript { inherit pkgs; }; psc-package = haskell.lib.justStaticExecutables (haskellPackages.callPackage ../development/compilers/purescript/psc-package { }); From fb39447028a03ed2aa22d3079967405050a3711f Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 20 Mar 2019 15:50:16 +0200 Subject: [PATCH 3/6] purescript: inline properties used from pkgs Co-Authored-By: justinwoo --- .../purescript/purescript/default.nix | 22 +++++++++---------- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkgs/development/compilers/purescript/purescript/default.nix b/pkgs/development/compilers/purescript/purescript/default.nix index fd20e17ca1d..219c111b080 100644 --- a/pkgs/development/compilers/purescript/purescript/default.nix +++ b/pkgs/development/compilers/purescript/purescript/default.nix @@ -1,13 +1,13 @@ -{ pkgs ? import {} }: +{ stdenv, fetchurl, zlib, gmp, ncurses5 }: # from justinwoo/easy-purescript-nix # https://github.com/justinwoo/easy-purescript-nix/blob/d383972c82620a712ead4033db14110497bc2c9c/purs.nix let - dynamic-linker = pkgs.stdenv.cc.bintools.dynamicLinker; + dynamic-linker = stdenv.cc.bintools.dynamicLinker; patchelf = libPath : - if pkgs.stdenv.isDarwin + if stdenv.isDarwin then "" else '' @@ -16,28 +16,28 @@ let chmod u-w $PURS ''; -in pkgs.stdenv.mkDerivation rec { +in stdenv.mkDerivation rec { name = "purs-simple"; version = "v0.12.3"; src = - if pkgs.stdenv.isDarwin + if stdenv.isDarwin then - pkgs.fetchurl { + fetchurl { url = "https://github.com/purescript/purescript/releases/download/v0.12.3/macos.tar.gz"; sha256 = "1f916gv4fz571l4jvr15xjnsvjyy4nljv2ii9njwlm7k6yr5m0qn"; } else - pkgs.fetchurl { + fetchurl { url = "https://github.com/purescript/purescript/releases/download/v0.12.3/linux64.tar.gz"; sha256 = "1fad862a2sv4njxbbcfzibbi585m6is3ywb94nmjl8ax254baj3i"; }; - buildInputs = [ pkgs.zlib - pkgs.gmp - pkgs.ncurses5]; - libPath = pkgs.lib.makeLibraryPath buildInputs; + buildInputs = [ zlib + gmp + ncurses5 ]; + libPath = lib.makeLibraryPath buildInputs; dontStrip = true; installPhase = '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e5cab6e7917..d466fe55e1f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7137,7 +7137,7 @@ in all-cabal-hashes = callPackage ../data/misc/hackage { }; - purescript = callPackage ../development/compilers/purescript/purescript { inherit pkgs; }; + purescript = callPackage ../development/compilers/purescript/purescript { }; psc-package = haskell.lib.justStaticExecutables (haskellPackages.callPackage ../development/compilers/purescript/psc-package { }); From 7af53c85ed41c9be5f1c65bc56ef6fd569c19f29 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 20 Mar 2019 15:52:28 +0200 Subject: [PATCH 4/6] purescript: add meta information for package Co-Authored-By: justinwoo --- .../compilers/purescript/purescript/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/development/compilers/purescript/purescript/default.nix b/pkgs/development/compilers/purescript/purescript/default.nix index 219c111b080..51863807e41 100644 --- a/pkgs/development/compilers/purescript/purescript/default.nix +++ b/pkgs/development/compilers/purescript/purescript/default.nix @@ -50,4 +50,11 @@ in stdenv.mkDerivation rec { mkdir -p $out/etc/bash_completion.d/ $PURS --bash-completion-script $PURS > $out/etc/bash_completion.d/purs-completion.bash ''; + meta = with stdenv.lib; { + description = "A strongly-typed functional programming language that compiles to JavaScript"; + homepage = http://www.purescript.org/; + license = licenses.bsd3; + maintainers = [ maintainers.justinwoo ]; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + }; } From 037f5fdffae19b2a82e1fdb5dd019afa6e3b14b1 Mon Sep 17 00:00:00 2001 From: justinwoo Date: Wed, 20 Mar 2019 15:54:46 +0200 Subject: [PATCH 5/6] maintainers: add justinwoo --- maintainers/maintainer-list.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 8d794dc84fc..3abd745104a 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -2370,6 +2370,11 @@ github = "juliendehos"; name = "Julien Dehos"; }; + justinwoo = { + email = "moomoowoo@gmail.com"; + github = "justinwoo"; + name = "Justin Woo"; + }; jwiegley = { email = "johnw@newartisans.com"; github = "jwiegley"; From 5aaf79d189a5374efbc47a1842c1b95bbc83644f Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 20 Mar 2019 15:55:48 +0200 Subject: [PATCH 6/6] purescript: tweak inlined import and usages Co-Authored-By: justinwoo --- pkgs/development/compilers/purescript/purescript/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/purescript/purescript/default.nix b/pkgs/development/compilers/purescript/purescript/default.nix index 51863807e41..5e84f2d874a 100644 --- a/pkgs/development/compilers/purescript/purescript/default.nix +++ b/pkgs/development/compilers/purescript/purescript/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, zlib, gmp, ncurses5 }: +{ stdenv, fetchurl, zlib, gmp, ncurses5, lib }: # from justinwoo/easy-purescript-nix # https://github.com/justinwoo/easy-purescript-nix/blob/d383972c82620a712ead4033db14110497bc2c9c/purs.nix @@ -50,7 +50,7 @@ in stdenv.mkDerivation rec { mkdir -p $out/etc/bash_completion.d/ $PURS --bash-completion-script $PURS > $out/etc/bash_completion.d/purs-completion.bash ''; - meta = with stdenv.lib; { + meta = with stdenv.lib; { description = "A strongly-typed functional programming language that compiles to JavaScript"; homepage = http://www.purescript.org/; license = licenses.bsd3;