2173b4e9c0
lastFile:flake.nix
170 lines
5.5 KiB
Nix
170 lines
5.5 KiB
Nix
{
|
|
description = "Clan flake for controlling NewEdge infrastructure.";
|
|
inputs = {
|
|
clan-core = {
|
|
url = "git+https://git.clan.lol/clan/clan-core";
|
|
inputs.flake-parts.follows = "flake-parts";
|
|
inputs.treefmt-nix.follows = "treefmt-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
devshell = {
|
|
url = "github:numtide/devshell";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
flake-parts = {
|
|
inputs.nixpkgs-lib.follows = "nixpkgs";
|
|
url = "github:hercules-ci/flake-parts";
|
|
};
|
|
home-manager = {
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
url = "github:nix-community/home-manager";
|
|
};
|
|
plasma-manager = {
|
|
url = "github:nix-community/plasma-manager";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
inputs.home-manager.follows = "home-manager";
|
|
};
|
|
import-tree.url = "github:vic/import-tree";
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
|
openwrt-imagebuilder = {
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
inputs.flake-parts.follows = "flake-parts";
|
|
url = "github:astro/nix-openwrt-imagebuilder";
|
|
};
|
|
treefmt-nix = {
|
|
url = "github:numtide/treefmt-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
liminix = {
|
|
url = "git+https://gti.telent.net/dan/liminix";
|
|
flake = false;
|
|
};
|
|
frappix = {
|
|
url = "github:kurogeek/frappix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
inputs.devshell.follows = "devshell";
|
|
};
|
|
};
|
|
outputs =
|
|
{
|
|
flake-parts,
|
|
...
|
|
}@inputs:
|
|
flake-parts.lib.mkFlake { inherit inputs; } (
|
|
{ ... }:
|
|
{
|
|
systems = [
|
|
"x86_64-linux"
|
|
];
|
|
imports = [
|
|
./fmt.nix
|
|
./shell.nix
|
|
|
|
./overlays
|
|
./modules/nixos
|
|
./machines
|
|
./routers
|
|
./inventories
|
|
./overlays
|
|
./tests
|
|
./modules/clan/flake-module.nix
|
|
./modules/nixos/flake-module.nix
|
|
];
|
|
perSystem =
|
|
{ pkgs, system, ... }:
|
|
{
|
|
_module.args.pkgs = import inputs.nixpkgs {
|
|
inherit system;
|
|
overlays = [
|
|
inputs.self.overlays.packagesOverlay
|
|
];
|
|
config = { };
|
|
};
|
|
packages.think = pkgs.think-gtcm;
|
|
packages.think-be = pkgs.think-backend-gtcm;
|
|
packages.file-uploader = pkgs.gtcm-file-uploader;
|
|
};
|
|
|
|
flake.packages.x86_64-linux.myrouter =
|
|
let
|
|
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
|
|
profiles = inputs.openwrt-imagebuilder.lib.profiles { inherit pkgs; };
|
|
config = profiles.identifyProfile "glinet_gl-mt6000" // {
|
|
# add package to include in the image, ie. packages that you don't
|
|
# want to install manually later
|
|
packages = [
|
|
"tcpdump"
|
|
"relayd"
|
|
"luci-proto-relay"
|
|
];
|
|
|
|
disabledServices = [ ];
|
|
|
|
# include files in the images.
|
|
# to set UCI configuration, create a uci-defauts scripts as per
|
|
# official OpenWRT ImageBuilder recommendation.
|
|
files =
|
|
let
|
|
router-config = {
|
|
upstream-wifi = {
|
|
ssid = "Glom";
|
|
password = "";
|
|
};
|
|
};
|
|
in
|
|
pkgs.runCommand "image-files" { } ''
|
|
|
|
mkdir -p $out/etc/uci-defaults
|
|
cat > $out/etc/uci-defaults/99-custom <<EOF
|
|
uci -q batch << EOI
|
|
set system.@system[0].hostname='flint'
|
|
commit
|
|
EOI
|
|
|
|
# Add a new wifi-iface for the upstream network (station mode)
|
|
uci set wireless.wwan=wifi-iface
|
|
uci set wireless.wwan.device='radio0' # or radio1 for 5GHz
|
|
uci set wireless.wwan.mode='sta'
|
|
uci set wireless.wwan.network='wwan'
|
|
uci set wireless.wwan.ssid='${router-config.upstream-wifi.ssid}'
|
|
uci set wireless.wwan.encryption='psk2' # use 'psk' for WPA, 'none' for open
|
|
uci set wireless.wwan.key='${router-config.upstream-wifi.password}'
|
|
uci commit wireless
|
|
|
|
uci set network.wwan=interface
|
|
uci set network.wwan.proto='dhcp'
|
|
uci commit network
|
|
|
|
uci set network.relay=interface
|
|
uci set network.relay.proto='relay'
|
|
uci set network.relay.network='lan wwan' # bridges LAN and upstream
|
|
uci commit network
|
|
|
|
# Edit the existing AP or add a new one:
|
|
uci set wireless.default_radio0.ssid='YourRepeaterSSID'
|
|
uci set wireless.default_radio0.encryption='psk2'
|
|
uci set wireless.default_radio0.key='YourRepeaterPassword'
|
|
uci commit wireless
|
|
|
|
uci set dhcp.lan.ignore='1'
|
|
uci commit dhcp
|
|
|
|
uci set firewall.@zone[1].network='wan wan6 wwan'
|
|
uci commit firewall
|
|
|
|
/etc/init.d/relayd enable
|
|
/etc/init.d/relayd start
|
|
/etc/init.d/network restart
|
|
|
|
/etc/init.d/firewall restart
|
|
wifi
|
|
|
|
EOF
|
|
'';
|
|
};
|
|
in
|
|
inputs.openwrt-imagebuilder.lib.build config;
|
|
}
|
|
);
|
|
}
|