Skip to content

Commit

Permalink
Add daed package (#7)
Browse files Browse the repository at this point in the history
* fix: disabled module

* add: daed package

* ci: add daed package build check

* chore: update doc

* chore: clean whitespace

* chore: append daed into default overlay

* chore: remove unuse step

---------

Co-authored-by: dae-bot[bot] <136105375+dae-bot[bot]@users.noreply.github.com>
  • Loading branch information
oluceps and dae-prow[bot] authored Aug 30, 2023
1 parent c44641a commit daccb9d
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ jobs:
run: |
nix build .#packages.x86_64-linux.dae
shell: bash

- name: build daed
run: |
nix build .#packages.x86_64-linux.daed
shell: bash
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ Modify flake.nix
};
};
}
# use package
#...
environment.systemPackages = with inputs.daeuniverse.packages.x86_64-linux; [ dae daed ];
```

## License
Expand Down
2 changes: 1 addition & 1 deletion dae/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildGoModule rec {
owner = "daeuniverse";
repo = pname;
rev = "8bbfd691a7034b6007600ed65547cb84f446d387";
sha256 = "sha256-WiJqhXYehuUCLEuVbsQkmTntuH1srtePtZgYBSTbxiw=";
hash = "sha256-WiJqhXYehuUCLEuVbsQkmTntuH1srtePtZgYBSTbxiw=";
fetchSubmodules = true;
};

Expand Down
105 changes: 105 additions & 0 deletions daed/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{ mkPnpmPackage
, clang
, buildGoModule
, fetchFromGitHub
}:

let
dist = mkPnpmPackage {
src = fetchFromGitHub {
owner = "daeuniverse";
repo = "daed";
fetchSubmodules = true;
rev = "32d1af726298ca033209a1a7b16e6b24f8792de3";
hash = "sha256-t6rPnOjzCM2azfAc7u+KL/Yfw5lNo/m2GcFEGBnZvZE=";
};
};

dae-ebpf = buildGoModule rec {
pname = "dae";
version = "ebpf";

src = fetchFromGitHub {
owner = "daeuniverse";
repo = pname;
rev = "92596cd01e1b90e92b51a2f5dea867010ced6dbe";
hash = "sha256-DY32iX8o4cd/c6IJt+oEYzD8kpocn/Tl5lU15PcoE6M=";
fetchSubmodules = true;
};

vendorHash = "sha256-rZwK+mYWJqgLFhzwZTfCC4tIg2gtNtx7Lu/fyOL3ozA=";

proxyVendor = true;

nativeBuildInputs = [ clang ];

buildPhase = ''
make CFLAGS="-D__REMOVE_BPF_PRINTK -fno-stack-protector" \
NOSTRIP=y \
ebpf
'';
installPhase = ''
mkdir $out
cp -r ./* $out
'';

# network required
doCheck = false;
};


in
buildGoModule rec {
name = "daed";
version = "unstable-2023-08-22";

src = fetchFromGitHub {
owner = "daeuniverse";
repo = "dae-wing";
rev = "bcfba3a71bd1bd55a690a38d5efcd2a31ef43001";
hash = "sha256-LzHXdm98Ny/UFIasPGD08YD/mEX6MRtwFUnk44hnpbU=";
};

vendorHash = "sha256-IGORrj9br8fQyu2m23ukCNFR8M5EHW6spR18B+eowtw=";
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" \
chmod -R 777 webrender
go generate ./...
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
" ';'
'';

tags = [ "embedallowed" ];

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

excludedPackages = [ "dae-core" ];

postInstall = ''
mv $out/bin/dae-wing $out/bin/daed
rm $out/bin/{input,resolver}
'';
}
16 changes: 14 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@
];
systems = [ "x86_64-linux" "aarch64-linux" ];
perSystem = { config, self', inputs', pkgs, system, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = with inputs;[
pnpm2nix.overlays.default
];
};

packages = {
dae = pkgs.callPackage ./dae/package.nix { };
daed = pkgs.callPackage ./daed/package.nix { };
};

checks = {
Expand All @@ -32,9 +40,13 @@
};
flake = {
nixosModules = { dae = import ./dae/module.nix inputs; };
overlays = rec {
default = dae;
overlays = {
default = final: prev: {
dae = inputs.self.packages.dae;
daed = inputs.self.packages.daed;
};
dae = final: prev: { dae = inputs.self.packages.dae; };
daed = final: prev: { daed = inputs.self.packages.daed; };
};
};
};
Expand Down

0 comments on commit daccb9d

Please sign in to comment.