setup nix-topology

This commit is contained in:
2025-05-30 01:25:08 +02:00
parent a0c2c41d17
commit aab09abc52
10 changed files with 262 additions and 0 deletions

143
flake.lock generated
View File

@@ -105,6 +105,27 @@
"url": "https://git.clan.lol/clan/data-mesher/archive/main.tar.gz" "url": "https://git.clan.lol/clan/data-mesher/archive/main.tar.gz"
} }
}, },
"devshell": {
"inputs": {
"nixpkgs": [
"nix-topology",
"nixpkgs"
]
},
"locked": {
"lastModified": 1728330715,
"narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=",
"owner": "numtide",
"repo": "devshell",
"rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"disko": { "disko": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -146,6 +167,22 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
@@ -188,6 +225,46 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"inputs": {
"systems": "systems_4"
},
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"nix-topology",
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"gvc": { "gvc": {
"flake": false, "flake": false,
"locked": { "locked": {
@@ -317,6 +394,29 @@
"url": "https://git.clan.lol/clan/nix-select/archive/main.tar.gz" "url": "https://git.clan.lol/clan/nix-select/archive/main.tar.gz"
} }
}, },
"nix-topology": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
],
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1744142264,
"narHash": "sha256-h5KyodobZm8dx/HSNN+basgdmjxrQxudjrss4gAQpZk=",
"owner": "oddlama",
"repo": "nix-topology",
"rev": "f49121cbbf4a86c560638ade406d99ee58deb7aa",
"type": "github"
},
"original": {
"owner": "oddlama",
"repo": "nix-topology",
"type": "github"
}
},
"nixlib": { "nixlib": {
"locked": { "locked": {
"lastModified": 1736643958, "lastModified": 1736643958,
@@ -414,6 +514,33 @@
"type": "github" "type": "github"
} }
}, },
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nix-topology",
"nixpkgs"
],
"nixpkgs-stable": [
"nix-topology",
"nixpkgs"
]
},
"locked": {
"lastModified": 1730797577,
"narHash": "sha256-SrID5yVpyUfknUTGWgYkTyvdr9J1LxUym4om3SVGPkg=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "1864030ed24a2b8b4e4d386a5eeaf0c5369e50a9",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
@@ -422,6 +549,7 @@
"home-manager": "home-manager_2", "home-manager": "home-manager_2",
"ignis": "ignis", "ignis": "ignis",
"impermanence": "impermanence", "impermanence": "impermanence",
"nix-topology": "nix-topology",
"nixos-generators": "nixos-generators", "nixos-generators": "nixos-generators",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
@@ -493,6 +621,21 @@
"type": "github" "type": "github"
} }
}, },
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": { "treefmt-nix": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [

View File

@@ -92,6 +92,29 @@
}; };
} }
); );
topology =
nixpkgs.lib.genAttrs
[
"x86_64-linux"
"aarch64-linux"
]
(
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ inputs.nix-topology.overlays.default ];
};
in
import inputs.nix-topology {
inherit pkgs;
modules = [
{ inherit (self) nixosConfigurations; }
./topology.nix
];
}
);
}; };
inputs = { inputs = {
@@ -127,6 +150,10 @@
url = "github:linkfrg/ignis"; url = "github:linkfrg/ignis";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nix-topology = {
url = "github:oddlama/nix-topology";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
nixConfig = { nixConfig = {

View File

@@ -12,6 +12,7 @@
inputs.clan-core.clanModules.state-version inputs.clan-core.clanModules.state-version
../../modules/remote-builder.nix ../../modules/remote-builder.nix
../../modules/borgbackup.nix ../../modules/borgbackup.nix
./topology.nix
]; ];
nixpkgs.hostPlatform = "x86_64-linux"; nixpkgs.hostPlatform = "x86_64-linux";

View File

@@ -0,0 +1,11 @@
{
topology.self = {
hardware.info = "x86_64 VPS";
interfaces = {
tailscale0 = {
type = "wireguard";
network = "tailscale";
};
};
};
}

View File

@@ -19,6 +19,7 @@
./nginx.nix ./nginx.nix
./syncthing.nix ./syncthing.nix
./taskchampion.nix ./taskchampion.nix
./topology.nix
../../system ../../system
../../modules/borgbackup.nix ../../modules/borgbackup.nix

View File

@@ -0,0 +1,24 @@
{ config, ... }:
let
inherit (config.lib.topology)
mkConnection
;
in
{
topology.self = {
hardware.info = "Raspberry Pi 4B";
interfaces = {
tailscale0 = {
type = "wireguard";
network = "tailscale";
};
enp1s0 = {
type = "ethernet";
network = "home";
physicalConnections = [
(mkConnection "cassoulet" "eth1")
];
};
};
};
}

View File

@@ -18,6 +18,7 @@
./thunderbird.nix ./thunderbird.nix
./network.nix ./network.nix
./syncthing.nix ./syncthing.nix
./topology.nix
./video.nix ./video.nix
../../system ../../system

View File

@@ -0,0 +1,12 @@
{
topology.self = {
hardware.info = "VivoBook Laptop";
interfaces = {
tailscale0 = {
type = "wireguard";
network = "tailscale";
virtual = true;
};
};
};
}

View File

@@ -1,5 +1,7 @@
{ inputs, ... }:
{ {
imports = [ imports = [
inputs.nix-topology.nixosModules.default
./tailscale.nix ./tailscale.nix
]; ];
} }

40
topology.nix Normal file
View File

@@ -0,0 +1,40 @@
{ config, ... }:
let
inherit (config.lib.topology)
mkConnection
mkInternet
mkRouter
;
in
{
nodes.internet = mkInternet {
connections = [
(mkConnection "cassoulet" "wan1")
(mkConnection "crocus" "enp1s0")
];
};
nodes.cassoulet = mkRouter "Cassoulet" {
info = "BBox Fibre";
interfaceGroups = [
[ "wan1" ]
[
"eth1"
"eth2"
"eth3"
"eth4"
]
];
};
networks.home = {
name = "Home Network";
cidrv4 = "192.168.1.1/24";
};
networks.tailscale = {
name = "Tailscale";
cidrv4 = "100.100.181.10/32";
cidrv6 = "fd7a:115c:a1e0::2401:b50a/128";
};
}