Compare commits

..

2 commits

Author SHA1 Message Date
sinavir
31d31260b8
feat(system-config): Readable name for the system closure
All checks were successful
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 19s
build liminix / build_vm_qemu_mips (pull_request) Successful in 21s
build liminix / test_shell_customization (pull_request) Successful in 21s
build liminix / test_hostapd (pull_request) Successful in 1m12s
2025-02-04 23:33:38 +01:00
sinavir
b129f775b2
feat(networking): Add wlan mac personalisation
All checks were successful
build liminix / build_vm_qemu_mips (pull_request) Successful in 35s
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 38s
build liminix / test_shell_customization (pull_request) Successful in 42s
build liminix / test_hostapd (pull_request) Successful in 45s
2025-02-04 22:00:13 +01:00
8 changed files with 231 additions and 201 deletions

View file

@ -135,6 +135,21 @@ rec {
../../modules/zyxel-dual-image ../../modules/zyxel-dual-image
]; ];
options = {
hardware.wlanMacAddresses = {
wlan0 = lib.mkOption {
type = lib.types.str;
description = "Mac address of wlan0 device";
};
wlan1 = lib.mkOption {
type = lib.types.str;
description = "Mac address of wlan1 device";
};
};
};
config = {
nixpkgs.hostPlatform = system.crossSystem; nixpkgs.hostPlatform = system.crossSystem;
filesystem = dir { filesystem = dir {
@ -208,10 +223,12 @@ rec {
wlan0 = link.build { wlan0 = link.build {
ifname = "wlan0"; ifname = "wlan0";
dependencies = [ mac80211 ]; dependencies = [ mac80211 ];
mac = config.hardware.wlanMacAddresses.wlan0;
}; };
wlan1 = link.build { wlan1 = link.build {
ifname = "wlan1"; ifname = "wlan1";
dependencies = [ mac80211 ]; dependencies = [ mac80211 ];
mac = config.hardware.wlanMacAddresses.wlan1;
}; };
}; };
}; };
@ -364,4 +381,5 @@ rec {
}; };
}; };
}; };
};
} }

View file

@ -74,6 +74,13 @@ in {
device will be renamed to the name provided. device will be renamed to the name provided.
''; '';
}; };
mac = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
MAC address of the interface.
'';
};
devpath = mkOption { devpath = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;

View file

@ -7,6 +7,7 @@
{ {
ifname ifname
, devpath ? null , devpath ? null
, mac ? null
, mtu} : , mtu} :
# if devpath is supplied, we rename the interface at that # if devpath is supplied, we rename the interface at that
# path to have the specified name. # path to have the specified name.
@ -24,7 +25,7 @@ in oneshot {
inherit name; inherit name;
up = '' up = ''
${rename} ${rename}
${liminix.networking.ifup name ifname} ${liminix.networking.ifup name ifname mac}
''; '';
down = "ip link set down dev ${ifname}"; down = "ip link set down dev ${ifname}";
} }

View file

@ -75,7 +75,7 @@ in
mv out $out mv out $out
''; '';
systemConfiguration = systemConfiguration =
pkgs.systemconfig config.filesystem.contents; pkgs.systemconfig config.filesystem.contents config.hostname;
}; };
}; };
} }

View file

@ -11,7 +11,7 @@ in oneshot rec {
up = '' up = ''
ip link add link $(output ${primary} ifname) name ${ifname} type vlan id ${vid} ip link add link $(output ${primary} ifname) name ${ifname} type vlan id ${vid}
${optionalString untagged.egress "bridge vlan add dev ${ifname} vid ${toString untagged.vid} pvid untagged master"} ${optionalString untagged.egress "bridge vlan add dev ${ifname} vid ${toString untagged.vid} pvid untagged master"}
${liminix.networking.ifup name ifname} ${liminix.networking.ifup name ifname null}
(in_outputs ${name} (in_outputs ${name}
echo ${ifname} > ifname echo ${ifname} > ifname
) )

View file

@ -74,7 +74,7 @@ let
../../modules/s6 ../../modules/s6
]; ];
}; };
in systemconfig eval.config.filesystem.contents; in systemconfig eval.config.filesystem.contents eval.config.hostname;
in writeScriptBin "levitate" '' in writeScriptBin "levitate" ''
#!/bin/sh #!/bin/sh
destdir=${newRoot} destdir=${newRoot}

View file

@ -3,9 +3,13 @@
, serviceFns , serviceFns
}: }:
{ {
ifup = name : ifname : '' ifup = name : ifname : mac: ''
. ${serviceFns} . ${serviceFns}
${ifwait}/bin/ifwait -v ${ifname} present ${ifwait}/bin/ifwait -v ${ifname} present
${if (mac == null) then "" else ''
ip link set down dev ${ifname}
ip link set dev ${ifname} address ${mac}
''}
ip link set up dev ${ifname} ip link set up dev ${ifname}
(in_outputs ${name} (in_outputs ${name}
echo ${ifname} > ifname echo ${ifname} > ifname

View file

@ -62,10 +62,10 @@ let
${(builtins.concatStringsSep "\n" (visit "." attrset))} ${(builtins.concatStringsSep "\n" (visit "." attrset))}
} }
''; '';
in attrset: in attrset: hostname:
let makedevs = activateScript attrset; let makedevs = activateScript attrset;
in stdenv.mkDerivation { in stdenv.mkDerivation {
name="make-stuff"; name="${hostname}-system-configuration";
src = ./.; src = ./.;
CFLAGS = "-Os"; CFLAGS = "-Os";