Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maintainers: add targeted fix for missing pkgs/by-name/.../package.nix files #341041

Merged
merged 1 commit into from
Sep 11, 2024
Merged
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
22 changes: 21 additions & 1 deletion maintainers/scripts/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,27 @@
# nix-build build.nix --argstr maintainer <yourname> --argstr system aarch64-linux

let
pkgs = import ./../../default.nix (removeAttrs args [ "maintainer" ]);
# This avoids a common situation for maintainers, where due to Git's behavior of not tracking
# directories, they have an empty directory somewhere in `pkgs/by-name`. Because that directory
# exists, `pkgs/top-level/by-name-overlay.nix` picks it up and attempts to read `package.nix` out
# of it... which doesn't exist, since it's empty.
#
# We don't want to run the code below on every instantiation of `nixpkgs`, as the `pkgs/by-name`
# eval machinery is quite performance sensitive. So we use the internals of the `by-name` overlay
# to implement our own way to avoid an evaluation failure for this script.
#
# See <https://github.com/NixOS/nixpkgs/issues/338227> for more motivation for this code block.
overlay = self: super: {
_internalCallByNamePackageFile =
file: if builtins.pathExists file then super._internalCallByNamePackageFile file else null;
};

nixpkgsArgs = removeAttrs args [ "maintainer" "overlays" ] // {
overlays = args.overlays or [] ++ [ overlay ];
};

pkgs = import ./../../default.nix nixpkgsArgs;

maintainer_ = pkgs.lib.maintainers.${maintainer};
packagesWith = cond: return: set:
(pkgs.lib.flatten
Expand Down