1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-18 05:21:47 +03:00
mobile-nixos/boot/init/lib/udev.rb

15 lines
433 B
Ruby
Raw Normal View History

2019-12-22 07:12:39 +03:00
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