Commit Graph

520 Commits

Author SHA1 Message Date
Wolfgang Walther
c8635a8849 ci/pinned: update (#450451) 2025-10-27 07:56:46 +00:00
Winter
1a9867167d ci: add zizmor check and configuration
`zizmor` is a tool that uses static analysis to find potential security
issues in GitHub Actions [0]. (Yes, it's a bit absurd that GitHub
made a CI system so complicated that tools like this were created, but
I digress.)

Given our increase in GHA usage recently, I think this is a good step
towards keeping our security posture in tip-top shape. (It also keeps
with the theme of automating as many things as possible!)

The rule related to the usages of dangerous-triggers have been disabled
to avoid false-positives. Explanations about the usage of
`pull_request_target` and expectations around its usage can be found in
`.github/workflows/README.md`.

[0]: https://woodruffw.github.io/zizmor/

Co-authored-by: Thomas Gerbet <thomas@gerbet.me>
2025-10-26 22:03:12 +01:00
Sergei Zimmerman
b3d75f7b45 ci/pinned: update
This gives us Nix 2.32 for use in CI's Eval job and nixfmt 1.1.0.

From the nixpkgs-unstable channel:
https://hydra.nixos.org/build/311062898#tabs-buildinputs

Changes for treefmt-nix:
5eda4ee812...f56b1934f5

Co-authored-by: Wolfgang Walther <walther@technowledgy.de>
2025-10-24 10:40:42 +02:00
Matt Sturgeon
9ea88ca354 ci/eval/compare/maintainers: simplify meta.position predicate 2025-10-22 21:11:19 +01:00
Wolfgang Walther
6d564102b7 ci/eval/compare/maintainers: fix maintainer pings without meta.position
In a recent change, the path matching was simplified in maintainers.nix.
This revealed a pre-existing logic bug: Packages without `meta.position`
would get an empty string as their file name. The change would then
cause this empty string to always be matched, which lead to maintainer
pings for these packages in seemingly random PRs, when some of their
dependencies were changed.
2025-10-22 21:06:53 +02:00
Wolfgang Walther
5fde0d7e4e ci/README: add github-script policy (#453985) 2025-10-22 12:41:51 +00:00
Wolfgang Walther
6a26c66335 ci/eval/compare/maintainers: disable aliases
We should never try to ping maintainers through package aliases, this
can only lead to errors. One example case is, where an attribute is a
throw alias, but then re-introduced in a PR. This would trigger the
throw. By disabling aliases, we can fallback gracefully.
2025-10-22 13:33:41 +02:00
Wolfgang Walther
ce8c42d995 ci/README: add github-script policy
Over the last couple of months we have been migrating a lot of the old
bash code to JavaScript, which is supported in GitHub Actions via
`actions/github-script`. This change documents a "manual ratchet check"
for this migration - new code should only be introduced as JavaScript
and not as Bash. This will help us to eventually succeed with the
migration and ensure quality and maintainability.

We are migrating to JavaScript, because:

1. Using JavaScript is GitHub's [recommendation] against injection attacks.
   Using `actions/github-script` has first-class support for the event
   context and does not require to resort back to environment variables in
   most cases. When environment variables need to be used, these are
   accessed via `process.env`, without a risk for accidental injections.
   Using `actions/github-script` is also recommended in a recent
   [survey] of open source supply chain compromises:

   > Finally, since two out of three compromises were due to shell injection,
   > it might be safer to use a proper programming language, like JavaScript
   > with actions/github-script, or any other language accessing the context
   > via environment variables instead of YAML interpolation.

2. Handling even environment variables in Bash safely is almost
   impossible. For example arithmetic expressions cause arbitrary code
   execution vulnerabilities. While a lot of contributors are somehwat
   familiar writing Bash code for builders, writing *safe* Bash code for
   CI is a very different matter. Few people, if any, know how to do
   this.

3. GitHub Action's security model is quite unintuitive and even if some
   code runs with trusted inputs today, it may later be used in a more
   exposed context. Instead of making judgement calls about language
   choice case by case, a clear policy helps writing things defensively
   from the beginning.

4. We have developed a framework around our github-script based tools in
   `ci/github-script`. This provides a local `nix-shell` environment
   with the right dependencies and a local runner for these scripts for
   quick testing, debugging and development. No matter, whether you're
   developing a new feature, fixing bugs or reviewing a PR - this allows
   much quicker verification of the scripts, *without* running
   everything in a fork or test organization.

5. This framework also provides helpers for challenges that come up with
   GHA. One example is rate-limiting, where we have a helper script that
   will handle all rate-limiting needs for us, preventing us from
   running out of API calls and thus breaking CI entirely. We can only
   use these tools consistently, if we consistently use JavaScript code.

6. Using JavaScript allows us to handle JSON natively. Using
   `octokit/rest.js` provides first-class integration with GitHub's API.
   Together, this makes these scripts much more maintainable than
   resorting to `gh` and `jq`.

[recommendation]: https://docs.github.com/en/actions/reference/security/secure-use#use-an-action-instead-of-an-inline-script
[survey]: https://words.filippo.io/compromise-survey/
2025-10-22 12:59:20 +02:00
Wolfgang Walther
a705a34a22 ci/github-script/labels: prevent closing purposely-empty PRs
Some PRs are empty on purpose, for example the yearly notification about
the election for voters. We should not close these because the merge
commit is empty - only if there was a change intended, but the merge
commit *becomes* empty, we should act.
2025-10-19 11:27:05 +02:00
Wolfgang Walther
e8e79cc1ca ci/parse: only show first error (#453214) 2025-10-18 18:18:34 +00:00
Wolfgang Walther
bd193ba607 ci/eval: disable GC warning (#453205) 2025-10-18 17:41:08 +00:00
Wolfgang Walther
a2def7f914 ci/parse: fix potential race condition
The parse check runs multiple `nix-instantiate` processes in parallel -
and they can error out with "SQLite database '...' is busy" while
setting up the state directories. This was observed once locally.

Initialising the store should fix this.
2025-10-18 19:37:49 +02:00
Wolfgang Walther
7a8622a0af ci/parse: only show first error
There is no point in running the much slower `parse-each` part for each
interpreter/version. The CI job is not meant as a development tool that
should report all parse errors at once, but as a confirmation that no
parse errors are present on *different interpreter versions*.

Once this test fails, Eval, nixpkgs-vet and treefmt will most likely
fail as well - with more information for multiple parse errors.
2025-10-18 19:37:45 +02:00
Wolfgang Walther
8db9fa116b ci/nixpkgs-vet: try to fix race
This is another attempt at fixing the annoying nixpkgs-vet errors in CI,
which just throw with `error: SQLite database '...' is busy`.

The assumption is that this happens while initially setting up the state
directories. nixpkgs-vet runs `nix-instantiate` on both the base and the
head commit and these two could interfere.
2025-10-18 14:12:05 +02:00
Wolfgang Walther
2b7ea9379a ci/eval: disable GC warning
This came up more often recently, and breaks Eval because it prints on
stderr.
2025-10-18 14:06:09 +02:00
Wolfgang Walther
402b41c125 ci/github-script/labels: close empty PRs
If the change of a PR has already been merged to the target branch
elsewhere, the PR will not be auto-closed by GitHub - and will still
show the same original diff. Still, the temporary merge commit is
actually empty. This causes all kinds of strange CI behavior, from not
showing rebuilds to not pinging maintainers.

We check the merge commit during labeling anyway, to see whether a merge
conflict is present. It's easy to just look a the number of affected
files in this merge commit - and if there are none, we can just
automatically close the PR as no longer relevant.
2025-10-18 11:29:36 +02:00
Wolfgang Walther
a5bc3bbbd4 ci/eval/compare/maintainers: first-class by-name support (#452566) 2025-10-17 14:49:52 +00:00
Wolfgang Walther
f33892fcc9 ci/eval/compare/maintainers: ping by-name reviewers for pure refactors
This allows requesting reviewers for pure refactor PRs, which don't
cause a rebuild of the package. This is only possible for by-name,
because only here the package names can be inferred from the filenames.
2025-10-17 16:37:14 +02:00
Wolfgang Walther
0a5ffcdf31 ci/eval/compare/maintainers: ping by-name reviewers for all rebuilds
This adds support to ping maintainers when arbitrary files in by-name
are changed, as long as they still cause a rebuild. For example, this is
the case when changing .json files with version metadata. These were
previously not detected as belonging to the package, and didn't cause
maintainer pings.
2025-10-17 16:37:09 +02:00
Wolfgang Walther
7c865ddd46 ci/eval/compare/maintainers: refactor path matching
The only reason for the additional `lib.hasSuffix` check was, that the
`lib.removePrefix` was broken - it was never adjusted when porting this
from ofborg, so the relative path was wrong and no prefix ever removed,
since no packages are in `ci/`.

This additionally strips the leading `/`, so that `relevantFilenames`
will then have paths starting with `pkgs/...`, similar to how git
reports those paths in the `changedpathsjson` file. This allows simple
equality comparison.
2025-10-17 16:37:04 +02:00
Wolfgang Walther
79029e39a4 ci/eval/compare/maintainers: refactor using lib
Removes unused code and comments, uses shorter lib over builtins and
switches to `lib.importJSON`.

Readability is key.
2025-10-17 16:37:00 +02:00
Wolfgang Walther
44e4c1ba9f maintainers/scripts/get-maintainer-pings-between: drop
This has been broken for months, since all the interface to `ci/eval`
changed. Nobody noticed, so nobody is using it.
2025-10-16 13:36:42 +02:00
Wolfgang Walther
b98ea083be workflows/labels: use Node 24 2025-10-11 13:37:21 +02:00
Wolfgang Walther
f0c1e4b672 ci/github-script/labels: solve TODOs
These can now be removed after enough time has passed.

Advanced search is only the default from November 4, according to the
GitHub docs at:
https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#search-issues-and-pull-requests
2025-10-11 13:35:53 +02:00
Philip Taron
b3877f1266 dockerTools: Updated streamNixShellImage Nix GitHub links (#449992) 2025-10-09 17:15:53 +00:00
Joel Holdsworth
9ef7242483 OWNERS: Added @jhol to dockerTools maintainers 2025-10-09 09:51:39 -07:00
Philip Taron
04d243c35b OWNERS: add rocm team to rocm-modules (#444734) 2025-10-07 19:22:50 +00:00
Wolfgang Walther
d28cc2a2f5 linux: new workflow for kernel changes (#444973) 2025-10-06 06:41:41 +00:00
Luna Nova
329438685d OWNERS: add rocm team to rocm-modules 2025-10-05 16:24:51 -07:00
Maximilian Bosch
9f95c2ace2 linux: new workflow for kernel changes
See https://github.com/NixOS/nixpkgs/issues/437208#issuecomment-3288623669
Depends on https://github.com/NixOS/org/pull/172

As documented below, the idea is to essentially group all changes
rebuilding all VM tests with kernel updates and merge them together into
`master` whenever the Linux kernels get updated.

This documents the workflow of updates in the nixpkgs manual. While at
it, I removed the README from the packages because

* it's horribly outdated
* I didn't even know it exists which confirms that its discoverability
  was very poor

and added the relevant portions into the nixpkgs manual as well.
2025-10-05 22:59:25 +02:00
Naïm Camille Favier
a871af02f1 Add an Agda team (#447957) 2025-10-05 21:46:40 +02:00
K900
e93c560b79 Merge remote-tracking branch 'origin/master' into staging-next 2025-10-05 12:17:08 +03:00
Wolfgang Walther
91a8fee3aa treewide: remove redundant parentheses
Auto-fixed by nixf-diagnose.
2025-10-05 10:52:03 +02:00
Wolfgang Walther
c283f32d29 treewide: remove unused with
Auto-fixed by nixf-diagnose.
2025-10-05 10:50:41 +02:00
Wolfgang Walther
90e7159c55 treewide: remove unused rec
Auto-fix by nixf-diagnose.
2025-10-05 10:49:12 +02:00
Wolfgang Walther
6f066d934b ci/treefmt: add nixf-diagnose
This currently has plenty of failures, so we disable many checks. We can
now start working towards fixing these rules 1-by-1.
2025-10-05 10:40:22 +02:00
Vladimír Čunát
dd51f936da Merge branch 'master' into staging-next
lixPackageSets.git conflicted via 9c29a340be + eabfa160aa
I think, hopefully good now.
2025-10-05 08:18:28 +02:00
Philip Taron
d9335d5dd7 treewide: remove optional builtins prefixes from prelude functions (#444432) 2025-10-04 18:30:40 +00:00
Naïm Camille Favier
9ea1f78ff8 Add an Agda team 2025-10-02 19:50:01 +02:00
nixpkgs-ci[bot]
328f4a49c0 Merge master into staging-next 2025-09-30 12:07:29 +00:00
NAHO
dec908b169 treewide: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd --type file --exec-batch sed --in-place --regexp-extended "
      s/\<builtins\.($(
        printf '%s\n' "${builtins[@]}" |
          paste --delimiter '|' --serial -
      ))\>/\1/g
    "

    nix fmt
2025-09-30 09:05:08 +02:00
Wolfgang Walther
f7d6d11e8e workflows/check: don't check github api for owners file
This removes the "owners" check from codeowners-validator. With it, all
tokens and permissions can be removed, because these were only needed to
make these requests.

This solves the problem of codeowners-validator not supporting our new
nested team structure for nixpkgs-maintainers. To make the onboarding of
new teams easier, we moved all teams "under" the nixpkgs-maintainers
team. This makes them inherit the right privileges (triage) for Nixpkgs.

However, this inheritance is not recognized by codeowners-validator,
thus it assumes that these teams don't have access to Nixpkgs. This then
fails the owners check immediately.

Removing the owners check also has a few other advantages:
- This check depends on external state: If a user is renamed or a team
removed, the check will fail. This makes it a bad check for required
status checks or merge queues - the check might fail randomly,
independent of the current PR.
- Running this check in a fork will never work, because the respective
users and teams don't have access to the fork's repo.

Both of this required us to set `continue-on-error: true` most of the
time.
2025-09-28 18:22:01 +02:00
K900
63730dc4de Merge remote-tracking branch 'origin/master' into staging-next 2025-09-26 22:55:30 +03:00
Wolfgang Walther
86b7a69460 ci/pinned: update
This gives us nixd 2.7.0, which is needed to add nixf-diagnose to
treefmt.

From the nixpkgs-unstable channel:
https://hydra.nixos.org/build/308290354#tabs-buildinputs

Changes for treefmt-nix:
128222dc91...5eda4ee812
2025-09-26 14:28:56 +02:00
nixpkgs-ci[bot]
66a3cd62a8 Merge master into staging-next 2025-09-22 18:05:40 +00:00
Wolfgang Walther
4c675a3f9d ci/pinned: update
This gives us Nix 2.31 in Eval and nixf-diagnose 0.1.4 which has
auto-fix mode.

From the nixpkgs-unstable channel:
https://hydra.nixos.org/build/308169374#tabs-buildinputs

Changes for treefmt-nix:
7d81f6fb2e...128222dc91
2025-09-22 14:37:25 +02:00
nixpkgs-ci[bot]
15409f9947 Merge staging-next into staging 2025-09-18 18:06:41 +00:00
Philip Taron
3d0e2841b8 ci.eval.compare: keep warnings as warnings rather than raising them as errors
This reverts commit f8210561f3 (ci.eval.compare: turn warnings into errors, 2025-09-16).

It turns out that there are normal math warnings and we don't want to block CI on the math coming out wrong.
2025-09-18 08:37:36 -07:00
Philip Taron
d80d4a77b7 ci.eval.compare: split out equivalent values into their own table 2025-09-17 14:04:28 -07:00
Philip Taron
fb1647ec6e ci.eval.compare: explain the various metrics under the --explain flag 2025-09-17 14:04:28 -07:00