Skip to content

Commit a6a911e

Browse files
committed
feat: initial project
1 parent 874e050 commit a6a911e

18 files changed

+1084
-2
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!Dockerfile
3+
!bin

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true

.github/renovate.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"github>containerbase/.github",
5+
"github>containerbase/.github//merge-queue.json"
6+
]
7+
}

.github/workflows/build.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
10+
merge_group:
11+
12+
schedule:
13+
- cron: '0 1 * * *'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
17+
cancel-in-progress: true
18+
19+
env:
20+
HUSKY: 0
21+
22+
jobs:
23+
lint:
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 10
26+
steps:
27+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
28+
- run: corepack enable
29+
- run: pnpm install
30+
- run: pnpm prettier
31+
32+
build:
33+
needs:
34+
- lint
35+
runs-on: ubuntu-latest
36+
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
# distro:
41+
# - focal
42+
# - jammy
43+
arch:
44+
- x86_64
45+
# - aarch64
46+
47+
env:
48+
# DISTRO: ${{ matrix.distro }} # build target, name required by binary-builder
49+
ARCH: ${{ matrix.arch }} # build target, name required by binary-builder
50+
51+
steps:
52+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
53+
54+
- name: binary-builder
55+
uses: containerbase/internal-tools@ea879db0cfe20e24636d8010ea1d1b2e9683e167 # v3.4.0
56+
with:
57+
command: binary-builder
58+
dry-run: ${{github.ref != 'refs/heads/main'}}
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
last-only: true

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules/
2+
/.pnpm-store/
3+
4+
/.cache/

.husky/pre-commit

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
lint-staged

.lintstagedrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"*": "prettier --ignore-unknown --write"
3+
}

.npmrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
save-exact = true
2+
save-prefix =
3+
4+
# pnpm run settings
5+
# https://pnpm.io/cli/run
6+
shell-emulator = true

.prettierignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules/
2+
/coverage/
3+
/dist/
4+
/bin/
5+
/tmp/
6+
/html/
7+
/.cache/
8+
9+
10+
# pnpm
11+
pnpm-lock.yaml
12+
/.pnpm-store

.prettierrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"plugins": ["prettier-plugin-packagejson"]
5+
}

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM ghcr.io/containerbase/base:11.9.1@sha256:abc869b6fd4bffbf0ccd107ffc73078bd3e6aeb2ff08858424cdd5810ee920e6
2+
3+
4+
#--------------------------------------
5+
# builder images
6+
#--------------------------------------
7+
# FROM build-${DISTRO} as builder
8+
9+
ARG APT_PROXY
10+
11+
ENTRYPOINT [ "dumb-init", "--", "builder.sh" ]
12+
13+
COPY --chmod=755 bin /usr/local/bin
14+
15+
16+
# renovate: datasource=github-tags packageName=NixOS/nix
17+
RUN install-tool nix 2.24.2
18+
19+
ENV TOOL_NAME=nix
20+
21+
RUN install-builder.sh
22+
23+
WORKDIR /nix
24+

