Skip to content

Instantly share code, notes, and snippets.

@ungeskriptet
Last active July 2, 2025 18:57
Show Gist options
  • Save ungeskriptet/e9c3ba8a806bd264076a5aebb486748e to your computer and use it in GitHub Desktop.
Save ungeskriptet/e9c3ba8a806bd264076a5aebb486748e to your computer and use it in GitHub Desktop.
{pkgs ? import <nixpkgs> {}}: let
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
ln -sf ${pkgs.gcc.cc}/bin/{,*-gnu-}gcc-{ar,nm,ranlib} $out/bin
'';
fhs = pkgs.buildFHSEnv {
name = "openwrt-env";
targetPkgs = pkgs:
with pkgs; [
bc
fixWrapper
binutils
bison
ccache
curl
elfutils
file
flex
fontconfig
freetype
gcc
git
git-lfs
git-repo
glibc.static
gnumake
gnupg
gperf
imagemagick
jdk11
libxcrypt-legacy
libxml2
libxslt
lz4
lzop
m4
ncurses
nettools
openssl
openssl.dev
patch
perl
pkg-config
pngcrush
procps
python3
rsync
schedtool
SDL
squashfsTools
subversion
swig
systemd
unzip
util-linux
wget
which
xml2
yaml-cpp
zip
zlib
zlib.static
zsh
];
runScript = "zsh"; # personal preference, you could set this to bash instead if you want
extraOutputsToInstall = [ "dev" ];
profile = ''
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.ncurses}/lib
export PKG_CONFIG_PATH="${pkgs.ncurses.dev}/lib/pkgconfig";
'';
};
in
pkgs.stdenv.mkDerivation {
name = "openwrt-env-shell";
nativeBuildInputs = [fhs pkgs.python3Packages.setuptools];
shellHook = "exec openwrt-env";
hardeningDisable = [ "all" ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment