Skip to content
Draft
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
7 changes: 7 additions & 0 deletions .github/workflows/bm_maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ concurrency:
cancel-in-progress: true

jobs:
nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

build-image:
name: "Build cleanup-bare-metal image"
runs-on: ubuntu-24.04
needs: nix-build
permissions:
contents: read
packages: write
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/check_patches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ on:
- packages/by-name/kata/kata-runtime/0*.patch

jobs:
nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

check-patches:
runs-on: ubuntu-24.04
needs: nix-build
timeout-minutes: 15
permissions:
contents: read
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/docs_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ permissions:
pull-requests: write

jobs:
nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

deploy:
name: Publish docs to GitHub Pages
runs-on: ubuntu-24.04
needs: nix-build
# Prevent the job from running on forked PRs, for security reasons.
if: |
(github.event_name == 'push' && github.ref_name == 'main') ||
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ env:
DO_NOT_TRACK: 1

jobs:
nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

test:
name: "${{ inputs.test-name }}${{ inputs.debug-shell && ' (with debug shell)' || '' }}"
runs-on: ${{ inputs.runner }}
needs: nix-build
permissions:
contents: read
packages: write
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/imagepuller-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ on:
- main

jobs:
nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

run-benchmark:
runs-on: ubuntu-24.04
needs: nix-build
permissions:
contents: read
packages: read
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/k3s_compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ env:
container_registry: ghcr.io/edgelesssys

jobs:
nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

test:
runs-on: ubuntu-24.04
needs: nix-build
permissions:
contents: read
packages: write
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ on:
- ".github/workflows/links.yml"

jobs:
nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

check-links:
name: check external links
runs-on: ubuntu-24.04
needs: nix-build
timeout-minutes: 15
permissions:
contents: read
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/nix_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: build and cache all flake outputs

on:
workflow_call:
secrets:
GITHUB_TOKEN_IN:
required: true
CACHIX_AUTH_TOKEN:
required: true

jobs:
nix-build:
runs-on: ${{ matrix.runner }}
permissions:
contents: read
strategy:
matrix:
include:
- runner: yet-to-be-set-up-nix-build-host
system: x86_64-linux
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- uses: ./.github/actions/setup_nix
with:
githubToken: ${{ secrets.GITHUB_TOKEN_IN || secrets.GITHUB_TOKEN }}
cachixToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: pre-build all flake outputs
run: |
nix build .#matrix.${{ matrix.system }}
7 changes: 7 additions & 0 deletions .github/workflows/pr_release_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ on:
default: false

jobs:
nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

create-release-artifacts:
name: Create release artifacts for PR
if: github.event_name == 'workflow_dispatch' && github.event.inputs.cleanup == 'false'
runs-on: ubuntu-24.04
needs: nix-build
permissions:
pull-requests: write
issues: write
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,16 @@ jobs:
exit 1
fi

nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

update-main:
name: Update main branch
runs-on: ubuntu-24.04
needs: [process-inputs, release]
needs: [process-inputs, release, nix-build]
permissions:
contents: write
env:
Expand Down Expand Up @@ -220,7 +226,7 @@ jobs:
release:
name: Build and push artifacts, create release
runs-on: ubuntu-24.04
needs: process-inputs
needs: [process-inputs, nix-build]
permissions:
contents: write
packages: write
Expand Down Expand Up @@ -311,7 +317,7 @@ jobs:
# Job needs content:write to see draft releases.
contents: write
packages: read
needs: [process-inputs, release]
needs: [process-inputs, release, nix-build]
env:
VERSION: ${{ inputs.version }}
steps:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/rim_updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ on:
- cron: "0 18 * * 0"

jobs:
nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

update-rim-ids:
name: update NVIDIA RIM IDs
runs-on: ubuntu-24.04
needs: nix-build
timeout-minutes: 20
permissions:
contents: read
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ on:
pull_request:

