forked from dan/liminix
1
0
Fork 0

set hostname before dhcp client runs

This commit is contained in:
Daniel Barlow 2023-03-08 22:11:59 +00:00
parent 2318c54037
commit 91c0147919
4 changed files with 30 additions and 5 deletions

View File

@ -22,6 +22,7 @@ let
{ _module.args = { inherit pkgs; lib = pkgs.lib; }; }
./modules/hardware.nix
./modules/base.nix
./modules/hostname.nix
device.module
liminix-config
./modules/s6

View File

@ -38,6 +38,8 @@ in rec {
./modules/flashable.nix
];
hostname = "extneder";
kernel = {
config = {
@ -90,7 +92,10 @@ in rec {
type = "bridge";
device = "int";
};
services.dhcpc = (udhcpc services.int {}) // {device = "int";};
services.dhcpc = (udhcpc services.int {
dependencies = [ config.services.hostname ];
}) // { device = "int"; };
services.bridge = let
primary = services.int;
@ -154,7 +159,7 @@ in rec {
name = "default";
contents =
let links = config.hardware.networkInterfaces;
in with services; [
in with config.services; [
links.lo links.eth links.wlan
int
bridge

19
modules/hostname.nix Normal file
View File

@ -0,0 +1,19 @@
{ lib, pkgs, config, ...}:
let
inherit (lib) mkOption types;
inherit (pkgs.liminix.services) oneshot;
in {
options = {
hostname = mkOption {
default = "liminix";
type = types.nonEmptyStr;
};
};
config = {
services.hostname = oneshot {
name = "hostname";
up = "echo ${config.hostname} > /proc/sys/kernel/hostname";
down = "true";
};
};
}

View File

@ -7,7 +7,7 @@
let
inherit (liminix.services) longrun;
in
interface: { ... } @ args:
interface: { dependencies ? [] } @ args:
let
name = "${interface.device}.udhcp";
script = writeAshScript "udhcp-notify" {
@ -43,9 +43,9 @@ let
'';
in longrun {
inherit name;
run = "${busybox}/bin/udhcpc -f -i ${interface.device} -s ${script}";
run = "${busybox}/bin/udhcpc -f -i ${interface.device} -x hostname:$(cat /proc/sys/kernel/hostname) -s ${script}";
notification-fd = 10;
dependencies = [ interface ];
dependencies = [ interface ] ++ dependencies;
}
# lease=86400