Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main01 #15

Closed
wants to merge 13 commits into from
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ We will welcome all help with open arms!

- [Michael Fellinger](https://github.com/manveru)
- [Peter Hoeg](https://github.com/peterhoeg)
- [Vidhvath J](https://github.com/vidhvath28)
Binary file added crystal2nix
Binary file not shown.
3 changes: 3 additions & 0 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ shards:
git: https://github.com/hugopl/version_from_shard.git
version: 1.2.5

carbon_smtp_adapter:
hg: https://hg.sr.ht/~peterhoeg/dummy
version: 0.1.1+hg.commit.4048cd7e156f3d4317e10ebd4e742020c8049310
46 changes: 46 additions & 0 deletions shard.lock.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: 2.0
shards:
carbon:
git: https://github.com/luckyframework/carbon.git
version: 0.2.1

carbon_smtp_adapter:
hg: https://hg.sr.ht/~peterhoeg/dummy
version: 0.1.1+hg.commit.4048cd7e156f3d4317e10ebd4e742020c8049310

email:
git: https://github.com/arcage/crystal-email.git
version: 0.6.4

habitat:
git: https://github.com/luckyframework/habitat.git
version: 0.4.8

libremiliacr:
fossil: https://chiselapp.com/user/MistressRemilia/repository/libremiliacr
version: 0.90.6

lucky_task:
git: https://github.com/luckyframework/lucky_task.git
version: 0.1.1

teeplate:
git: https://github.com/luckyframework/teeplate.git
version: 0.8.5

version_from_shard:
git: https://github.com/hugopl/version_from_shard.git
version: 1.2.5

wordsmith:
git: https://github.com/luckyframework/wordsmith.git
version: 0.3.0

yunosynth:
fossil: https://chiselapp.com/user/MistressRemilia/repository/yunosynth
version: 0.4.2+fossil.commit.e820a8489011d22d43383526726b40695238c79d8e8b335fbf60a42dd0215544

zstd:
git: https://github.com/didactic-drunk/zstd.cr.git
version: 1.2.0

5 changes: 4 additions & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
name: crystal2nix
version: 0.3.0
license: MIT
Expand All @@ -18,6 +17,10 @@ dependencies:
github: hugopl/version_from_shard
version: ~> 1.2.4

carbon_smtp_adapter:
hg: https://hg.sr.ht/~peterhoeg/dummy
version: ~> 0.1.1

development_dependencies:
spectator:
gitlab: arctic-fox/spectator
Expand Down
12 changes: 0 additions & 12 deletions shards.nix
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
{
spectator = {
url = "https://gitlab.com/arctic-fox/spectator.git";
rev = "v0.10.5";
sha256 = "1fgjz5vg59h4m25v4fjklimcdn62ngqbchm00kw1160ggjpgpzw2";
};
version_from_shard = {
url = "https://github.com/hugopl/version_from_shard.git";
rev = "v1.2.5";
sha256 = "0xizj0q4rd541rwjbx04cjifc2gfx4l5v6q2y7gmd0ndjmkgb8ik";
};
}
2 changes: 1 addition & 1 deletion spec/repo_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Spectator.describe Repo do
expect(repo.rev).to eq("v0.1.1")
end
end
end
end
20 changes: 7 additions & 13 deletions src/repo.cr
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
module Crystal2Nix
class Repo
@url : URI
getter rev : String
property url : String
property rev : String?
property type : Symbol

def initialize(entry : Shard)
@url = URI.parse(entry.git).normalize
@rev = if entry.version =~ /^(?<version>.+)\+git\.commit\.(?<rev>.+)$/
$~["rev"]
else
"v#{entry.version}"
end
end

def url : String
@url.to_s
def initialize(url : String, rev : String? = nil, type : Symbol = :git)
@url = url
@rev = rev
@type = type
end
end
end
2 changes: 1 addition & 1 deletion src/runner.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "./crystal2nix"
require "./cli"

Crystal2Nix::Cli.new.run
Crystal2Nix::Cli.new.run
34 changes: 26 additions & 8 deletions src/worker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,32 @@ module Crystal2Nix
exit 1
end
sha256 = ""
args = [
"--no-deepClone",
"--url", repo.url,
"--rev", repo.rev,
]
Process.run("nix-prefetch-git", args: args) do |x|
x.error.each_line { |e| puts e }
sha256 = PrefetchJSON.from_json(x.output).sha256
case
when repo.url.ends_with?(".git")
args = [
"--no-deepClone",
"--url", repo.url,
"--rev", repo.rev,
]
Process.run("nix-prefetch-git", args: args) do |x|
x.error.each_line { |e| puts e }
sha256 = PrefetchJSON.from_json(x.output).sha256
end
when repo.url.starts_with?("https://hg.") || repo.url.ends_with?(".hg")
args = [
"--url", repo.url,
"--rev", repo.rev,
]
Process.run("nix-prefetch-hg", args: args) do |x|
x.error.each_line { |e| puts e }
sha256 = PrefetchJSON.from_json(x.output).sha256
end
when repo.url.ends_with?(".fossil")
STDERR.puts "Fossil repositories are not supported."
next
else
STDERR.puts "Unknown repository type for #{repo.url}"
next
end

file.puts %( #{key} = {)
Expand Down
Loading