aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/development/compilers/ghcjs/gen-stage2.rb
blob: 709e635db55cb6aa2584ce2d92c144a5a7425a4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/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