iowa-city-mesh-config/flake.nix

54 lines
2.2 KiB
Nix
Raw Normal View History

2022-05-27 17:12:26 +02:00
{
inputs.openwrt-imagebuilder.url =
"github:IowaCityMesh/nix-openwrt-imagebuilder";
outputs = { self, nixpkgs, openwrt-imagebuilder }:
2022-05-28 19:37:23 +02:00
let
inherit (nixpkgs) lib;
sshAuthorizedKeys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCqAXBEROEfldkHdUbF3TinBhfeX5l4DQ/5MAOhLh09avqCqcHY2FanZN+qmWpD695UZ71Cl+XF6Bj0KO7Rt4SAemvkEDPMBoidkt+ZjLsdnb8GVvbDhu/62JnqW9meYTN5GcjfmKMPDtKFbgSx9PPcjsDaO6LI/GWeyTz+EYQqwTdc7TKffjLXp6bREYLf0oKIBTvW9/oPCBI7ywYmyBaadFKrYSnujJbMejH91L+JN2fJoxjjhsGcRR78ottbjz4q6JxYjt9CG5oa7Lm60xdZkiiA3c4dMuHU9+EWGshjBKL1Fb9BafeAKhHobcs7UG8IVlqHRJC5VAGQlmus/fNagAArz9PnGW4MAOgg+yLjQJLLKqePBMsAsMHZ9XT+sqPyJfcai5dWynGXFP1B63C/oosVMkeZAlBIwDz/CmufpKBCJZXCfFoC3PotWsH/JT3ir/RSdtVHQ169CEgm+AUd7gjBuRwn6j2eBHcYkn0nCbQ93KLPlnYCLXzjByGved8= emery@zuni"
];
2022-05-27 17:12:26 +02:00
in {
packages = lib.attrsets.mapAttrs (system: pkgs:
let
profiles = openwrt-imagebuilder.lib.profiles { inherit pkgs; };
2022-05-28 19:37:23 +02:00
2022-05-27 17:12:26 +02:00
customConfig = {
# add package to include in the image, ie. packages that you don't
# want to install manually later
2022-05-28 19:37:23 +02:00
packages = [ ];
2022-05-27 17:12:26 +02:00
2022-05-28 19:37:23 +02:00
disabledServices = [ ]; # dnsmasq
2022-05-27 17:12:26 +02:00
# include files in the images.
# to set UCI configuration, create a uci-defauts scripts as per
# official OpenWRT ImageBuilder recommendation.
files = pkgs.runCommandNoCC "image-files" { } ''
mkdir -p $out/etc/uci-defaults
2022-05-28 19:37:23 +02:00
cat > $out/etc/uci-defaults/99-custom << EOF
2022-05-27 17:12:26 +02:00
uci -q batch << EOI
set system.@system[0].hostname='meshic-testrouter'
2022-05-28 19:37:23 +02:00
set wireless.@wifi-iface[0].ssid='MeshIC'
2022-05-27 17:12:26 +02:00
commit
EOI
EOF
2022-05-28 19:37:23 +02:00
mkdir -p $out/etc/dropbear
cat > $out/etc/dropbear/authorized_keys << EOF
${lib.strings.concatStringsSep "\n" sshAuthorizedKeys}
EOF
2022-05-27 17:12:26 +02:00
'';
};
in {
trendnet_tew-691gr = openwrt-imagebuilder.lib.build
(profiles.identifyProfile "trendnet_tew-691gr" // customConfig);
}) { inherit (nixpkgs.legacyPackages) x86_64-linux; };
2022-05-28 19:37:23 +02:00
hydraJobs = self.packages.x86_64-linux;
2022-05-27 17:12:26 +02:00
};
}