summary refs log tree commit diff
path: root/pkgs/development/compilers/elm/elm2nix.rb
blob: fab5551ca15892ae9ecf5c4b7dc0665457b33dc5 (plain) (blame)
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
#!/usr/bin/env ruby

require 'json'

system("elm-package install -y")
depsSrc = JSON.parse(File.read("elm-stuff/exact-dependencies.json"))
deps = Hash[ depsSrc.map { |pkg, ver|
  url = "https://github.com/#{pkg}/archive/#{ver}.tar.gz"
  sha256 = `nix-prefetch-url #{url}`

  [ pkg, { version: ver,
           sha256: sha256.strip
         }
  ]
} ]

File.open("package.nix", 'w') do |file|
  file.puts "{"
    for pkg, info in deps
      file.puts "  \"#{pkg}\" = {"
      file.puts "    version = \"#{info[:version]}\";"
      file.puts "    sha256 = \"#{info[:sha256]}\";"
      file.puts "  };"
    end
  file.puts "}"
end