merge lib/hosts.nix into lib/machines.nix

This commit is contained in:
stupidcomputer 2024-12-31 11:48:50 -06:00
parent 606de89b8c
commit 053ce2b76b
5 changed files with 52 additions and 20 deletions

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }: { pkgs, lib, machines, ... }:
{ {
imports = [ imports = [
@ -17,8 +17,13 @@
networkmanager.enable = true; networkmanager.enable = true;
firewall.allowedTCPPorts = [ 24800 ]; firewall.allowedTCPPorts = [ 24800 ];
hosts = { hosts = lib.attrsets.mergeAttrsList [
"127.0.0.1" = [ "news.ycombinator.com" ]; # i'm finally free (machines.mkHosts machines "router" "localnet")
(machines.mkHosts machines "copernicus" "localnet")
(machines.mkHosts machines "phone" "localnet")
(machines.mkHosts machines "netbox" "internet")
] // {
"127.0.0.1" = [ "news.ycombinator.com" ];
}; };
}; };
hardware = { hardware = {
@ -35,7 +40,6 @@
isNormalUser = true; isNormalUser = true;
description = "usr"; description = "usr";
extraGroups = [ "networkmanager" "wheel" "input" ]; extraGroups = [ "networkmanager" "wheel" "input" ];
packages = with pkgs; [];
}; };
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;

View File

@ -1,4 +1,4 @@
{ lib, config, pkgs, ...}: { pkgs, lib, machines, ...}:
{ {
imports = [ imports = [
@ -6,7 +6,6 @@
./nvidia.nix ./nvidia.nix
./services ./services
../../config/copernicus.nix ../../config/copernicus.nix
../../lib/hosts.nix
../../lib/bootstrap.nix ../../lib/bootstrap.nix
]; ];
@ -130,6 +129,12 @@
}; };
}; };
}; };
hosts = lib.attrsets.mergeAttrsList [
(machines.mkHosts machines "aristotle" "localnet")
(machines.mkHosts machines "router" "localnet")
(machines.mkHosts machines "phone" "localnet")
(machines.mkHosts machines "netbox" "internet")
];
}; };
services.getty.autologinUser = "usr"; services.getty.autologinUser = "usr";

View File

@ -1,4 +1,4 @@
{ pkgs, ... }: { pkgs, lib, machines, ... }:
{ {
imports = [ imports = [
@ -115,5 +115,9 @@
}; };
}; };
}; };
hosts = lib.attrsets.mergeAttrsList [
(machines.mkHosts machines "copernicus" "wgnet")
(machines.mkHosts machines "aristotle" "wgnet")
];
}; };
} }

View File

@ -1,13 +0,0 @@
{ lib, config, pkgs, inputs, ...}:
{
networking.hosts = {
"192.168.1.1" = [ "router" ];
"192.168.1.200" = [ "mainsail" ];
"192.168.1.201" = [ "x230t" ];
"192.168.1.202" = [ "mlg" ];
"192.168.1.203" = [ "phone" ];
"149.28.63.115" = [ "netbox" ];
};
}

View File

@ -1,17 +1,49 @@
{ {
router = {
ip-addrs = {
localnet = "192.168.1.1";
};
};
copernicus = { copernicus = {
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILBGh1FHPneg7PCDkhMs2BCJPTIRVJkRTKpOj1w02ydD usr"; pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILBGh1FHPneg7PCDkhMs2BCJPTIRVJkRTKpOj1w02ydD usr";
wg-pubkey = "JlH1X4KRT+B8Uau+qTLtBqyapkbGClIj1db7znU77kc="; wg-pubkey = "JlH1X4KRT+B8Uau+qTLtBqyapkbGClIj1db7znU77kc=";
ip-addrs = {
localnet = "192.168.1.201";
wgnet = "10.100.0.2";
};
}; };
phone = { phone = {
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILuVT5W3kzjzsuMIWk1oeGtL8jZGtAhRSx8dK8oBJQcG u0_a291"; pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILuVT5W3kzjzsuMIWk1oeGtL8jZGtAhRSx8dK8oBJQcG u0_a291";
ip-addrs = {
localnet = "192.168.1.203";
};
}; };
aristotle = { aristotle = {
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKTDyKneaM44I5to883ghEnnPonedCKDbCX+OnrQ9vO5 usr"; pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKTDyKneaM44I5to883ghEnnPonedCKDbCX+OnrQ9vO5 usr";
wg-pubkey = "Sw2yyMhyS8GOCWm1VuGn3Y7cfx606dXOGK5mux8ckQU="; wg-pubkey = "Sw2yyMhyS8GOCWm1VuGn3Y7cfx606dXOGK5mux8ckQU=";
ip-addrs = {
localnet = "192.168.1.202";
wgnet = "10.100.0.3";
};
}; };
netbox = { netbox = {
wg-privkey = ../secrets/netbox-wg-priv.age; wg-privkey = ../secrets/netbox-wg-priv.age;
wg-pubkey = "0fOqAfsYO4HvshMPnlkKL7Z1RChq98hjDr0Q8o7OJFE="; wg-pubkey = "0fOqAfsYO4HvshMPnlkKL7Z1RChq98hjDr0Q8o7OJFE=";
ip-addrs = {
internet = "beepboop.systems";
wgnet = "10.100.0.1";
}; };
};
mkHosts = machines: hostname: network:
builtins.listToAttrs [
{
"name" = (
builtins.getAttr network (
builtins.getAttr hostname machines
).ip-addrs
);
"value" = [ hostname ];
}
];
} }