From 5cb378f61bf5891d6d5a03ac18b4d04f35bdad06 Mon Sep 17 00:00:00 2001 From: Pyrox Date: Tue, 9 Jul 2024 16:01:22 -0400 Subject: [PATCH] [flake] add nix-search and topology --- flake.lock | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 44 +++++++++--- topology.nix | 78 +++++++++++++++++++++ 3 files changed, 303 insertions(+), 11 deletions(-) create mode 100644 topology.nix diff --git a/flake.lock b/flake.lock index fe5446a5..da6aae6a 100644 --- a/flake.lock +++ b/flake.lock @@ -276,6 +276,28 @@ "type": "github" } }, + "devshell": { + "inputs": { + "flake-utils": "flake-utils_4", + "nixpkgs": [ + "topology", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713532798, + "narHash": "sha256-wtBhsdMJA3Wa32Wtm1eeo84GejtI43pMrFrmwLXrsEc=", + "owner": "numtide", + "repo": "devshell", + "rev": "12e914740a25ea1891ec619bb53cf5e6ca922e40", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "dns": { "inputs": { "flake-utils": [ @@ -384,6 +406,22 @@ "type": "github" } }, + "flake-compat_5": { + "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": { "inputs": { "nixpkgs-lib": [ @@ -538,6 +576,24 @@ "inputs": { "systems": "systems_4" }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_5": { + "inputs": { + "systems": "systems_5" + }, "locked": { "lastModified": 1710146030, "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", @@ -638,6 +694,28 @@ "type": "github" } }, + "gitignore_3": { + "inputs": { + "nixpkgs": [ + "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" + } + }, "golink": { "inputs": { "flake-utils": [ @@ -740,7 +818,7 @@ }, "lib-aggregate": { "inputs": { - "flake-utils": "flake-utils_4", + "flake-utils": "flake-utils_5", "nixpkgs-lib": "nixpkgs-lib_2" }, "locked": { @@ -1087,6 +1165,32 @@ "type": "github" } }, + "nix-search": { + "inputs": { + "flake-compat": [ + "flake-compat" + ], + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1720284519, + "narHash": "sha256-GAGgfUXXgXdxZOtoJ9kE9Kby/7mthcSA/1Oh7nR3o0U=", + "owner": "diamondburned", + "repo": "nix-search", + "rev": "b075a39227150cce4af9452621c0eb5ce92790f0", + "type": "github" + }, + "original": { + "owner": "diamondburned", + "repo": "nix-search", + "type": "github" + } + }, "nixd": { "inputs": { "flake-parts": [ @@ -1227,6 +1331,22 @@ "type": "github" } }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1710695816, + "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "614b4613980a522ba49f0d194531beddbb7220d3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1719285171, @@ -1361,6 +1481,34 @@ "type": "github" } }, + "pre-commit-hooks_2": { + "inputs": { + "flake-compat": "flake-compat_5", + "flake-utils": [ + "topology", + "flake-utils" + ], + "gitignore": "gitignore_3", + "nixpkgs": [ + "topology", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable_2" + }, + "locked": { + "lastModified": 1714478972, + "narHash": "sha256-q//cgb52vv81uOuwz1LaXElp3XAe1TqrABXODAEF6Sk=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "2849da033884f54822af194400f8dff435ada242", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "prismlauncher": { "inputs": { "flake-compat": [ @@ -1414,6 +1562,7 @@ "nh": "nh", "nix-index": "nix-index", "nix-index-database": "nix-index-database", + "nix-search": "nix-search", "nixd": "nixd", "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs_2", @@ -1425,6 +1574,7 @@ "snowfall-lib": "snowfall-lib", "stable": "stable", "systems": "systems_3", + "topology": "topology", "wayland": "wayland" } }, @@ -1542,6 +1692,46 @@ "type": "github" } }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "topology": { + "inputs": { + "devshell": "devshell", + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks_2" + }, + "locked": { + "lastModified": 1715634843, + "narHash": "sha256-YrECYhEXY7g8Ji5luq8mdRaLRGiwTPCSDEeVP91DyDY=", + "owner": "oddlama", + "repo": "nix-topology", + "rev": "9ed5c7b5c5cd5bed9e204e8b9d69f4be1954abd3", + "type": "github" + }, + "original": { + "owner": "oddlama", + "repo": "nix-topology", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 43cdf768..98ad2e9b 100644 --- a/flake.nix +++ b/flake.nix @@ -137,6 +137,12 @@ inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; + nix-search = { + url = "github:diamondburned/nix-search"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + inputs.flake-compat.follows = "flake-compat"; + }; nixos-generators = { url = "github:nix-community/nixos-generators"; inputs.nixpkgs.follows = "nixpkgs"; @@ -181,6 +187,11 @@ url = "git+https://git.pyrox.dev/pyrox/pkgs"; inputs.nixpkgs.follows = "nixpkgs"; }; + topology = { + url = "github:oddlama/nix-topology"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; wayland = { url = "github:nix-community/nixpkgs-wayland"; inputs = { @@ -204,14 +215,6 @@ namespace = "py"; }; }; - in - lib.mkFlake { - # Nixpkgs configuration - channels-config = { - allowUnfree = true; - }; - - # Overlays for Nixpkgs. overlays = [ self.overlays.pyronet-packages self.overlays.nix-index @@ -222,8 +225,18 @@ inputs.nixd.overlays.default inputs.nur.overlay inputs.prismlauncher.overlays.default + inputs.topology.overlays.default inputs.wayland.overlays.default ]; + in + lib.mkFlake { + # Nixpkgs configuration + channels-config = { + allowUnfree = true; + }; + + # Overlays for Nixpkgs. + inherit overlays; # Home-manager configurations homes = { @@ -242,6 +255,7 @@ buildbot-nix.nixosModules.buildbot-worker ctp.nixosModules.catppuccin lix-module.nixosModules.default + topology.nixosModules.default ]; hosts = { # Zaphod, my personal Framework 16 laptop @@ -274,13 +288,23 @@ # Export packages and systems as checks for buildbot-nix checks = let - pkgs = channels.nixpkgs; - inherit (pkgs) system; + inherit (channels.nixpkgs) system; packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self.packages.${system}; devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self.devShells.${system}; in packages // devShells; }; deploy = lib.mkDeploy { inherit (inputs) self; }; + topology = import inputs.topology { + pkgs = import inputs.nixpkgs { + inherit overlays; + system = "x86_64-linux"; + }; + modules = [ + ./topology.nix + { nixosConfigurations = self.nixosConfigurations; } + ]; + }; + }; } diff --git a/topology.nix b/topology.nix new file mode 100644 index 00000000..493f725e --- /dev/null +++ b/topology.nix @@ -0,0 +1,78 @@ +{ config, ... }: +let + inherit (config.lib.topology) mkInternet mkConnection; + mkTS = addresses: { + inherit addresses; + network = "tailscale"; + virtual = true; + }; +in +{ + topology = { + + }; + nodes.internet = mkInternet { + connections = [ + (mkConnection "marvin" "wlp41s0") + (mkConnection "prefect" "enp1s0") + (mkConnection "thought" "enp1s0") + (mkConnection "zaphod" "wlp1s0") + ]; + }; + networks.tailscale = { + name = "Tailscale"; + cidrv4 = "100.64.0.0/10"; + cidrv6 = "fd7a:115c:a1e0::/96"; + }; + nodes = { + marvin = { + interfaces.enp42s0 = { + renderer.hidePhysicalConnections = true; + }; + interfaces.tailscale0 = + mkTS [ + "100.123.15.72" + "\n" + "fd7a:115c:a1e0:ab12:4843:cd96:627b:f48" + ] + // { + physicalConnections = [ + (mkConnection "prefect" "tailscale0") + (mkConnection "marvin" "tailscale0") + ]; + }; + }; + zaphod = { + interfaces = { + vboxnet0.virtual = true; + tailscale0 = + mkTS [ + "100.125.9.36" + "" + "fd7a:115c:a1e0:ab12:4843:cd96:627d:924" + ] + // { + physicalConnections = [ + (mkConnection "prefect" "tailscale0") + (mkConnection "marvin" "tailscale0") + ]; + }; + }; + }; + prefect = { + interfaces.tailscale0 = + mkTS [ + "100.93.63.54" + "\n" + "fd7a:115c:a1e0:ab12:4843:cd96:625d:3f36" + ] + // { + physicalConnections = [ + (mkConnection "marvin" "tailscale0") + (mkConnection "zaphod" "tailscale0") + ]; + }; + }; + thought = { }; + }; +} -- 2.54.0