2022-06-06 15:21:37 +01:00
|
|
|
{ lib, pkgs, config, ... }:
|
2022-05-16 00:05:02 +01:00
|
|
|
let
|
|
|
|
inherit (lib) flatten optional mkIf mkDefault mkMerge;
|
2022-06-06 15:21:37 +01:00
|
|
|
|
|
|
|
# TODO: Backported from systemd 251
|
|
|
|
networkd-wait-online-at = pkgs.writeTextDir "lib/systemd/system/systemd-networkd-wait-online@.service" ''
|
|
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
#
|
|
|
|
# This file is part of systemd.
|
|
|
|
#
|
|
|
|
# systemd is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU Lesser General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
[Unit]
|
|
|
|
Description=Wait for Network Interface %i to be Configured
|
|
|
|
Documentation=man:systemd-networkd-wait-online.service(8)
|
|
|
|
DefaultDependencies=no
|
|
|
|
Conflicts=shutdown.target
|
|
|
|
Requires=systemd-networkd.service
|
|
|
|
After=systemd-networkd.service
|
|
|
|
Before=network-online.target shutdown.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
ExecStart=${pkgs.systemd}/lib/systemd/systemd-networkd-wait-online -i %i
|
|
|
|
RemainAfterExit=yes
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=network-online.target
|
|
|
|
'';
|
2022-05-16 00:05:02 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
config = mkMerge [
|
|
|
|
{
|
|
|
|
networking = {
|
|
|
|
domain = mkDefault "int.nul.ie";
|
|
|
|
useDHCP = false;
|
|
|
|
enableIPv6 = mkDefault true;
|
|
|
|
useNetworkd = mkDefault true;
|
|
|
|
};
|
2022-05-18 23:29:52 +01:00
|
|
|
|
2022-06-06 15:21:37 +01:00
|
|
|
systemd = {
|
|
|
|
packages = [ networkd-wait-online-at ];
|
|
|
|
};
|
|
|
|
|
2022-05-23 00:57:25 +01:00
|
|
|
services.resolved = {
|
|
|
|
domains = [ config.networking.domain ];
|
|
|
|
# Explicitly unset fallback DNS (Nix module will not allow for a blank config)
|
|
|
|
extraConfig = ''
|
|
|
|
FallbackDNS=
|
2022-05-28 13:57:01 +01:00
|
|
|
Cache=no-negative
|
2022-05-23 00:57:25 +01:00
|
|
|
'';
|
|
|
|
};
|
2022-05-16 00:05:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf config.my.build.isDevVM {
|
|
|
|
networking.interfaces.eth0.useDHCP = mkDefault true;
|
|
|
|
virtualisation = {
|
|
|
|
forwardPorts = flatten [
|
|
|
|
(optional config.services.openssh.openFirewall { from = "host"; host.port = 2222; guest.port = 22; })
|
|
|
|
];
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|