README.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,31 @@
1-
# nix-prebuild
2-
Prebuild static nix binaries for containerbase
1+
# containerbase nix releases
2+
3+
[![build](https://github.com/containerbase/nix-prebuild/actions/workflows/build.yml/badge.svg)](https://github.com/containerbase/nix-prebuild/actions/workflows/build.yml)
4+
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/containerbase/nix-prebuild)
5+
![License: MIT](https://img.shields.io/github/license/containerbase/nix-prebuild)
6+
7+
Prebuild nix releases used by [containerbase/base](https://github.com/containerbase/base).
8+
9+
## Local development
10+
11+
Build the image
12+
13+
```bash
14+
docker build -t builder --build-arg APT_PROXY=http://apt-proxy:3142 --build-arg DISTRO=focal .
15+
```
16+
17+
Test the image
18+
19+
```bash
20+
docker run --rm -it -v ${PWD}/.cache:/cache -e DEBURG=true builder 8.0.3
21+
```
22+
23+
`${PWD}/.cache` will contain packed releases after successful build.
24+
25+
Optional environment variables
26+
27+
| Name | Description | Default |
28+
| ----------- | ------------------------------------------------------------ | --------- |
29+
| `DISTRO` | Set an ubuntu base distro, `focal` and `jammy` are supported | `focal` |
30+
| `APT_PROXY` | Set an APT http proxy for installing build deps | `<empty>` |
31+
| `DEBUG` | Show verbose nix build output | `<empty>` |

bin/builder.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# shellcheck source=/dev/null
6+
. /usr/local/containerbase/util.sh
7+
# shellcheck source=/dev/null
8+
. /usr/local/containerbase/utils/v2/overrides.sh
9+
10+
11+
# trim leading v
12+
TOOL_VERSION=${1#v}
13+
14+
# shellcheck disable=SC1091
15+
#CODENAME=$(. /etc/os-release && echo "${VERSION_CODENAME}")
16+
17+
ARCH=$(uname -p)
18+
19+
20+
check_semver "${TOOL_VERSION}"
21+
22+
echo "Building ${TOOL_NAME} ${TOOL_VERSION} for ${ARCH}"
23+
24+
if [[ "${DEBUG}" == "true" ]]; then
25+
set -x
26+
fi
27+
28+
echo "------------------------"
29+
echo "init repo"
30+
31+
git reset --hard "${TOOL_VERSION}"
32+
33+
34+
echo "------------------------"
35+
echo "build ${TOOL_NAME}"
36+
nix build .#nix-static
37+
38+
mkdir "/usr/local/${TOOL_NAME}/${TOOL_VERSION}/bin"
39+
cp result/bin/nix "/usr/local/${TOOL_NAME}/${TOOL_VERSION}/bin/nix"
40+
41+
echo "------------------------"
42+
echo "testing"
43+
"/usr/local/${TOOL_NAME}/${TOOL_VERSION}/bin/nix" --version
44+
45+
file "/usr/local/${TOOL_NAME}/${TOOL_VERSION}/bin/nix"
46+
#ldd "/usr/local/${TOOL_NAME}/${TOOL_VERSION}/bin/nix"
47+
48+
echo "------------------------"
49+
echo "create archive"
50+
echo "Compressing ${TOOL_NAME} ${TOOL_VERSION} for ${ARCH}"
51+
tar -cJf "/cache/${TOOL_NAME}-${TOOL_VERSION}-${ARCH}.tar.xz" -C "/usr/local/${TOOL_NAME}" "${TOOL_VERSION}"

bin/install-builder.sh

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# shellcheck source=/dev/null
6+
. /usr/local/containerbase/util.sh
7+
# shellcheck source=/dev/null
8+
. /usr/local/containerbase/utils/v2/overrides.sh
9+
10+
11+
mkdir /cache "/usr/local/${TOOL_NAME}"
12+
13+
echo "APT::Install-Recommends \"false\";" | tee -a /etc/apt/apt.conf.d/99buildpack.conf
14+
echo "APT::Get::Upgrade \"false\";" | tee -a /etc/apt/apt.conf.d/99buildpack.conf
15+
echo "APT::Get::Install-Suggests \"false\";" | tee -a /etc/apt/apt.conf.d/99buildpack.conf
16+
17+
if [[ -n "${APT_PROXY}" ]]; then
18+
echo "Acquire::http::proxy \"${APT_PROXY}\";" | tee -a /etc/apt/apt.conf.d/99buildpack-proxy.conf
19+
fi
20+
21+
22+
export DEBIAN_FRONTEND=noninteractive
23+
24+
# apt-get update -q
25+
# apt-get install -q -y \
26+
# autoconf2.13 \
27+
# autoconf2.64 \
28+
# autoconf \
29+
# bison \
30+
# build-essential \
31+
# ca-certificates \
32+
# curl \
33+
# dumb-init \
34+
# git \
35+
# file \
36+
# libbz2-dev \
37+
# libc-client2007e-dev \
38+
# libcurl4-openssl-dev \
39+
# libicu-dev \
40+
# libjpeg-dev \
41+
# libkrb5-dev \
42+
# libmcrypt-dev \
43+
# libonig-dev \
44+
# libpng-dev \
45+
# libreadline-dev \
46+
# libsqlite3-dev \
47+
# libssl-dev \
48+
# libtidy-dev \
49+
# libxml2-dev \
50+
# libxslt-dev \
51+
# libzip-dev \
52+
# pkg-config \
53+
# re2c \
54+
# zlib1g-dev \
55+
# ;
56+
57+
git clone https://github.com/NixOS/nix.git
58+
59+
60+
#--------------------------------
61+
# fixes
62+
#--------------------------------
63+
64+
#ARCH=$(uname -p)
65+
#https://github.com/phpbrew/phpbrew/issues/861#issuecomment-294715448
66+
#ln -s "/usr/include/${ARCH}-linux-gnu/curl" /usr/include/curl
67+
68+
#--------------------------------
69+
# cleanup
70+
#--------------------------------
71+
if [[ -n "${APT_PROXY}" ]]; then
72+
rm -f /etc/apt/apt.conf.d/99buildpack-proxy.conf
73+
fi

builder.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"image": "nix",
3+
"depName": "NixOS/nix",
4+
"datasource": "github-tags",
5+
"versioning": "semver",
6+
"startVersion": "2.0.0",
7+
"ignoredVersions": []
8+
}

package.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "containerbase-nix-prebuild",
3+
"private": true,
4+
"repository": "https://github.com/containerbase/nix-prebuild.git",
5+
"license": "MIT",
6+
"author": "Michael Kriese <[email protected]>",
7+
"scripts": {
8+
"lint": "run-s prettier",
9+
"prepare": "husky",
10+
"prettier": "prettier --cache -c -u '**/*.*'",
11+
"prettier-fix": "prettier --cache -w -u '**/*.*'"
12+
},
13+
"devDependencies": {
14+
"husky": "9.1.4",
15+
"lint-staged": "15.2.8",
16+
"npm-run-all2": "6.2.2",
17+
"prettier": "3.3.3",
18+
"prettier-plugin-packagejson": "2.5.1"
19+
},
20+
"packageManager": "[email protected]",
21+
"engines": {
22+
"node": ">=20.9.0",
23+
"pnpm": "^9.0.0"
24+
}
25+
}

0 commit comments

Comments
 (0)