Compare commits
4 commits
d52f45442e
...
fc28547693
Author | SHA1 | Date | |
---|---|---|---|
|
fc28547693 | ||
|
50b22e0dcd | ||
|
dcde00c428 | ||
|
19439ea13a |
7 changed files with 60 additions and 109 deletions
6
machines/router/build.sh
Executable file
6
machines/router/build.sh
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
|
||||||
|
mkdir output/
|
||||||
|
|
||||||
|
nom-build -A outputs.tftpboot -o output/result
|
|
@ -12,7 +12,6 @@ let
|
||||||
inherit (pkgs) serviceFns;
|
inherit (pkgs) serviceFns;
|
||||||
# EDIT: you can pick your preferred RFC1918 address space
|
# EDIT: you can pick your preferred RFC1918 address space
|
||||||
# for NATted connections, if you don't like this one.
|
# for NATted connections, if you don't like this one.
|
||||||
ipv4LocalNet = "192.168.1";
|
|
||||||
svc = config.system.service;
|
svc = config.system.service;
|
||||||
|
|
||||||
in rec {
|
in rec {
|
||||||
|
@ -27,56 +26,18 @@ in rec {
|
||||||
hardware.flash.eraseBlockSize = 126976;
|
hardware.flash.eraseBlockSize = 126976;
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
"${liminix}/modules/bridge"
|
|
||||||
"${liminix}/modules/dhcp6c"
|
|
||||||
"${liminix}/modules/dnsmasq"
|
|
||||||
"${liminix}/modules/firewall"
|
|
||||||
"${liminix}/modules/hostapd"
|
|
||||||
"${liminix}/modules/network"
|
"${liminix}/modules/network"
|
||||||
"${liminix}/modules/ntp"
|
|
||||||
"${liminix}/modules/ssh"
|
"${liminix}/modules/ssh"
|
||||||
"${liminix}/modules/vlan"
|
|
||||||
"${liminix}/modules/wlan.nix"
|
|
||||||
"${liminix}/modules/outputs/ubimage.nix"
|
"${liminix}/modules/outputs/ubimage.nix"
|
||||||
];
|
];
|
||||||
rootfsType = "ubifs";
|
rootfsType = "ubifs";
|
||||||
hostname = "hackens-router"; # EDIT
|
hostname = "hackens-router"; # EDIT
|
||||||
|
|
||||||
services.hostap = svc.hostapd.build {
|
|
||||||
interface = config.hardware.networkInterfaces.wlan;
|
|
||||||
# EDIT: you will want to change the obvious things
|
|
||||||
# here to values of your choice
|
|
||||||
params = {
|
|
||||||
ssid = "The_Game";
|
|
||||||
channel = "1";
|
|
||||||
country_code = "FR";
|
|
||||||
wpa_passphrase = "putainmauricetueschiant";
|
|
||||||
|
|
||||||
hw_mode="g";
|
|
||||||
ieee80211n = 1;
|
|
||||||
auth_algs = 1; # 1=wpa2, 2=wep, 3=both
|
|
||||||
wpa = 2; # 1=wpa, 2=wpa2, 3=both
|
|
||||||
wpa_key_mgmt = "WPA-PSK";
|
|
||||||
wpa_pairwise = "TKIP CCMP"; # auth for wpa (may not need this?)
|
|
||||||
rsn_pairwise = "CCMP"; # auth for wpa2
|
|
||||||
wmm_enabled = 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.int = svc.network.address.build {
|
services.int = svc.network.address.build {
|
||||||
interface = svc.bridge.primary.build { ifname = "int"; };
|
interface = config.hardware.networkInterfaces.wan;
|
||||||
family = "inet"; address = "${ipv4LocalNet}.1"; prefixLength = 16;
|
family = "inet";
|
||||||
};
|
address = "10.0.0.8";
|
||||||
|
prefixLength = 24;
|
||||||
services.bridge = svc.bridge.members.build {
|
|
||||||
primary = services.int;
|
|
||||||
members = with config.hardware.networkInterfaces;
|
|
||||||
[ lan ];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.ntp = svc.ntp.build {
|
|
||||||
pools = { "pool.ntp.org" = ["iburst"]; };
|
|
||||||
makestep = { threshold = 1.0; limit = 3; };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.sshd = svc.ssh.build { };
|
services.sshd = svc.ssh.build { };
|
||||||
|
@ -85,68 +46,6 @@ in rec {
|
||||||
# EDIT: choose a root password and then use
|
# EDIT: choose a root password and then use
|
||||||
# "mkpasswd -m sha512crypt" to determine the hash.
|
# "mkpasswd -m sha512crypt" to determine the hash.
|
||||||
# It should start wirh $6$.
|
# It should start wirh $6$.
|
||||||
passwd = "$6$UnjSEEpbfVAtIs8H$6xLsdpdpc/XvmxiiUtbHLkItuG/jTJuGm9omOLVZnpXzDThyRb6jeGS6W0LqHfNjfeErRwsZQVsvucMG4Iyda1";
|
passwd = "$6$9XlVymX951ai.c2C$SYtEF2Ykcud8VRuLRxfQRfuc9h7oJpVo.xDEv6fTWjBngMj3bPN9GbFMv3r.T.K2wIj1rTo9j1m58G.GTPKWo/";
|
||||||
openssh.authorizedKeys.keys = [
|
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKiXXYkhRh+s7ixZ8rvG8ntIqd6FELQ9hh7HoaHQJRPU Thorkell"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.dns =
|
|
||||||
let interface = services.int;
|
|
||||||
in svc.dnsmasq.build {
|
|
||||||
# resolvconf = services.resolvconf;
|
|
||||||
inherit interface;
|
|
||||||
ranges = [
|
|
||||||
"${ipv4LocalNet}.10,${ipv4LocalNet}.249"
|
|
||||||
# EDIT: ... maybe. In this example we use "ra-stateless",
|
|
||||||
# meaning dnsmasq sends router advertisements with the O and A
|
|
||||||
# bits set, and provides a stateless DHCP service. The client
|
|
||||||
# will use a SLAAC address, and use DHCP for other
|
|
||||||
# configuration information.
|
|
||||||
# If you didn't understand the preceding sentence then
|
|
||||||
# the default is _probably_ fine, but if you need
|
|
||||||
# a DHCP-only IPv6 network or some other different
|
|
||||||
# configuration, this is the place to change it.
|
|
||||||
"::,constructor:$(output ${interface} ifname),ra-stateless"
|
|
||||||
];
|
|
||||||
# EDIT: choose a domain name for the DNS names issued for your
|
|
||||||
# DHCP-issued hosts
|
|
||||||
domain = "lan.hackens.org";
|
|
||||||
};
|
|
||||||
|
|
||||||
#services.resolvconf = oneshot rec {
|
|
||||||
# dependencies = [ services.wan ];
|
|
||||||
# name = "resolvconf";
|
|
||||||
# up = ''
|
|
||||||
# . ${serviceFns}
|
|
||||||
# ( in_outputs ${name}
|
|
||||||
# echo "nameserver $(output ${services.wan} ns1)" > resolv.conf
|
|
||||||
# echo "nameserver $(output ${services.wan} ns2)" >> resolv.conf
|
|
||||||
# chmod 0444 resolv.conf
|
|
||||||
# )
|
|
||||||
# '';
|
|
||||||
#};
|
|
||||||
|
|
||||||
#filesystem =
|
|
||||||
# let inherit (pkgs.pseudofile) dir symlink;
|
|
||||||
# in dir {
|
|
||||||
# etc = dir {
|
|
||||||
# "resolv.conf" = symlink "${services.resolvconf}/.outputs/resolv.conf";
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
|
|
||||||
#services.defaultroute4 = svc.network.route.build {
|
|
||||||
# via = "$(output ${services.wan} address)";
|
|
||||||
# target = "default";
|
|
||||||
# dependencies = [ services.wan ];
|
|
||||||
#};
|
|
||||||
|
|
||||||
# 4A:3D:B6:7F:44:F0
|
|
||||||
# 129.199.146.30
|
|
||||||
|
|
||||||
services.packet_forwarding = svc.network.forward.build { };
|
|
||||||
|
|
||||||
defaultProfile.packages = with pkgs; [
|
|
||||||
min-collect-garbage
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,14 @@
|
||||||
, nixpkgs ? (import ./npins).nixpkgs
|
, nixpkgs ? (import ./npins).nixpkgs
|
||||||
, liminix-config ? ./configuration.nix
|
, liminix-config ? ./configuration.nix
|
||||||
}:
|
}:
|
||||||
(import liminix { inherit nixpkgs liminix-config; device = import (liminix + "/devices/belkin-rt3200"); })
|
let
|
||||||
|
patchedLiminix = pkgs.applyPatches {
|
||||||
|
name = "liminix-patched";
|
||||||
|
src = liminix;
|
||||||
|
patches = [
|
||||||
|
./liminix-dtbsize.patch
|
||||||
|
];
|
||||||
|
};
|
||||||
|
pkgs = import nixpkgs {};
|
||||||
|
in
|
||||||
|
(import patchedLiminix { inherit nixpkgs liminix-config; device = import (patchedLiminix + "/devices/belkin-rt3200"); })
|
||||||
|
|
23
machines/router/liminix-dtbsize.patch
Normal file
23
machines/router/liminix-dtbsize.patch
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
diff --git a/modules/outputs/tftpboot.nix b/modules/outputs/tftpboot.nix
|
||||||
|
index ad6ed63..9773042 100644
|
||||||
|
--- a/modules/outputs/tftpboot.nix
|
||||||
|
+++ b/modules/outputs/tftpboot.nix
|
||||||
|
@@ -73,8 +73,6 @@ in {
|
||||||
|
rootfsStart=${toString cfg.loadAddress}
|
||||||
|
rootfsSize=$(binsize64k ${o.rootfs} )
|
||||||
|
dtbStart=$(($rootfsStart + $rootfsSize))
|
||||||
|
- dtbSize=$(binsize ${o.dtb} )
|
||||||
|
- imageStart=$(($dtbStart + $dtbSize))
|
||||||
|
imageSize=$(binsize ${image})
|
||||||
|
|
||||||
|
ln -s ${o.manifest} manifest
|
||||||
|
@@ -102,6 +100,9 @@ in {
|
||||||
|
fdtput -p -t s dtb /reserved-memory/$node compatible phram
|
||||||
|
fdtput -p -t lx dtb /reserved-memory/$node reg $ac_prefix $(hex $rootfsStart) $sz_prefix $(hex $rootfsSize)
|
||||||
|
|
||||||
|
+ dtbSize=$(binsize ./dtb )
|
||||||
|
+ imageStart=$(($dtbStart + $dtbSize))
|
||||||
|
+
|
||||||
|
cmd="liminix ${cmdline} mtdparts=phram0:''${rootfsSize}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsSize},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0";
|
||||||
|
fdtput -t s dtb /chosen bootargs "$cmd"
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"type": "Channel",
|
"type": "Channel",
|
||||||
"name": "nixpkgs-unstable",
|
"name": "nixpkgs-unstable",
|
||||||
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-24.05pre567370.24fe8bb4f552/nixexprs.tar.xz",
|
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-24.05pre572676.b06ff4bf8f4a/nixexprs.tar.xz",
|
||||||
"hash": "1bflgzw7x8ws2xmiaappxhp331wrvjc2zc77b41ijvsiid8k0l4j"
|
"hash": "1alh0waf9hjhxqnxwkmc6g1fq9h1m498g269yncdnhhkiglg73kx"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version": 3
|
"version": 3
|
||||||
|
|
3
machines/router/serve.sh
Executable file
3
machines/router/serve.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
sudo capsh --keep=1 --user="$USER" --inh='cap_net_bind_service' --addamb='cap_net_bind_service' -- -c 'tftpy_server.py -r ./output'
|
10
machines/router/shell.nix
Normal file
10
machines/router/shell.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
let
|
||||||
|
pkgs = import (import ./npins).nixpkgs {};
|
||||||
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
|
packages = with pkgs; [
|
||||||
|
python3.pkgs.tftpy
|
||||||
|
minicom
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue