ghcjs: refactor stage2 handling

Previously, the stage2 information was stored in haskell-modules, and imported directly from there. However, the correct stage2 information is determined by the version of ghcjs-boot repository. This commit makes the stage2 information part of the ghcjs derivation, which improves organization and makes it possible to override stage2 when overriding ghcjs.

+60 -58
+3
pkgs/development/compilers/ghcjs/default.nix
··· 136 136 isGhcjs = true; 137 137 inherit nodejs ghcjsBoot; 138 138 inherit (ghcjsNodePkgs) "socket.io"; 139 + mkStage2 = import ./stage2.nix { 140 + inherit ghcjsBoot; 141 + }; 139 142 }; 140 143 141 144 homepage = "https://github.com/ghcjs/ghcjs";
+54
pkgs/development/compilers/ghcjs/gen-stage2.rb
··· 1 + #!/usr/bin/env ruby 2 + 3 + require 'pathname' 4 + 5 + # from boot.yaml in ghcjs/ghcjs 6 + stage2_packages = [ 7 + "boot/async", 8 + "boot/aeson", 9 + "boot/attoparsec", 10 + "boot/case-insensitive", 11 + "boot/dlist", 12 + "boot/extensible-exceptions", 13 + "boot/hashable", 14 + "boot/mtl", 15 + "boot/old-time", 16 + "boot/parallel", 17 + "boot/scientific", 18 + "boot/stm", 19 + "boot/syb", 20 + "boot/text", 21 + "boot/unordered-containers", 22 + "boot/vector", 23 + "ghcjs/ghcjs-base", 24 + # not listed under stage2, but needed when "quick booting". 25 + "boot/cabal/Cabal" 26 + ] 27 + 28 + nixpkgs = File.expand_path("../../../../..", __FILE__) 29 + boot = ARGV[0] || `nix-build #{nixpkgs} -A haskell.packages.ghcjs.ghc.ghcjsBoot`.chomp 30 + 31 + out = "".dup 32 + out << "{ ghcjsBoot }: { callPackage }:\n" 33 + out << "\n" 34 + out << "{\n" 35 + 36 + stage2_packages.each do |package| 37 + name = Pathname.new(package).basename 38 + nix = `cabal2nix file://#{boot}/#{package} --jailbreak` 39 + nix.sub!(/src =.*?$/, "src = \"${ghcjsBoot}/#{package}\";") 40 + nix.sub!(" doCheck = false;\n", "") 41 + nix.sub!("libraryHaskellDepends", "doCheck = false;\n libraryHaskellDepends") 42 + # cabal2nix somehow generates the deps for 'text' as if it had selected flag 43 + # 'integer-simple' (despite not passing the flag within the generated 44 + # expression). We want integer-gmp instead. 45 + nix.gsub!(/integer-simple/, "integer-gmp") 46 + nix = nix.split("\n").join("\n ") 47 + 48 + out << " #{name} = callPackage\n" 49 + out << " (#{nix}) {};\n" 50 + end 51 + 52 + out << "}" 53 + 54 + puts out
+2 -4
pkgs/development/haskell-modules/configuration-ghcjs.nix
··· 9 9 10 10 self: super: 11 11 # The stage 2 packages. Regenerate with ./ghcjs/gen-stage2.rb 12 - let stage2 = 13 - (import ./ghcjs/stage2.nix { 12 + let stage2 = super.ghc.mkStage2 { 14 13 inherit (self) callPackage; 15 - inherit (self.ghc) ghcjsBoot; 16 - }); in stage2 // { 14 + }; in stage2 // { 17 15 18 16 old-time = overrideCabal stage2.old-time (drv: { 19 17 postPatch = ''
-53
pkgs/development/haskell-modules/ghcjs/gen-stage2.rb
··· 1 - #!/usr/bin/env ruby 2 - 3 - require 'pathname' 4 - 5 - # from boot.yaml in ghcjs/ghcjs 6 - stage2_packages = [ 7 - "boot/async", 8 - "boot/aeson", 9 - "boot/attoparsec", 10 - "boot/case-insensitive", 11 - "boot/dlist", 12 - "boot/extensible-exceptions", 13 - "boot/hashable", 14 - "boot/mtl", 15 - "boot/old-time", 16 - "boot/parallel", 17 - "boot/scientific", 18 - "boot/stm", 19 - "boot/syb", 20 - "boot/text", 21 - "boot/unordered-containers", 22 - "boot/vector", 23 - "ghcjs/ghcjs-base", 24 - # not listed under stage2, but needed when "quick booting". 25 - "boot/cabal/Cabal" 26 - ] 27 - 28 - nixpkgs = File.expand_path("../../../../..", __FILE__) 29 - boot = `nix-build #{nixpkgs} -A haskell.packages.ghcjs.ghc.ghcjsBoot`.chomp 30 - 31 - out = "".dup 32 - out << "{ ghcjsBoot, callPackage }:\n" 33 - out << "\n" 34 - out << "{\n" 35 - 36 - stage2_packages.each do |package| 37 - name = Pathname.new(package).basename 38 - nix = `cabal2nix file://#{boot}/#{package} --jailbreak` 39 - nix.sub!(/src =.*?$/, "src = \"${ghcjsBoot}/#{package}\";") 40 - nix.sub!("libraryHaskellDepends", "doCheck = false;\n libraryHaskellDepends") 41 - # cabal2nix somehow generates the deps for 'text' as if it had selected flag 42 - # 'integer-simple' (despite not passing the flag within the generated 43 - # expression). We want integer-gmp instead. 44 - nix.gsub!(/integer-simple/, "integer-gmp") 45 - nix = nix.split("\n").join("\n ") 46 - 47 - out << " #{name} = callPackage\n" 48 - out << " (#{nix}) {};\n" 49 - end 50 - 51 - out << "}" 52 - 53 - puts out
+1 -1
pkgs/development/haskell-modules/ghcjs/stage2.nix pkgs/development/compilers/ghcjs/stage2.nix
··· 1 - { ghcjsBoot, callPackage }: 1 + { ghcjsBoot }: { callPackage }: 2 2 3 3 { 4 4 async = callPackage