Skip to content

Commit 20cc90d

Browse files
committed
bump nixos version
* adds omadad support
1 parent 529627a commit 20cc90d

File tree

12 files changed

+276
-23
lines changed

12 files changed

+276
-23
lines changed

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/services/omadad/default.nix

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ in {
1717

1818
user = mkOption {
1919
default = defaultUser;
20-
example = "john";
20+
example = "omadad";
2121
type = types.str;
2222
description = ''
2323
The name of an existing user account to use to own the omadad server
@@ -27,7 +27,7 @@ in {
2727

2828
group = mkOption {
2929
default = defaultUser;
30-
example = "john";
30+
example = "omadad";
3131
type = types.str;
3232
description = ''
3333
Group to own the omadad server process.
@@ -36,7 +36,7 @@ in {
3636

3737
dataDir = mkOption {
3838
default = "/var/lib/omadad/";
39-
example = "/home/john/.omadad/";
39+
example = "/home/omadad/.omadad/";
4040
type = types.path;
4141
description = ''
4242
The state directory for omadad.
@@ -69,6 +69,14 @@ in {
6969
'';
7070
};
7171

72+
mongodb = mkOption {
73+
type = types.package;
74+
default = pkgs.mongodb-4_4;
75+
description = ''
76+
mongodb package
77+
'';
78+
};
79+
7280
openFirewall = mkOption {
7381
type = types.bool;
7482
default = false;
@@ -85,16 +93,16 @@ in {
8593
description = "Wifi access point controller";
8694
wantedBy = [ "multi-user.target" ];
8795
after = [ "network-online.target" ];
88-
path = [ pkgs.bash pkgs.mongodb pkgs.nettools pkgs.curl pkgs.procps ];
96+
path = [ pkgs.bash cfg.mongodb pkgs.nettools pkgs.curl pkgs.procps ];
8997

9098
serviceConfig = let
91-
java_opts = "-classpath '${cfg.dataDir}/lib/*' -server -Xms128m -Xmx1024m -XX:MaxHeapFreeRatio=60 -XX:MinHeapFreeRatio=30 -XX:+HeapDumpOnOutOfMemoryError -DhttpPort=${toString cfg.httpPort} -DhttpsPort=${toString cfg.httpsPort} -DmongoPort=${toString cfg.mongoPort} -DdataDir=${cfg.dataDir}/data -Deap.home=${cfg.dataDir} --add-opens=java.base/sun.security.x509=ALL-UNNAMED";
99+
java_opts = "-classpath '${cfg.dataDir}/lib/*' -server -Xms128m -Xmx1024m -XX:MaxHeapFreeRatio=60 -XX:MinHeapFreeRatio=30 -XX:+HeapDumpOnOutOfMemoryError -DhttpPort=${toString cfg.httpPort} -DhttpsPort=${toString cfg.httpsPort} -DmongoPort=${toString cfg.mongoPort} -DdataDir=${cfg.dataDir}/data -Deap.home=${cfg.dataDir}";
92100
main_class = "com.tplink.smb.omada.starter.OmadaLinuxMain";
93101
in {
94102
Type = "simple";
95103
User = cfg.user;
96104
Group = cfg.group;
97-
ExecStart = "${pkgs.jre}/bin/java ${java_opts} ${main_class}";
105+
ExecStart = "${pkgs.openjdk8}/bin/java ${java_opts} ${main_class}";
98106
WorkingDirectory = "${cfg.dataDir}/data";
99107
};
100108

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# MongoDB keeps track of its build parameters, which tricks nix into
2+
# keeping dependencies to build inputs in the final output.
3+
# We remove the build flags from buildInfo data.
4+
--- a/site_scons/mongo/generators.py
5+
+++ b/site_scons/mongo/generators.py
6+
@@ -18,10 +18,7 @@ def default_buildinfo_environment_data():
7+
('distmod', '$MONGO_DISTMOD', True, True,),
8+
('distarch', '$MONGO_DISTARCH', True, True,),
9+
('cc', '$CC_VERSION', True, False,),
10+
- ('ccflags', '$CCFLAGS', True, False,),
11+
('cxx', '$CXX_VERSION', True, False,),
12+
- ('cxxflags', '$CXXFLAGS', True, False,),
13+
- ('linkflags', '$LINKFLAGS', True, False,),
14+
('target_arch', '$TARGET_ARCH', True, True,),
15+
('target_os', '$TARGET_OS', True, False,),
16+
)
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
{ lib
2+
, stdenv
3+
, fetchurl
4+
, sconsPackages
5+
, boost
6+
, gperftools
7+
, pcre-cpp
8+
, snappy
9+
, zlib
10+
, yaml-cpp
11+
, sasl
12+
, openssl
13+
, libpcap
14+
, python3
15+
, curl
16+
, Security
17+
, CoreFoundation
18+
, cctools
19+
, xz
20+
}:
21+
22+
# Note:
23+
# The command line administrative tools are part of other packages:
24+
# see pkgs.mongodb-tools and pkgs.mongosh.
25+
26+
with lib;
27+
28+
{ version, sha256, patches ? []
29+
, license ? lib.licenses.sspl
30+
}:
31+
32+
let
33+
variants =
34+
if versionAtLeast version "6.0" then rec {
35+
python = scons.python.withPackages (ps: with ps; [
36+
pyyaml
37+
cheetah3
38+
psutil
39+
setuptools
40+
packaging
41+
pymongo
42+
]);
43+
44+
scons = sconsPackages.scons_3_1_2;
45+
46+
mozjsVersion = "60";
47+
mozjsReplace = "defined(HAVE___SINCOS)";
48+
49+
} else rec {
50+
python = scons.python.withPackages (ps: with ps; [
51+
pyyaml
52+
cheetah3
53+
psutil
54+
setuptools
55+
]);
56+
57+
scons = sconsPackages.scons_3_1_2;
58+
59+
mozjsVersion = "60";
60+
mozjsReplace = "defined(HAVE___SINCOS)";
61+
62+
};
63+
64+
system-libraries = [
65+
"boost"
66+
"pcre"
67+
"snappy"
68+
"yaml"
69+
"zlib"
70+
#"asio" -- XXX use package?
71+
#"stemmer" -- not nice to package yet (no versioning, no makefile, no shared libs).
72+
#"valgrind" -- mongodb only requires valgrind.h, which is vendored in the source.
73+
#"wiredtiger"
74+
] ++ optionals stdenv.isLinux [ "tcmalloc" ];
75+
inherit (lib) systems subtractLists;
76+
77+
in stdenv.mkDerivation rec {
78+
inherit version;
79+
pname = "mongodb";
80+
81+
src = fetchurl {
82+
url = "https://fastdl.mongodb.org/src/mongodb-src-r${version}.tar.gz";
83+
inherit sha256;
84+
};
85+
86+
nativeBuildInputs = [ variants.scons ]
87+
++ lib.optionals (versionAtLeast version "4.4") [ xz ];
88+
89+
buildInputs = [
90+
boost
91+
curl
92+
gperftools
93+
libpcap
94+
yaml-cpp
95+
openssl
96+
pcre-cpp
97+
variants.python
98+
sasl
99+
snappy
100+
zlib
101+
] ++ lib.optionals stdenv.isDarwin [ Security CoreFoundation cctools ];
102+
103+
# MongoDB keeps track of its build parameters, which tricks nix into
104+
# keeping dependencies to build inputs in the final output.
105+
# We remove the build flags from buildInfo data.
106+
inherit patches;
107+
108+
postPatch = ''
109+
# fix environment variable reading
110+
substituteInPlace SConstruct \
111+
--replace "env = Environment(" "env = Environment(ENV = os.environ,"
112+
'' + lib.optionalString (versionAtLeast version "4.4") ''
113+
# Fix debug gcc 11 and clang 12 builds on Fedora
114+
# https://github.com/mongodb/mongo/commit/e78b2bf6eaa0c43bd76dbb841add167b443d2bb0.patch
115+
substituteInPlace src/mongo/db/query/plan_summary_stats.h --replace '#include <string>' '#include <optional>
116+
#include <string>'
117+
substituteInPlace src/mongo/db/exec/plan_stats.h --replace '#include <string>' '#include <optional>
118+
#include <string>'
119+
'' + lib.optionalString (versionOlder version "5.0") ''
120+
# remove -march overriding, we know better.
121+
sed -i 's/env.Append.*-march=.*$/pass/' SConstruct
122+
'' + lib.optionalString (stdenv.isDarwin && versionOlder version "6.0") ''
123+
substituteInPlace src/third_party/mozjs-${variants.mozjsVersion}/extract/js/src/jsmath.cpp --replace '${variants.mozjsReplace}' 0
124+
'' + lib.optionalString (stdenv.isDarwin && versionOlder version "3.6") ''
125+
substituteInPlace src/third_party/s2/s1angle.cc --replace drem remainder
126+
substituteInPlace src/third_party/s2/s1interval.cc --replace drem remainder
127+
substituteInPlace src/third_party/s2/s2cap.cc --replace drem remainder
128+
substituteInPlace src/third_party/s2/s2latlng.cc --replace drem remainder
129+
substituteInPlace src/third_party/s2/s2latlngrect.cc --replace drem remainder
130+
'' + lib.optionalString stdenv.isi686 ''
131+
132+
# don't fail by default on i686
133+
substituteInPlace src/mongo/db/storage/storage_options.h \
134+
--replace 'engine("wiredTiger")' 'engine("mmapv1")'
135+
'';
136+
137+
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang
138+
"-Wno-unused-command-line-argument";
139+
140+
sconsFlags = [
141+
"--release"
142+
"--ssl"
143+
#"--rocksdb" # Don't have this packaged yet
144+
"--wiredtiger=on"
145+
"--js-engine=mozjs"
146+
"--use-sasl-client"
147+
"--disable-warnings-as-errors"
148+
"VARIANT_DIR=nixos" # Needed so we don't produce argument lists that are too long for gcc / ld
149+
] ++ lib.optionals (versionAtLeast version "4.4") [ "--link-model=static" ]
150+
++ map (lib: "--use-system-${lib}") system-libraries;
151+
152+
preBuild = ''
153+
sconsFlags+=" CC=$CC"
154+
sconsFlags+=" CXX=$CXX"
155+
'' + optionalString stdenv.isAarch64 ''
156+
sconsFlags+=" CCFLAGS='-march=armv8-a+crc'"
157+
'';
158+
159+
preInstall = ''
160+
mkdir -p "$out/lib"
161+
'';
162+
163+
postInstall = ''
164+
rm -f "$out/bin/install_compass" || true
165+
'';
166+
167+
doInstallCheck = true;
168+
installCheckPhase = ''
169+
runHook preInstallCheck
170+
"$out/bin/mongo" --version
171+
runHook postInstallCheck
172+
'';
173+
174+
installTargets =
175+
if (versionAtLeast version "6.0") then "install-devcore"
176+
else if (versionAtLeast version "4.4") then "install-core"
177+
else "install";
178+
179+
prefixKey = if (versionAtLeast version "4.4") then "DESTDIR=" else "--prefix=";
180+
181+
enableParallelBuilding = true;
182+
183+
hardeningEnable = [ "pie" ];
184+
185+
meta = {
186+
description = "A scalable, high-performance, open source NoSQL database";
187+
homepage = "http://www.mongodb.org";
188+
inherit license;
189+
190+
maintainers = with maintainers; [ bluescreen303 offline cstrahan ];
191+
platforms = subtractLists systems.doubles.i686 systems.doubles.unix;
192+
broken = (versionOlder version "6.0" && stdenv.system == "aarch64-darwin");
193+
};
194+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{ stdenv, callPackage, lib, boost }:
2+
3+
let
4+
buildMongoDB = callPackage ./mongodb.nix {
5+
inherit boost;
6+
};
7+
in buildMongoDB {
8+
version = "3.6.23";
9+
sha256 = "sha256-EJpIerW4zcGJvHfqJ65fG8yNsLRlUnRkvYfC+jkoFJ4=";
10+
patches = [ ./forget-build-dependencies.patch ];
11+
}

modules/services/omadad/package.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{ stdenv, lib, fetchurl, mongodb }: let
22

3-
version = "5.7.4";
4-
year = "2022";
5-
month = "11";
3+
version = "5.9.31";
4+
year = "2023";
5+
month = "03";
66
day = "21";
77
url = "https://static.tp-link.com/upload/software/${year}/${year}${month}/${year}${month}${day}/Omada_SDN_Controller_v${version}_Linux_x64.tar.gz";
88
src = fetchurl {
99
inherit url;
10-
sha256 = "sha256-6xG80bOFoJg3DXe00zw4t9QOfw/ADrHjowWHUtQtj0s=";
10+
sha256 = "sha256-rSrioNDgzCJES5YneklHIYpropgvNsU141cqNZAghww=";
1111
};
1212

1313

nixos/colmena.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
, ...
55
}:
66
let
7-
mkNode = server: ip: fast:
8-
self.nixosConfigurations."${server}" // {
9-
deployment.targetHost = ip;
10-
deployment.targetPort = 22;
11-
deployment.targetUser = "root";
7+
mkNode = server: ip: fast: {
8+
imports = [self.nixosConfigurations."${server}".config];
9+
deployment.targetHost = ip;
10+
deployment.targetPort = 22;
11+
deployment.targetUser = "root";
1212
};
1313
in
1414
{

nixos/deploy.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ in
1616
sshUser = "root";
1717
nodes = {
1818
optina = mkNode "optina" "10.40.33.20" true;
19-
portal = mkNode "portal" "10.40.33.1" true;
19+
portal = mkNode "portal" "prophet.samleathers.com" true;
2020
sarov = mkNode "sarov" "10.40.33.183" true;
2121
valaam = mkNode "valaam" "10.40.33.21" true;
2222
prod01 = mkNode "prod01" "45.76.4.212" false;

nixos/optina/configuration.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@ in
371371
passwordFile = config.sops.secrets.gitea_dbpass.path;
372372
};
373373
};
374-
mongodb.enable = true;
374+
#mongodb.enable = true;
375375
omadad = {
376-
enable = false;
376+
enable = true;
377377
httpPort = 8089;
378378
httpsPort = 10443;
379379
};

nixos/optina/minecraft-bedrock.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{ stdenv, fetchurl, patchelf, openssl, unzip, lib, zlib, curl }:
22

33
let
4-
version = "1.19.51.01";
5-
sha256 = "sha256-ZzSlPYM8On0xTsifQgC4GE14g0lBDAImYtYGM3/BYZ0=";
4+
version = "1.20.0.01";
5+
sha256 = "sha256-pm/bu8rcAUlNFlWsm1f4+RGWmF6LxOhMT8am0a1PNF4=";
66
rpath = lib.makeLibraryPath [ zlib openssl stdenv.cc.cc curl ];
77
in
88
stdenv.mkDerivation rec {

0 commit comments

Comments
 (0)