summary refs log tree commit diff
path: root/.github
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-08-31 22:41:09 +0200
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-09-05 16:10:50 +0200
commitf6467c357419d70d8f32816fe68b9bde6278f8b0 (patch)
tree9215a2a77dc61588e91aa9aa4f911660e5dda064 /.github
parentbb34f4d1a6a7fc413b5e695ebefd0ebfc6e6c77e (diff)
downloadnixpkgs-f6467c357419d70d8f32816fe68b9bde6278f8b0.tar
nixpkgs-f6467c357419d70d8f32816fe68b9bde6278f8b0.tar.gz
nixpkgs-f6467c357419d70d8f32816fe68b9bde6278f8b0.tar.bz2
nixpkgs-f6467c357419d70d8f32816fe68b9bde6278f8b0.tar.lz
nixpkgs-f6467c357419d70d8f32816fe68b9bde6278f8b0.tar.xz
nixpkgs-f6467c357419d70d8f32816fe68b9bde6278f8b0.tar.zst
nixpkgs-f6467c357419d70d8f32816fe68b9bde6278f8b0.zip
pkgs/by-name: Introduce
This introduces the `pkgs/by-name` directory as proposed by RFC 140.
Included are:
- The implementation to add packages defined in that directory to the
  top-level package scope
- Contributer documentation on how to add packages to it
- A GitHub Actions workflow to check the structure of it on all PRs
Diffstat (limited to '.github')
-rw-r--r--.github/CODEOWNERS3
-rw-r--r--.github/workflows/check-by-name.yml49
2 files changed, 52 insertions, 0 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index f5679a1a142..79ba7b7c520 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -49,6 +49,9 @@
 
 # pkgs/by-name
 /pkgs/test/nixpkgs-check-by-name @infinisil
+/pkgs/by-name/README.md @infinisil
+/pkgs/top-level/by-name-overlay.nix @infinisil
+/.github/workflows/check-by-name.nix @infinisil
 
 # Nixpkgs build-support
 /pkgs/build-support/writers @lassulus @Profpatsch
diff --git a/.github/workflows/check-by-name.yml b/.github/workflows/check-by-name.yml
new file mode 100644
index 00000000000..9622634fcff
--- /dev/null
+++ b/.github/workflows/check-by-name.yml
@@ -0,0 +1,49 @@
+# Checks pkgs/by-name (see pkgs/by-name/README.md)
+# using the nixpkgs-check-by-name tool (see pkgs/test/nixpkgs-check-by-name)
+name: Check pkgs/by-name
+
+# The pre-built tool is fetched from a channel,
+# making it work predictable on all PRs
+on: pull_request
+
+# The tool doesn't need any permissions, it only outputs success or not based on the checkout
+permissions: {}
+
+jobs:
+  check:
+    # This is x86_64-linux, for which the tool is always prebuilt on the nixos-* channels,
+    # as specified in nixos/release-combined.nix
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: cachix/install-nix-action@v22
+      - name: Determining channel to use for dependencies
+        run: |
+          echo "Determining which channel to use for PR base branch $GITHUB_BASE_REF"
+          if [[ "$GITHUB_BASE_REF" =~ ^(release|staging|staging-next)-([0-9][0-9]\.[0-9][0-9])$ ]]; then
+              # Use the release channel for all PRs to release-XX.YY, staging-XX.YY and staging-next-XX.YY
+              channel=nixos-${BASH_REMATCH[2]}
+              echo "PR is for a release branch, using release channel $channel"
+          else
+              # Use the nixos-unstable channel for all other PRs
+              channel=nixos-unstable
+              echo "PR is for a non-release branch, using unstable channel $channel"
+          fi
+          echo "channel=$channel" >> "$GITHUB_ENV"
+      - name: Fetching latest version of channel
+        run: |
+          echo "Fetching latest version of channel $channel"
+          # This is probably the easiest way to get Nix to output the path to a downloaded channel!
+          nixpkgs=$(nix-instantiate --find-file nixpkgs -I nixpkgs=channel:"$channel")
+          # This file only exists in channels
+          rev=$(<"$nixpkgs"/.git-revision)
+          echo "Channel $channel is at revision $rev"
+          echo "nixpkgs=$nixpkgs" >> "$GITHUB_ENV"
+          echo "rev=$rev" >> "$GITHUB_ENV"
+      - name: Fetching pre-built nixpkgs-check-by-name from the channel
+        run: |
+          echo "Fetching pre-built nixpkgs-check-by-name from channel $channel at revision $rev"
+          # Passing --max-jobs 0 makes sure that we won't build anything
+          nix-build "$nixpkgs" -A tests.nixpkgs-check-by-name --max-jobs 0
+      - name: Running nixpkgs-check-by-name
+        run: result/bin/nixpkgs-check-by-name .