jobs:
nix-build:
uses: ./.github/workflows/nix_build.yml
secrets:
GITHUB_TOKEN_IN: ${{ secrets.GITHUB_TOKEN_IN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

flake-check:
runs-on: ubuntu-24.04
needs: nix-build
timeout-minutes: 15
permissions:
contents: read
Expand All @@ -27,6 +34,7 @@ jobs:

generate:
runs-on: ubuntu-24.04
needs: nix-build
timeout-minutes: 60
permissions:
contents: write
Expand All @@ -52,6 +60,7 @@ jobs:

govulncheck:
runs-on: ubuntu-24.04
needs: nix-build
timeout-minutes: 15
permissions:
contents: read
Expand All @@ -69,6 +78,7 @@ jobs:

golangci-lint:
runs-on: ubuntu-24.04
needs: nix-build
timeout-minutes: 15
permissions:
contents: read
Expand All @@ -86,6 +96,7 @@ jobs:

go-licenses:
runs-on: ubuntu-24.04
needs: nix-build
timeout-minutes: 15
permissions:
contents: read
Expand Down
5 changes: 4 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@
overlays = [
(final: _prev: { fenix = self.inputs.fenix.packages.${final.stdenv.hostPlatform.system}; })
(import ./overlays/nixpkgs.nix)
(import ./overlays/contrast.nix)
(import ./overlays/contrast.nix { inherit (self) inputs; })
];
config.allowUnfree = true;
config.nvidia.acceptLicense = true;
};
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
inherit (pkgs) lib;
in

{
Expand All @@ -57,6 +58,8 @@
"contrastPkgs"
];
};

matrix = pkgs.writeText "output-matrix.json" (builtins.toJSON (lib.ci.allOutputs self system));
}
);

Expand Down
22 changes: 22 additions & 0 deletions lib/ci.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ lib, ... }:
rec {
fromPackageOutputs =
flake: system:
lib.concatMap (kind: lib.attrValues (lib.attrByPath [ kind system ] { } flake)) [
"legacyPackages"
"packages"
"checks"
"devShells"
"formatters"
];

allOutputs =
flake: system:
lib.filter lib.isDerivation (
lib.unique (
lib.concatMap (from: from flake system) [
fromPackageOutputs
]
)
);
}
12 changes: 12 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ inputs }:

let
mkLib =
nixpkgs:
nixpkgs.lib.extend (
self: _: {
ci = import ./ci.nix { lib = self; };
}
);
in
mkLib inputs.nixpkgs
3 changes: 3 additions & 0 deletions overlays/contrast.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Copyright 2024 Edgeless Systems GmbH
# SPDX-License-Identifier: BUSL-1.1

{ inputs }:

final: _prev:

{
contrastPkgs = import ../packages { pkgs = final; };
lib = import ../lib { inherit inputs; };
}
4 changes: 0 additions & 4 deletions packages/contrast-releases.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"contrast": [
{
"version": "v0.2.0",
"hash": "sha256-cGyWvUmL/rbjX3Bu1OPGTZlk5PgVW/O0qdo9KmZPo+U="
},
{
"version": "v0.3.0",
"hash": "sha256-8yVZLhwf2bsWIMxSAqXUKDNCjltCSGA6bwrXTi+cJB0="
Expand Down
42 changes: 42 additions & 0 deletions packages/scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -809,4 +809,46 @@ lib.makeScope pkgs.newScope (scripts: {
echo "$timestamp $digest"
'';
};

# Shows which derivations' dependency changes cause rebuilds
show-input-diff = writeShellApplication {
name = "show-input-diff";
runtimeInputs = with pkgs; [
nix-diff
jq
];
text = ''
maxDepth=999
new_args=()
while [[ $# -gt 0 ]]; do
case $1 in
--max-depth)
maxDepth="$2"
shift 2
;;
--max-depth=*)
maxDepth="''${1#*=}"
shift
;;
*)
new_args+=("$1")
shift
;;
esac
done
set -- "''${new_args[@]}"

left=$(nix eval --raw "''${1:-"github:edgelesssys/contrast#matrix.x86_64-linux"}.drvPath" | tr -d '\n')
right=$(nix eval --raw "''${2:-".#matrix.x86_64-linux"}.drvPath" | tr -d '\n')
nix-diff "$left" "$right" --json | jq -r --argjson maxDepth "$maxDepth" '
def printTree(level):
(
select(.drvName != null and .drvName != "") | (" " * level) + .drvName,
(.drvNames // [] | .[] | (" " * (level + 1)) + .),
(if level + 1 < $maxDepth then (.drvDiff.inputsDiff.inputDerivationDiffs // [] | .[] | printTree(level + 1)) else empty end)
);
.inputsDiff.inputDerivationDiffs[] | printTree(0)
'
'';
};
})
Loading
Loading