Class: Dependabot::Nix::FileParser

Inherits:
FileParsers::Base
  • Object
show all
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.

%w(github gitlab sourcehut git tarball).freeze
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

#ecosystemObject



53
54
55
56
57
58
59
60
61
# File 'lib/dependabot/nix/file_parser.rb', line 53

def ecosystem
  @ecosystem ||= T.let(
    Ecosystem.new(
      name: ECOSYSTEM,
      package_manager: package_manager
    ),
    T.nilable(Dependabot::Ecosystem)
  )
end

#parseObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/dependabot/nix/file_parser.rb', line 34

def parse
  lockfile = Lockfile.new(T.must(flake_lock.content))

  lock_version = lockfile.version
  if lock_version != SUPPORTED_LOCK_VERSION
    Dependabot.logger.warn(
      "flake.lock version #{lock_version.inspect} differs from expected #{SUPPORTED_LOCK_VERSION}"
    )
  end

  lockfile.root_input_names.filter_map do |input_name|
    node = lockfile.input_node(input_name)
    next unless node

    build_dependency(input_name, node)
  end
end