summary refs log tree commit diff
path: root/nixos/modules/installer/tools/nixos-generate-config.pl
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-11 15:43:04 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-13 17:35:56 +0200
commit440fe8f05da84c37262ce4459d63febdded44f95 (patch)
treed8f412844c64bb9a0bf9bf716e0cbc31b4ec7bad /nixos/modules/installer/tools/nixos-generate-config.pl
parentac13bd2575843d0bc3f0eeb88600d1bb039cd5ba (diff)
downloadnixpkgs-440fe8f05da84c37262ce4459d63febdded44f95.tar
nixpkgs-440fe8f05da84c37262ce4459d63febdded44f95.tar.gz
nixpkgs-440fe8f05da84c37262ce4459d63febdded44f95.tar.bz2
nixpkgs-440fe8f05da84c37262ce4459d63febdded44f95.tar.lz
nixpkgs-440fe8f05da84c37262ce4459d63febdded44f95.tar.xz
nixpkgs-440fe8f05da84c37262ce4459d63febdded44f95.tar.zst
nixpkgs-440fe8f05da84c37262ce4459d63febdded44f95.zip
Use read_file from File::Slurp
Diffstat (limited to 'nixos/modules/installer/tools/nixos-generate-config.pl')
-rw-r--r--nixos/modules/installer/tools/nixos-generate-config.pl32
1 files changed, 8 insertions, 24 deletions
diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl
index e6d8eda016d..a70c9daff23 100644
--- a/nixos/modules/installer/tools/nixos-generate-config.pl
+++ b/nixos/modules/installer/tools/nixos-generate-config.pl
@@ -38,23 +38,7 @@ sub debug {
 }
 
 
-# Read a file, returning undef if the file cannot be opened.
-sub readFile {
-    my $filename = shift;
-    my $res;
-    if (open FILE, "<$filename") {
-        my $prev = $/;
-        undef $/;
-        $res = <FILE>;
-        $/ = $prev;
-        close FILE;
-        chomp $res;
-    }
-    return $res;
-}
-
-
-my $cpuinfo = readFile "/proc/cpuinfo";
+my $cpuinfo = read_file "/proc/cpuinfo";
 
 
 sub hasCPUFeature {
@@ -80,9 +64,9 @@ my $videoDriver;
 
 sub pciCheck {
     my $path = shift;
-    my $vendor = readFile "$path/vendor";
-    my $device = readFile "$path/device";
-    my $class = readFile "$path/class";
+    my $vendor = read_file "$path/vendor";
+    my $device = read_file "$path/device";
+    my $class = read_file "$path/class";
 
     my $module;
     if (-e "$path/driver/module") {
@@ -152,9 +136,9 @@ foreach my $path (glob "/sys/bus/pci/devices/*") {
 
 sub usbCheck {
     my $path = shift;
-    my $class = readFile "$path/bInterfaceClass";
-    my $subclass = readFile "$path/bInterfaceSubClass";
-    my $protocol = readFile "$path/bInterfaceProtocol";
+    my $class = read_file "$path/bInterfaceClass";
+    my $subclass = read_file "$path/bInterfaceSubClass";
+    my $protocol = read_file "$path/bInterfaceProtocol";
 
     my $module;
     if (-e "$path/driver/module") {
@@ -283,7 +267,7 @@ if (! -e $fn) {
   boot.loader.grub.enable = false;
   boot.loader.gummiboot.enable = true;
   boot.loader.efi.canTouchEfiVariables = true;
-  # !!! Remove me when nixos is on 3.10 or greater by default
+  # !!! Remove this when nixos is on 3.10 or greater by default
   # EFI booting requires kernel >= 3.10
   boot.kernelPackages = pkgs.linuxPackages_3_10;
 EOF