Skip to content
Merged
Show file tree
Hide file tree
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
File renamed without changes.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Usage

```shell
nix develop -c $SHELL
mkosi --force
mkosi --force -I buildernet.conf
```

> Note: Make sure the above command is not run with sudo, as this will clear necessary environment variables set by the nix shell
Expand Down
38 changes: 38 additions & 0 deletions scripts/make_git_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
#
# Note env variables: DESTDIR, BUILDROOT, GOCACHE

make_git_package() {
local package="$1"
local version="$2"
local git_url="$3"
local build_cmd="$4"
# All remaining arguments are artifact mappings in src:dest format

mkdir -p "$DESTDIR/usr/bin"

# Clone the repository
local build_dir="$BUILDROOT/build/$package"
git clone --depth 1 --branch "$version" "$git_url" "$build_dir"

# Build inside mkosi chroot with custom build command
mkosi-chroot bash -c "cd '/build/$package' && $build_cmd"

# Process each artifact mapping
for artifact_map in "${@:5}"; do
# Split the mapping into source and destination
local src=$(echo "$artifact_map" | cut -d':' -f1)
local dest=$(echo "$artifact_map" | cut -d':' -f2)

# Create destination directory if needed
mkdir -p "$(dirname "$DESTDIR$dest")"

# Copy the artifact
cp "$build_dir/$src" "$DESTDIR$dest"
done
}

# Example usage:
# make_git_package "myapp" "v1.0.0" "https://github.com/user/myapp.git" "make build" \
# "bin/myapp:/usr/bin/myapp" \
# "config/myapp.conf:/etc/myapp/myapp.conf"
4 changes: 4 additions & 0 deletions tdx-dummy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Config]
Include=base/base.conf
Include=tdx-dummy/tdx-dummy.conf
Include=devtools/devtools.conf
17 changes: 17 additions & 0 deletions tdx-dummy/dummy-tdx-dcap.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=Dummy TDX DCAP server
After=network-setup.service
Wants=network-setup.service

[Service]
Type=exec
User=root
Group=root
ExecStart=/usr/bin/dummy-tdx-dcap --listen-addr 0.0.0.0:8080
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=minimal.target
6 changes: 6 additions & 0 deletions tdx-dummy/mkosi.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -euxo pipefail

source scripts/make_git_package.sh

make_git_package "dummy-tdx-dcap" "v0.0.1" "https://github.com/Ruteri/dummy-tdx-dcap" 'go build -trimpath -ldflags "-s -w -buildid= -X github.com/flashbots/go-template/common.Version=v0.0.1" -v -o ./build/httpserver cmd/httpserver/main.go' "build/httpserver:/usr/bin/dummy-tdx-dcap"
8 changes: 8 additions & 0 deletions tdx-dummy/mkosi.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -euxo pipefail

# Install systemd service units
SERVICE_DIR="$BUILDROOT/etc/systemd/system"
mkdir -p "$SERVICE_DIR"

install -m 644 "tdx-dummy/dummy-tdx-dcap.service" "$SERVICE_DIR/"
7 changes: 7 additions & 0 deletions tdx-dummy/tdx-dummy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Content]
WithNetwork=true
BuildScripts=tdx-dummy/mkosi.build
BuildPackages=ca-certificates
golang-go
git
PostInstallationScripts=tdx-dummy/mkosi.postinst