nixpkgs-suyu/nixos/modules/system/boot/initrd-network.nix

62 lines
1.1 KiB
Nix
Raw Normal View History

2015-10-16 19:35:18 +02:00
{ config, lib, pkgs, ... }:
with lib;
let
2015-10-16 19:35:18 +02:00
cfg = config.boot.initrd.network;
in
2015-10-16 19:35:18 +02:00
{
options = {
boot.initrd.network.enable = mkOption {
type = types.bool;
default = false;
description = ''
Add network connectivity support to initrd.
Network options are configured via <literal>ip</literal> kernel
option, according to the kernel documentation.
'';
};
boot.initrd.network.postCommands = mkOption {
default = "";
type = types.lines;
2015-10-16 19:35:18 +02:00
description = ''
Shell commands to be executed after stage 1 of the
boot has initialised the network.
2015-10-16 19:35:18 +02:00
'';
};
};
config = mkIf cfg.enable {
boot.initrd.kernelModules = [ "af_packet" ];
boot.initrd.extraUtilsCommands = ''
copy_bin_and_libs ${pkgs.mkinitcpio-nfs-utils}/bin/ipconfig
'';
boot.initrd.preLVMCommands = ''
2015-10-16 19:35:18 +02:00
# Search for interface definitions in command line
for o in $(cat /proc/cmdline); do
case $o in
ip=*)
ipconfig $o && hasNetwork=1
;;
esac
done
${cfg.postCommands}
2015-10-16 19:35:18 +02:00
'';
};
2015-10-16 19:35:18 +02:00
}