diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 96691791..a4bfa7fc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,6 +40,7 @@ jobs: machines: ${{vars.MACHINES || env.default_machines}} package: ${{vars.PACKAGE || !contains(github.ref, 'refs/pull/')}} publish: ${{vars.PUBLISH || !contains(github.ref, 'refs/pull/')}} + build_nix: ${{vars.BUILD_NIX || !contains(github.ref, 'refs/pull/')}} build_pkgs: ${{vars.BUILD_PKGS || github.ref == 'refs/heads/main' || contains(github.ref, 'tags/v')}} check_pkgs: ${{vars.CHECK_PKGS || 'false'}} complement: ${{vars.COMPLEMENT || 'true'}} @@ -168,6 +169,7 @@ jobs: needs: [init, lint] uses: ./.github/workflows/test.yml with: + build_nix: ${{fromJSON(needs.init.outputs.build_nix)}} rust_sdk_integration: ${{fromJSON(needs.init.outputs.rust_sdk_integration)}} complement: ${{fromJSON(needs.init.outputs.complement)}} complement_runner: ${{needs.init.outputs.complement_runner}} @@ -223,6 +225,7 @@ jobs: release_url: ${{needs.init.outputs.release_url}} check_pkgs: ${{needs.init.outputs.check_pkgs}} build_pkgs: ${{needs.init.outputs.build_pkgs}} + build_nix: ${{fromJSON(needs.init.outputs.build_nix)}} cargo_profiles: ${{needs.init.outputs.cargo_profiles}} feat_sets: ${{needs.init.outputs.feat_sets}} rust_toolchains: ${{needs.init.outputs.rust_toolchains}} diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 330a9bf6..08574e2d 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -44,6 +44,9 @@ on: check_pkgs: type: string default: 'false' + build_nix: + type: string + default: 'true' jobs: book: @@ -144,6 +147,41 @@ jobs: } } + nix: + if: > + !failure() && !cancelled() + && contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0]) + && contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0]) + && contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0]) + && fromJSON(inputs.build_pkgs) + && fromJSON(inputs.build_nix) + && false + + name: NixOS Package + uses: ./.github/workflows/bake.yml + with: + bake_targets: '["nix"]' + cargo_profiles: '["release"]' + feat_sets: '["all"]' + rust_toolchains: '["stable"]' + sys_names: ${{inputs.sys_names}} + sys_versions: ${{inputs.sys_versions}} + rust_targets: ${{inputs.rust_targets}} + sys_targets: ${{inputs.sys_targets}} + machines: ${{inputs.machines}} + excludes: ${{inputs.excludes}} + includes: ${{inputs.includes}} + release_url: ${{inputs.release_url}} + artifact: > + { + "nix": { + "dst": "tuwunel.drv.tar.zst", + "src": "/opt/tuwunel/tuwunel.drv" + "mime": "application/zstd", + "zstd": 6, + }, + } + pkgs: if: > !failure() && !cancelled() diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f29405a..bfb601a3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,6 +46,9 @@ on: rust_sdk_integration: type: boolean default: true + build_nix: + type: boolean + default: true jobs: docs: @@ -163,6 +166,30 @@ jobs: {"sys_target": "x86_64-v4-linux-gnu", "bake_target": "smoke-valgrind"}, ] + nix: + if: > + !failure() && !cancelled() + && contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0]) + && contains(fromJSON(inputs.complement_feat_sets), fromJSON('["all"]')[0]) + && contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0]) + && contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0]) + && fromJSON(inputs.build_nix) + + name: Smoke NixOS + uses: ./.github/workflows/bake.yml + with: + bake_targets: '["smoke-nix"]' + cargo_profiles: '["release"]' + feat_sets: '["all"]' + rust_toolchains: '["stable"]' + sys_names: ${{inputs.sys_names}} + sys_versions: ${{inputs.sys_versions}} + rust_targets: ${{inputs.rust_targets}} + sys_targets: '["x86_64-v1-linux-gnu"]' + machines: ${{inputs.machines}} + excludes: ${{inputs.excludes}} + includes: ${{inputs.includes}} + rust-sdk-integration: if: > !failure() && !cancelled() diff --git a/docker/Dockerfile.nix b/docker/Dockerfile.nix new file mode 100644 index 00000000..f9beb623 --- /dev/null +++ b/docker/Dockerfile.nix @@ -0,0 +1,87 @@ +# syntax = docker/dockerfile:1.11-labs + +FROM input AS nix-base +ARG sys_name +ARG sys_version +ARG sys_target + +WORKDIR / +COPY --link --from=input . . +RUN \ +--mount=type=cache,dst=/nix,sharing=shared \ +--mount=type=cache,dst=/root/.cache/nix,sharing=shared \ +--mount=type=cache,dst=/root/.local/state/nix,sharing=shared \ +< nix-install + sh ./nix-install --daemon + rm nix-install +EOF + + +FROM nix-base AS build-nix +ARG sys_name +ARG sys_version +ARG sys_target + +WORKDIR /usr/src/tuwunel +COPY --link --from=source /usr/src/tuwunel . +RUN \ +--mount=type=cache,dst=/nix,sharing=shared \ +--mount=type=cache,dst=/root/.cache/nix,sharing=shared \ +--mount=type=cache,dst=/root/.local/state/nix,sharing=shared \ +<