2015-10-16 19:35:18 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2016-02-02 17:25:18 +01:00
|
|
|
|
2015-10-16 19:35:18 +02:00
|
|
|
cfg = config.boot.initrd.network;
|
|
|
|
|
|
|
|
in
|
2016-02-02 17:25:18 +01:00
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-02-02 17:25:18 +01:00
|
|
|
boot.initrd.network.postCommands = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
2015-10-16 19:35:18 +02:00
|
|
|
description = ''
|
2016-02-02 17:25:18 +01:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2016-02-02 17:25:18 +01:00
|
|
|
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
|
2016-02-02 17:25:18 +01:00
|
|
|
|
|
|
|
${cfg.postCommands}
|
2015-10-16 19:35:18 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
2016-02-02 17:25:18 +01:00
|
|
|
|
2015-10-16 19:35:18 +02:00
|
|
|
}
|