nixpkgs/pkgs/development/compilers/ghcjs/gen-stage2.rb
Ryan Trinkle c564997ba0 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.
2016-07-26 16:58:56 -04:00

55 lines
1.4 KiB
Ruby
Executable file

#!/usr/bin/env ruby
require 'pathname'
# from boot.yaml in ghcjs/ghcjs
stage2_packages = [
"boot/async",
"boot/aeson",
"boot/attoparsec",
"boot/case-insensitive",
"boot/dlist",
"boot/extensible-exceptions",
"boot/hashable",
"boot/mtl",
"boot/old-time",
"boot/parallel",
"boot/scientific",
"boot/stm",
"boot/syb",
"boot/text",
"boot/unordered-containers",
"boot/vector",
"ghcjs/ghcjs-base",
# not listed under stage2, but needed when "quick booting".
"boot/cabal/Cabal"
]
nixpkgs = File.expand_path("../../../../..", __FILE__)
boot = ARGV[0] || `nix-build #{nixpkgs} -A haskell.packages.ghcjs.ghc.ghcjsBoot`.chomp
out = "".dup
out << "{ ghcjsBoot }: { callPackage }:\n"
out << "\n"
out << "{\n"
stage2_packages.each do |package|
name = Pathname.new(package).basename
nix = `cabal2nix file://#{boot}/#{package} --jailbreak`
nix.sub!(/src =.*?$/, "src = \"${ghcjsBoot}/#{package}\";")
nix.sub!(" doCheck = false;\n", "")
nix.sub!("libraryHaskellDepends", "doCheck = false;\n libraryHaskellDepends")
# cabal2nix somehow generates the deps for 'text' as if it had selected flag
# 'integer-simple' (despite not passing the flag within the generated
# expression). We want integer-gmp instead.
nix.gsub!(/integer-simple/, "integer-gmp")
nix = nix.split("\n").join("\n ")
out << " #{name} = callPackage\n"
out << " (#{nix}) {};\n"
end
out << "}"
puts out