Clean files + add IP to hosts

This commit is contained in:
zuma 2025-11-06 22:21:20 +01:00
parent ca436c49a3
commit b6d31e25b9
6 changed files with 140 additions and 110 deletions

View file

@ -1,6 +1,11 @@
{ config, pkgs, lib, ...} @ args: {
with builtins; config,
with lib; pkgs,
lib,
...
}@args:
with builtins;
with lib;
{ {
options.filouterie = with types; { options.filouterie = with types; {
hostName = mkOption { hostName = mkOption {

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ...}: {
config,
lib,
pkgs,
...
}:
{ {
config.filouterie.hostName = "fifi"; config.filouterie.hostName = "fifi";
@ -21,5 +26,5 @@
config.networking.defaultGateway = "192.168.1.1"; config.networking.defaultGateway = "192.168.1.1";
# Setting up bootloader in UEFI mode # Setting up bootloader in UEFI mode
config.boot.loader.grub.devices = [ "nodev"]; config.boot.loader.grub.devices = [ "nodev" ];
} }

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ...}: {
config,
lib,
pkgs,
...
}:
{ {
config.filouterie.hostName = "loulou"; config.filouterie.hostName = "loulou";

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ...}: {
config,
lib,
pkgs,
...
}:
{ {
config.filouterie.hostName = "riri"; config.filouterie.hostName = "riri";

View file

@ -43,18 +43,7 @@ with pkgs.lib;
useXkbConfig = true; # use xkb.options in tty. useXkbConfig = true; # use xkb.options in tty.
}; };
# Define a user account. Don't forget to set a password with passwd.
users.users = { users.users = {
nixos = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user.
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHxRk3bAqq9sRuZD2rBecM9e2XXHnaUQVCkqNjkHrugv zuma@shenanigans.cc"
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDgXUerUE+Q3nRP1NHfNYSFoKeNauYBxYXAQ9+CJy4ZBWbxnQ0lp9GEF/KM2Ww0jdpW0hRUh3UJsnTauseWgSG+wxa0+j+bRj64d44G+f7Q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AveaYoFpLvwBYMBmc6K02Oj3cLIPPQhQQSZ26z8NazHpIgVyQxgWhrckCb/vAi5yxl5htTcJqONTLJBWdKOj2huG16kF7m6NsJ4m8mReoYDOAcaIR1UPVJKALHw82mKdgSlBP/YrN7rTU9woBXt/QoWnWMabNM4YYr1UssiR+NS6fs4yuNZ58MaYsJi1Zlv1Vjwm9bj+rNCmYoXTbpVesn+rXbWZxIAeMqNCsHRQ== achille.toupin@gadz.org"
];
};
zuma = { zuma = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user. extraGroups = [ "wheel" ]; # Enable sudo for the user.
@ -63,7 +52,6 @@ with pkgs.lib;
]; ];
hashedPassword = "$y$j9T$Qc23q8HQZMELvYyubvEoF/$jauiBKEGb65K03/va632gKIuGSR2Cro/CQ1yq5mOjxB"; hashedPassword = "$y$j9T$Qc23q8HQZMELvYyubvEoF/$jauiBKEGb65K03/va632gKIuGSR2Cro/CQ1yq5mOjxB";
}; };
mayel = { mayel = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user. extraGroups = [ "wheel" ]; # Enable sudo for the user.
@ -183,6 +171,11 @@ with pkgs.lib;
fi fi
''; '';
# Sets /etc/hosts to link all hostnames to wireguard IP
networking.extraHosts = concatStringsSep "\n" (
attrValues (mapAttrs (hostname: { address, ... }: "${address} ${hostname}") cfg.clusterNodes)
);
# Open ports in the firewall. # Open ports in the firewall.
networking.firewall = { networking.firewall = {
enable = true; enable = true;

View file

@ -1,14 +1,25 @@
{ config, lib, pkgs, ...}: {
config,
lib,
pkgs,
...
}:
with lib; with lib;
let let
cfg = config.filouterie.services.wgautomesh; cfg = config.filouterie.services.wgautomesh;
in in
with builtins; with builtins;
{ {
options.filouterie.services.wgautomesh = { options.filouterie.services.wgautomesh = {
enable = mkEnableOption "wgautomesh"; enable = mkEnableOption "wgautomesh";
logLevel = mkOption { logLevel = mkOption {
type = types.enum [ "trace" "debug" "info" "warn" "error" ]; type = types.enum [
"trace"
"debug"
"info"
"warn"
"error"
];
default = "info"; default = "info";
description = "wgautomesh log level (trace/debug/info/warn/error)"; description = "wgautomesh log level (trace/debug/info/warn/error)";
}; };
@ -21,7 +32,8 @@ in
description = "wgautomesh gossip port"; description = "wgautomesh gossip port";
}; };
peers = mkOption { peers = mkOption {
type = types.listOf (types.submodule { type = types.listOf (
types.submodule {
options = { options = {
pubkey = mkOption { pubkey = mkOption {
type = types.str; type = types.str;
@ -36,30 +48,34 @@ in
description = "bootstrap endpoint"; description = "bootstrap endpoint";
}; };
}; };
}); }
);
description = "wgautomesh peer list"; description = "wgautomesh peer list";
}; };
}; };
config = mkIf cfg.enable ( config = mkIf cfg.enable (
let let
peerDefs = map (peer: peerDefs = map (
let endpointDef = if peer.endpoint == null then "" peer:
else ''endpoint = "${peer.endpoint}"''; let
endpointDef = if peer.endpoint == null then "" else ''endpoint = "${peer.endpoint}"'';
in in
'' ''
[[peers]] [[peers]]
pubkey = "${peer.pubkey}" pubkey = "${peer.pubkey}"
address = "${peer.address}" address = "${peer.address}"
${endpointDef} ${endpointDef}
'') cfg.peers; ''
) cfg.peers;
configFile = pkgs.writeText "wgautomesh.toml" '' configFile = pkgs.writeText "wgautomesh.toml" ''
interface = "${cfg.interface}" interface = "${cfg.interface}"
gossip_port = ${toString cfg.gossipPort} gossip_port = ${toString cfg.gossipPort}
${concatStringsSep "\n" peerDefs} ${concatStringsSep "\n" peerDefs}
''; '';
in { in
{
systemd.services.wgautomesh = { systemd.services.wgautomesh = {
enable = true; enable = true;
path = [ pkgs.wireguard-tools ]; path = [ pkgs.wireguard-tools ];
@ -83,5 +99,6 @@ in
}; };
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
}; };
});
} }
);
}