blob: 4d18a890bd35bc9233fd922e730618d443955399 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
{
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";
};
});
}
|