1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-15 19:23:01 +03:00
mobile-nixos/boot/init/lib/udev.rb
2020-02-03 16:19:10 -05:00

15 lines
433 B
Ruby

module UDev
# Loads a simplified `ENV{k}="v"` udev rules file.
# This is *not* a comprehensive parser!!
# This is intended to be used for loading the environment as described by
# udev rules.
def self.simple_load_environment(file)
rules = File.read(file).strip.split("\n")
rules.each do |line|
data = line.match(/\s*ENV{([^}]+)}="(.*)"$/)
next unless data
ENV[data[1]] = data[2]
end
end
end