Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

daed: refactor & bump to v0.7.0 #104

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 38 additions & 93 deletions daed/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@
}:

let
dist = stdenv.mkDerivation (finalAttrs: {
name = "daed-dist";
pname = "daed-dist";
version = "0.6.0-unstable-2024-06-16";
pname = "daed";
version = "0.7.0";
src = fetchFromGitHub {
owner = "daeuniverse";
repo = "daed";
rev = "refs/tags/v${version}";
hash = "sha256-fck3k0KGSOAmNikrL1C8Bs44pUJJuDtT6UB/aYyCeEg=";
fetchSubmodules = true;
};

web = stdenv.mkDerivation {
inherit pname version src;

src = fetchFromGitHub {
owner = "daeuniverse";
repo = "daed";
fetchSubmodules = true;
rev = "32d1af726298ca033209a1a7b16e6b24f8792de3";
hash = "sha256-t6rPnOjzCM2azfAc7u+KL/Yfw5lNo/m2GcFEGBnZvZE=";
};
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) version src pname;
hash = "sha256-H0VYhK4myqZ5xqwJRJSF2okWN2fUsJUx+RU5fipbM5I=";
inherit pname version src;
hash = "sha256-pNP/Ut5vRE+tqBYNHEkulCIeXnowHAIZKJe73cA0BB0=";
};

nativeBuildInputs = [
nodejs
pnpm.configHook
Expand All @@ -35,104 +37,48 @@ let
pnpm build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
mv dist/* $out/
runHook postInstall
'';
});

dae-ebpf = buildGoModule rec {
pname = "dae";
version = "dae-ebpf-0.6.0-unstable-2024-06-16";

src = fetchFromGitHub {
owner = "daeuniverse";
repo = pname;
rev = "8e9311e0f76da739e51be54905318ca175a4cc53";
hash = "sha256-B4PLEb0HUHBp+C+c4hlTtXp84FWJk/xVpggW/gufcpk=";
fetchSubmodules = true;
};

vendorHash = "sha256-AtYLxR7Fw3+IOSeuPXlq4vMsnS+7MMaFANZDg0yvCl8=";

hardeningDisable = [ "zerocallusedregs" ];

proxyVendor = true;

nativeBuildInputs = [ clang ];

buildPhase = ''
runHook preBuild
make CFLAGS="-D__REMOVE_BPF_PRINTK -fno-stack-protector -Wno-unused-command-line-argument" \
NOSTRIP=y \
ebpf
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir $out
cp -r ./* $out
mkdir -p $out
cp -R dist/* $out/
runHook postInstall
'';

# network required
doCheck = false;
};
in
buildGoModule rec {
name = "daed";
version = "0.6.0-unstable-2024-06-16";

src = fetchFromGitHub {
owner = "daeuniverse";
repo = "dae-wing";
rev = "d832011a0392239ce40e16b08c0fe80bbd1e9ff7";
hash = "sha256-uijsoHm0RgPUpnDaNG8a599MMiBtbgWtjLGUKeSWIDg=";
};
inherit pname version src;
sourceRoot = "${src.name}/wing";

vendorHash = "sha256-zqYYEo33OU+lLNA8sVCm3O4tJoQ8UlRwSrEHYoeqrTc=";
proxyVendor = true;
preBuild = ''
# replace built dae ebpf bindings
rm -r ./dae-core
cp -r ${dae-ebpf} ./dae-core

cp -r ${dist} ./webrender/web

substituteInPlace Makefile \
--replace /bin/bash "/bin/sh" \
nativeBuildInputs = [ clang ];

chmod -R 777 webrender
hardeningDisable = [ "zerocallusedregs" ];

go generate ./...
prePatch = ''
substituteInPlace Makefile \
--replace-fail /bin/bash /bin/sh

find webrender/web -type f -size +4k ! -name "*.gz" ! -name "*.woff" ! -name "*.woff2" -exec sh -c "
echo '{}';
gzip -9 -k '{}';
if [ \$(stat -c %s '{}') -lt \$(stat -c %s '{}.gz') ]; then
rm '{}.gz';
else
rm '{}';
fi
" ';'
# ${web} does not have write permission
mkdir dist
cp -r ${web}/* dist
chmod -R 755 dist
'';

tags = [ "embedallowed" ];

ldflags = [
"-s"
"-w"
"-X github.com/daeuniverse/dae-wing/db.AppVersion=${version}"
"-X github.com/daeuniverse/dae-wing/db.AppName=${name}"
];
buildPhase = ''
runHook preBuild

excludedPackages = [ "dae-core" ];
make CFLAGS="-D__REMOVE_BPF_PRINTK -fno-stack-protector -Wno-unused-command-line-argument" \
NOSTRIP=y \
WEB_DIST=dist \
AppName=${pname} \
VERSION=${version} \
OUTPUT=$out/bin/daed \
bundle

postInstall = ''
mv $out/bin/dae-wing $out/bin/daed
rm $out/bin/{input,resolver}
runHook postBuild
'';

meta = {
Expand All @@ -143,5 +89,4 @@ buildGoModule rec {
platforms = lib.platforms.linux;
mainProgram = "daed";
};

}