Set networking options for Gitea

main
Carsten Kragelund 2023-05-10 05:19:25 +02:00
parent 7ec25b4da1
commit b8a35853e4
Signed by: nyx
GPG Key ID: CADDADEEC9F753C0
2 changed files with 26 additions and 4 deletions

@ -0,0 +1,23 @@
{ hostName, macAddresses, ipv4Addresses }: { lib, ... }: let
inherit (builtins) map toString listToAttrs;
inherit (lib) imap1 concatImapStrings;
in {
networking = {
inherit hostName;
useDHCP = false;
interfaces = listToAttrs (imap1 (i: macAddress: {
name = "enc${toString i}";
value = {
inherit macAddress;
ipv4.addresses = map (address: {
inherit address;
prefixLength = 24;
}) ipv4Addresses;
};
}) macAddresses);
defaultGateway.address = "192.168.1.1";
};
services.udev.extraRules = concatImapStrings (i: macAddress: ''
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="${macAddress}", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="enc${toString i}"
'') macAddresses;
}

@ -5,12 +5,14 @@
}: {
imports = [
./hardware.nix
(import ../common/network.nix { hostName = "gitea"; macAddresses = [ "00:50:50:00:00:01" ]; ipv4Addresses = [ "192.168.1.7" ]; })
../common
./services
];
# networking = builtins.trace ((pkgs.callPackage ../common/network.nix {}) { hostName = "gitea"; macAddresses = [ "00:50:50:00:00:01" ]; ipv4Addresses = [ "192.168.1.7" ]; }) {};
users.users.admin = {
isNormalUser = true;
description = "Gitea Administrator";
@ -25,9 +27,6 @@
graphical = false;
vm-guest = true;
networking.hostName = "gitea";
networking.firewall.allowedTCPPorts = [ 22 3000 ];
sops = {
defaultSopsFile = ../../secrets/gitea.yaml;
};