chore: track external network configs

This commit is contained in:
arcnmx 2024-03-25 10:09:18 -07:00
parent 3bb2e7e3c5
commit 103548a87c
11 changed files with 145 additions and 10 deletions

33
modules/system/extern/files.nix vendored Normal file
View file

@ -0,0 +1,33 @@
{config, lib, ...}: let
inherit (lib.options) mkOption;
fileModule = {config, name, ...}: {
options = with lib.types; {
path = mkOption {
type = str;
default = name;
};
owner = mkOption {
type = str;
default = "root";
};
group = mkOption {
type = str;
default = "root";
};
mode = mkOption {
type = str;
default = "0644";
};
source = mkOption {
type = path;
};
};
};
in {
options.extern = with lib.types; {
files = mkOption {
type = attrsOf (submodule fileModule);
default = { };
};
};
}

View file

@ -7,11 +7,12 @@
inputs,
...
}: let
inherit (lib.modules) mkOptionDefault;
inherit (lib.modules) mkIf mkOptionDefault;
inherit (lib.trivial) mapNullable;
inherit (std) string;
in {
options = let
inherit (lib.types) str listOf attrs unspecified enum nullOr;
inherit (lib.types) str listOf attrs unspecified enum;
inherit (lib.options) mkOption;
in {
arch = mkOption {
@ -21,7 +22,7 @@ in {
};
type = mkOption {
description = "Operating system type of the host";
type = nullOr (enum ["NixOS" "MacOS" "Darwin" "Linux"]);
type = enum ["NixOS" "MacOS" "Darwin" "Linux"];
default = "NixOS";
};
folder = mkOption {
@ -34,6 +35,7 @@ in {
};
modules = mkOption {
type = listOf unspecified;
default = [ ];
};
specialArgs = mkOption {
type = attrs;
@ -67,7 +69,7 @@ in {
linux = "linux";
}
.${string.toLower config.type};
modules = [
modules = mkIf (config.folder != "linux") [
# per-OS modules
meta.modules.${config.folder}
# per-OS configuration
@ -92,10 +94,10 @@ in {
darwin = inputs.darwin.lib.darwinSystem;
macos = inputs.darwin.lib.darwinSystem;
}
.${string.toLower config.type};
built = mkOptionDefault (config.builder {
.${string.toLower config.type} or null;
built = mkOptionDefault (mapNullable (builder: builder {
inherit (config) system modules specialArgs;
});
}) config.builder);
specialArgs = {
inherit name inputs std meta;
systemType = config.folder;

View file

@ -1,5 +1,5 @@
_: {
type = null;
type = "Linux";
proxmox = {
vm = {
id = 202;
@ -15,4 +15,14 @@ _: {
net1.internal.enable = true;
};
};
extern.files = {
"/etc/NetworkManager/system-connections/ens18.nmconnection" = {
source = ./ens18.nmconnection;
mode = "0600";
};
"/etc/NetworkManager/system-connections/int.nmconnection" = {
source = ./int.nmconnection;
mode = "0600";
};
};
}

View file

@ -0,0 +1,20 @@
[connection]
id=ens18
uuid=ee7fba03-49fa-3474-acf6-a9c2c591c098
type=ethernet
autoconnect-priority=-999
interface-name=ens18
timestamp=1706677871
[ethernet]
[ipv4]
address1=10.1.1.46/24,10.1.1.1
dns=1.1.1.1;
method=manual
[ipv6]
addr-gen-mode=eui64
method=auto
[proxy]

View file

@ -0,0 +1,12 @@
[connection]
id=int
type=ethernet
interface-name=ens19
[ipv4]
address1=10.9.1.170/24
may-fail=true
method=manual
[ipv6]
address1=fd0c::aa/64
may-fail=true
method=manual

View file

@ -1,5 +1,5 @@
_: {
type = null;
type = "Linux";
proxmox = {
vm = {
id = 203;

View file

@ -0,0 +1,11 @@
_: {
type = "Linux";
extern.files = {
"/etc/dhcpcd.conf" = {
source = ./dhcpcd.conf;
};
"/etc/motion/motion.conf" = {
source = ./motion.conf;
};
};
}

View file

@ -0,0 +1,9 @@
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option interface_mtu
require dhcp_server_identifier
slaac hwaddr

View file

@ -0,0 +1,37 @@
log_file /tmp/motion
daemon off
setup_mode off
log_level 6
target_dir /var/lib/motion
videodevice /dev/video0
v4l2_palette 8
width 640
height 480
framerate 5
text_left kitchen
text_right %Y-%m-%d\n%T-%q
emulate_motion off
threshold 1500
despeckle_filter EedDl
minimum_motion_frames 1
event_gap 60
pre_capture 3
post_capture 0
picture_output off
picture_filename %Y%m%d%H%M%S-%q
movie_output off
movie_max_time 60
movie_quality 45
movie_codec mkv
movie_filename %t-%v-%Y%m%d%H%M%S
webcontrol_port 8080
webcontrol_localhost off
webcontrol_parms 0
stream_port 41081
stream_localhost off
ipv6_enabled on

View file

@ -1,3 +1,3 @@
_: {
type = null;
type = "Linux";
}

View file

@ -61,6 +61,7 @@
"modules/meta".functor.enable = true;
"modules/system".functor.enable = true;
"modules/system/proxmox".functor.enable = true;
"modules/system/extern".functor.enable = true;
"modules/home".functor.enable = true;
"modules/type".functor.enable = true;
"nixos/*".functor = {