nix 0.0.3 → 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/nix/gem-nix-command.rb +40 -41
- data/lib/nix/version.rb +1 -1
- data/lib/rubygems_plugin.rb +13 -2
- data/nix.gemspec +1 -1
- metadata +4 -5
data/lib/nix/gem-nix-command.rb
CHANGED
@@ -31,23 +31,12 @@ class Gem::Specification
|
|
31
31
|
def nix_meta
|
32
32
|
{
|
33
33
|
:homepage => homepage,
|
34
|
-
:description =>
|
35
|
-
:longDescription =>
|
34
|
+
:description => summary,
|
35
|
+
:longDescription => description,
|
36
36
|
:license => licenses
|
37
37
|
}.reject { |k, v| v.nil? or (v.respond_to?(:empty?) and v.empty?) }
|
38
38
|
end
|
39
39
|
|
40
|
-
def nix_description(long)
|
41
|
-
return nil if description.nil? or description.empty?
|
42
|
-
desc = description.dup
|
43
|
-
if not long then
|
44
|
-
desc.sub!(/\A[[:space:]]*([^.\n]*[^.\n[:space:]]).*\z/,'\1')
|
45
|
-
desc.sub!(/ +/, ' ')
|
46
|
-
desc.sub!(/(.{120}).+/, '\1[...]') # Trim to 120 chars
|
47
|
-
end
|
48
|
-
desc
|
49
|
-
end
|
50
|
-
|
51
40
|
def src_url
|
52
41
|
"http://production.cf.rubygems.org/gems/#{full_name}.gem"
|
53
42
|
end
|
@@ -89,18 +78,29 @@ class Gem::Specification
|
|
89
78
|
end
|
90
79
|
|
91
80
|
class Gem::Commands::NixCommand < Gem::Command
|
92
|
-
include Gem::VersionOption
|
93
|
-
include Gem::LocalRemoteOptions
|
94
|
-
include Gem::InstallUpdateOptions
|
95
|
-
|
96
81
|
def exec
|
97
82
|
begin
|
98
83
|
@prerelease = false;
|
99
84
|
|
100
85
|
args = options[:args];
|
101
86
|
|
87
|
+
if FileTest.exists?(options[:nix_file])
|
88
|
+
raise "File #{options[:nix_file]} is not a regular file" unless FileTest.file?(options[:nix_file])
|
89
|
+
File.open(options[:nix_file], 'r') do |f|
|
90
|
+
l = f.readlines.select {|s| s =~ /gem_nix_args =/}.first
|
91
|
+
args += l.
|
92
|
+
sub(/ *gem_nix_args = \[ (.*) \];/, '\1').split(' ').
|
93
|
+
map do |s|
|
94
|
+
s.sub(/\A''/, '').sub(/''\Z/, '')
|
95
|
+
end
|
96
|
+
end unless options[:ignore_existing]
|
97
|
+
end
|
98
|
+
|
99
|
+
args.sort!
|
100
|
+
|
101
|
+
say "Will generate nix file for the following gems: #{args.join ', '}" if Gem::configuration.really_verbose
|
102
|
+
|
102
103
|
@gems_with_deps = {}
|
103
|
-
@seen = {}
|
104
104
|
|
105
105
|
# args to dep informations
|
106
106
|
args.each { |arg|
|
@@ -116,11 +116,6 @@ class Gem::Commands::NixCommand < Gem::Command
|
|
116
116
|
|
117
117
|
say " total: #{@gems_with_deps.length}" if Gem.configuration.really_verbose
|
118
118
|
|
119
|
-
print <<-EOF
|
120
|
-
# WARNING: automatically generated file
|
121
|
-
# the gem nix command comes from 'nix' gem
|
122
|
-
g: # Get dependencies from patched gems
|
123
|
-
EOF
|
124
119
|
# define aliases
|
125
120
|
aliases = {}
|
126
121
|
output_gems = {}
|
@@ -135,14 +130,19 @@ g: # Get dependencies from patched gems
|
|
135
130
|
})
|
136
131
|
end
|
137
132
|
|
138
|
-
|
139
|
-
:
|
140
|
-
|
141
|
-
:
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
133
|
+
File.open(options[:nix_file], 'w') do |f|
|
134
|
+
f << "# WARNING: automatically generated file\n"
|
135
|
+
f << "# Generated by 'gem nix' command that comes from 'nix' gem\n"
|
136
|
+
f << "g: # Get dependencies from patched gems\n"
|
137
|
+
f << ({
|
138
|
+
:gem_nix_args => args,
|
139
|
+
:gems => output_gems,
|
140
|
+
:aliases => aliases.values.inject({}) do |h, s|
|
141
|
+
h[s.nix_name(:short_sym)] = s.nix_name(:rhs_sym)
|
142
|
+
h
|
143
|
+
end
|
144
|
+
}.to_nix) << "\n"
|
145
|
+
end
|
146
146
|
exit_code = 0
|
147
147
|
|
148
148
|
rescue => e
|
@@ -155,15 +155,14 @@ g: # Get dependencies from patched gems
|
|
155
155
|
|
156
156
|
def adddep(dep)
|
157
157
|
say "adding dep #{dep.name}." if Gem.configuration.really_verbose
|
158
|
-
|
159
|
-
|
160
|
-
full_name = gem[0].full_name
|
158
|
+
spec, source_uri = find_gem_with_source(dep)
|
159
|
+
full_name = spec.full_name
|
161
160
|
|
162
|
-
return if @
|
163
|
-
@
|
161
|
+
return if @gems_with_deps.key?(full_name)
|
162
|
+
@gems_with_deps[full_name] = nil # there maybe circular dependencies. thus mark this gem seen as early as possible
|
164
163
|
|
165
164
|
# development deps can't be found. Some are old. Thus only add rutime dependencies
|
166
|
-
deps =
|
165
|
+
deps = spec.dependencies.find_all { |d| d.type == :runtime }
|
167
166
|
|
168
167
|
say " total deps of #{full_name}: #{deps.length}" if Gem.configuration.really_verbose
|
169
168
|
|
@@ -171,11 +170,9 @@ g: # Get dependencies from patched gems
|
|
171
170
|
dep_specs = deps.map { |dep| adddep(dep) }
|
172
171
|
|
173
172
|
@gems_with_deps[full_name] = [
|
174
|
-
|
175
|
-
gem[1], # src
|
176
|
-
dep_specs # deps
|
173
|
+
spec, source_uri, dep_specs
|
177
174
|
]
|
178
|
-
|
175
|
+
spec # only return spec, no source for dep list
|
179
176
|
end
|
180
177
|
|
181
178
|
|
@@ -199,6 +196,8 @@ g: # Get dependencies from patched gems
|
|
199
196
|
dep.match?(dep.name, version)
|
200
197
|
end
|
201
198
|
|
199
|
+
raise Gem::CommandLineError, "couldn't find #{dep}" if found.empty?
|
200
|
+
|
202
201
|
latest = found.sort { |a, b| a.first <=> b.first }.last
|
203
202
|
[Gem::SpecFetcher.fetcher.fetch_spec([dep.name, latest.first, latest[1]], latest.last), latest.last.to_s]
|
204
203
|
end
|
data/lib/nix/version.rb
CHANGED
data/lib/rubygems_plugin.rb
CHANGED
@@ -3,8 +3,19 @@ require 'rubygems/dependency_installer'
|
|
3
3
|
|
4
4
|
class Gem::Commands::NixCommand < Gem::Command
|
5
5
|
def initialize
|
6
|
-
defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
|
6
|
+
defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
|
7
|
+
:nix_file => ENV.fetch('NIXPKGS_ALL', '/etc/nixos/nixpkgs') + '/pkgs/development/interpreters/ruby/gems-generated.nix',
|
8
|
+
:ignore_existing => false
|
9
|
+
})
|
7
10
|
super 'nix', 'Create a nix file containing expressions of the gems', defaults
|
11
|
+
|
12
|
+
add_option('--nix-file=/path/to/gems-generated.nix', 'Use specified nix file instead of default one') do |value, options|
|
13
|
+
options[:nix_file] = value
|
14
|
+
end
|
15
|
+
|
16
|
+
add_option('--[no-]ignore-existing', 'Ignore gems from the previous run') do |value, options|
|
17
|
+
options[:ignore_existing] = value
|
18
|
+
end
|
8
19
|
end
|
9
20
|
|
10
21
|
def description # :nodoc:
|
@@ -31,7 +42,7 @@ class Gem::Commands::NixCommand < Gem::Command
|
|
31
42
|
|
32
43
|
def execute
|
33
44
|
require 'nix/gem-nix-command' unless respond_to? :exec
|
34
|
-
|
45
|
+
exec
|
35
46
|
end
|
36
47
|
end
|
37
48
|
|
data/nix.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ["urkud@ya.ru"]
|
11
11
|
s.homepage = "http://gitorious.org/ruby-nix"
|
12
12
|
s.summary = %q{Nix package manager interface}
|
13
|
-
s.description = %q{
|
13
|
+
s.description = %q{Adds 'gem nix' command that dumps given set of gems to format suitable for Nix package manager}
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.0.3
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Yury G. Kudryashov
|
@@ -19,7 +18,7 @@ date: 2011-01-18 00:00:00 +03:00
|
|
19
18
|
default_executable:
|
20
19
|
dependencies: []
|
21
20
|
|
22
|
-
description:
|
21
|
+
description: Adds 'gem nix' command that dumps given set of gems to format suitable for Nix package manager
|
23
22
|
email:
|
24
23
|
- urkud@ya.ru
|
25
24
|
executables: []
|