diff --git a/default.nix b/default.nix index 987a951..0f96a55 100644 --- a/default.nix +++ b/default.nix @@ -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 diff --git a/extneder.nix b/extneder.nix index 6f2139d..da49598 100644 --- a/extneder.nix +++ b/extneder.nix @@ -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 diff --git a/modules/hostname.nix b/modules/hostname.nix new file mode 100644 index 0000000..a2c17ea --- /dev/null +++ b/modules/hostname.nix @@ -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"; + }; + }; +} diff --git a/pkgs/liminix-tools/networking/udhcpc.nix b/pkgs/liminix-tools/networking/udhcpc.nix index 482260e..ee9ed47 100644 --- a/pkgs/liminix-tools/networking/udhcpc.nix +++ b/pkgs/liminix-tools/networking/udhcpc.nix @@ -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