Class: Dependabot::Nix::FileParser
- Inherits:
-
FileParsers::Base
- Object
- FileParsers::Base
- Dependabot::Nix::FileParser
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/nix/file_parser.rb
Constant Summary collapse
- SUPPORTED_SOURCE_TYPES =
Updatable source types: git-backed sources plus NixOS channel tarballs.
T.let(%w(github gitlab sourcehut git tarball).freeze, T::Array[String])
- SUPPORTED_LOCK_VERSION =
7- DEFAULT_HOSTS =
T.let( { "github" => "github.com", "gitlab" => "gitlab.com", "sourcehut" => "git.sr.ht" }.freeze, T::Hash[String, String] )
Instance Method Summary collapse
Instance Method Details
#ecosystem ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/dependabot/nix/file_parser.rb', line 58 def ecosystem @ecosystem ||= T.let( Ecosystem.new( name: ECOSYSTEM, package_manager: package_manager ), T.nilable(Dependabot::Ecosystem) ) end |
#parse ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/dependabot/nix/file_parser.rb', line 34 def parse lock_content = JSON.parse(T.must(flake_lock.content)) lock_version = lock_content["version"] if lock_version != SUPPORTED_LOCK_VERSION Dependabot.logger.warn( "flake.lock version #{lock_version.inspect} differs from expected #{SUPPORTED_LOCK_VERSION}" ) end root_name = lock_content.fetch("root", "root") nodes = lock_content.fetch("nodes", {}) root_node = nodes.fetch(root_name, {}) root_inputs = root_node.fetch("inputs", {}) root_inputs.filter_map do |input_name, node_label| node = resolve_node(node_label, nodes) next unless node build_dependency(input_name, node) end end |