{ lib, pkgs, config, username, ... }: let cfg = config.networking; in { options = { networking = { enable = lib.mkEnableOption "Enable networking in NixOS and home-manager"; }; }; config = lib.mkIf cfg.enable { environment = { systemPackages = [ ]; }; networking = { extraHosts = '' 10.0.0.24 desktop ''; networkmanager = { enable = true; }; useDHCP = lib.mkDefault true; wireguard.enable = true; }; # Fix for automatic-timezoned not working currently (Jan 2025) systemd.services.set-timezone = { description = "Kludgily set the timezone based on IP, with an API request to some sketchasaurus website."; after = [ "network-online.target" ]; wants = [ "network-online.target" ]; serviceConfig = { Type = "oneshot"; ExecStart = "${pkgs.writeShellScript "set-timezone.sh" '' IP=$(${pkgs.curl}/bin/curl -s https://api.ipify.org) /run/current-system/sw/bin/logger "Got IP $IP." ${pkgs.curl}/bin/curl "https://api.ipgeolocation.io/timezone?apiKey=2309807339f84c26a2cb8cb44c31e183&ip=$IP" > /tmp/tz TZ=$(${pkgs.jq}/bin/jq -r .timezone < /tmp/tz) timedatectl set-timezone $TZ /run/current-system/sw/bin/logger "Set timezone to $TZ." ''}"; Restart = "no"; StandardOutput = "journal"; StandardError = "journal"; }; }; }; }