{ description = "GKleen's flakey openwrt setup"; inputs = { openwrt = { type = "github"; owner = "openwrt"; repo = "openwrt"; ref = "openwrt-21.02"; flake = false; }; flake-utils = { type = "github"; owner = "numtide"; repo = "flake-utils"; ref = "master"; }; nixpkgs = { type = "github"; owner = "NixOS"; repo = "nixpkgs"; ref = "master"; }; }; outputs = { self, openwrt, nixpkgs, flake-utils, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; fixWrapper = pkgs.runCommand "fix-wrapper" {} '' mkdir -p $out/bin for i in ${pkgs.gcc.cc}/bin/*-gnu-gcc*; do ln -s ${pkgs.gcc}/bin/gcc $out/bin/$(basename "$i") done for i in ${pkgs.gcc.cc}/bin/*-gnu-{g++,c++}*; do ln -s ${pkgs.gcc}/bin/g++ $out/bin/$(basename "$i") done ''; fhs = extraAttrs: pkgs.buildFHSUserEnvBubblewrap ({ name = "openwrt-env"; multiPkgs = null; inherit targetPkgs; extraOutputsToInstall = [ "dev" ]; profile = '' export hardeningDisable=all ''; } // extraAttrs); targetPkgs = pkgs: with pkgs; [ binutils file fixWrapper gcc getopt gettext git gnumake openssl patch perl python2 python3 rsync subversion systemd unzip wget which ncurses zlib # zlib.static # glibc.static pkgconfig ]; in { devShell = pkgs.mkShell { name = "openwrt"; shellHook = let setup = pkgs.writeText "setup" '' cd $TMPDIR ${pkgs.rsync}/bin/rsync --chmod D+x,+r,u+w --exclude .keep -rlptD ${openwrt}/. ${./files}/. . find ${./patches} -type f -name '*.patch' -exec patch '{}' ';'; ''; in "exec -- ${fhs { runScript = "bash --init-file ${setup}"; }}/bin/openwrt-env"; }; }); }