Skip to content

Commit

Permalink
feat: enable dhcp
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed May 18, 2024
1 parent 03a5c0d commit d800002
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ with lib;
type = types.bool;
description = "enable nix-daemon and a writeable store";
};
not-os.dhcp = mkOption {
type = types.bool;
description = "enable dhcp initial discovery on startup";
};
not-os.rngd = mkOption {
type = types.bool;
description = "enable rngd";
Expand Down Expand Up @@ -104,6 +108,7 @@ with lib;
passwd.text = ''
root:x:0:0:System administrator:/root:/run/current-system/sw/bin/bash
sshd:x:498:65534:SSH privilege separation user:/var/empty:/run/current-system/sw/bin/nologin
dhcpcd:x:499:65534:DHCP Client privilege separation user:/var/empty:/run/current-system/sw/bin/nologin
toxvpn:x:1010:65534::/var/lib/toxvpn:/run/current-system/sw/bin/nologin
nixbld1:x:30001:30000:Nix build user 1:/var/empty:/run/current-system/sw/bin/nologin
nixbld2:x:30002:30000:Nix build user 2:/var/empty:/run/current-system/sw/bin/nologin
Expand Down
15 changes: 14 additions & 1 deletion runit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ in
ip route add 10.0.2.0/24 dev eth0
ip route add default via 10.0.2.2 dev eth0
''}
mkdir /bin/
ln -s ${pkgs.runtimeShell} /bin/sh
${lib.optionalString config.not-os.dhcp ''
mkdir -p /var/db/dhcpcd /var/run/dhcpcd
touch /etc/dhcpcd.conf
${pkgs.dhcpcd}/sbin/dhcpcd --oneshot
''}
${lib.optionalString (config.networking.timeServers != []) ''
${pkgs.ntp}/bin/ntpdate ${toString config.networking.timeServers}
''}
Expand All @@ -56,7 +63,6 @@ in
touch /etc/runit/stopit
chmod 0 /etc/runit/stopit
${if true then "" else "${pkgs.dhcpcd}/sbin/dhcpcd"}
'';
"runit/2".source = pkgs.writeScript "2" ''
#!${pkgs.runtimeShell}
Expand All @@ -79,6 +85,13 @@ in
nix-daemon
'';
}
(lib.mkIf config.not-os.dhcp {
"service/dhcp/run".source = pkgs.writeScript "dhcp_run" ''
#!${pkgs.runtimeShell}
echo Start dhcp client
${pkgs.dhcpcd}/sbin/dhcpcd --background
'';
})
(lib.mkIf config.not-os.rngd {
"service/rngd/run".source = pkgs.writeScript "rngd" ''
#!${pkgs.runtimeShell}
Expand Down

0 comments on commit d800002

Please sign in to comment.