Skip to content

Commit

Permalink
Add more aliases for --systems flag
Browse files Browse the repository at this point in the history
  • Loading branch information
PerchunPak authored and Mic92 committed Nov 12, 2024
1 parent 055465e commit 1475798
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,20 @@ since the architecture/operating system mismatches.

By default, `nixpkgs-review` targets only the current system
(`--systems current`). You can also explicitly provide one or several systems to
target (`--systems "x86_64-linux aarch64-darwin"`). The `--systems all` value
will build for the four major platforms supported by hydra (`--x86_64-linux`,
`aarch64-linux`, `x86_64-darwin` and `aarch64-darwin`). Ensure that your system
is capable of building for the specified architectures, either locally or
through the remote builder protocol.
target (`--systems "x86_64-linux aarch64-darwin"`). We also provide aliases for
the flag:

| Alias | Transforms to |
| ---------------------------------------------------- | --------------------------------------------------------- |
| `current` | Your current system |
| `all` | `aarch64-darwin aarch64-linux x86_64-darwin x86_64-linux` |
| `linux` | `aarch64-linux x86_64-linux` |
| `darwin`, `macos` | `aarch64-darwin x86_64-darwin` |
| `x64`, `x86`, `x86_64`, `x86-64`, `x64_86`, `x64-86` | `x86_64-darwin x86_64-linux` |
| `aarch64`, `arm64` | `aarch64-darwin aarch64-linux` |

Ensure that your system is capable of building for the specified architectures,
either locally or through the remote builder protocol.

```console
$ nixpkgs-review pr --system aarch64-linux 98734
Expand Down
40 changes: 25 additions & 15 deletions nixpkgs_review/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@

# keep up to date with `supportedPlatforms`
# https://github.com/NixOS/ofborg/blob/cf2c6712bd7342406e799110e7cd465aa250cdca/ofborg/src/outpaths.nix#L12
OFBORG_PLATFORMS: set[str] = set(
[
"aarch64-darwin",
"aarch64-linux",
"x86_64-darwin",
"x86_64-linux",
]
)
OFBORG_PLATFORMS_LINUX: set[str] = {"aarch64-linux", "x86_64-linux"}
OFBORG_PLATFORMS_DARWIN: set[str] = {"aarch64-darwin", "x86_64-darwin"}
OFBORG_PLATFORMS_AARCH64: set[str] = {"aarch64-darwin", "aarch64-darwin"}
OFBORG_PLATFORMS_X64: set[str] = {"x86_64-darwin", "x86_64-darwin"}
OFBORG_PLATFORMS: set[str] = OFBORG_PLATFORMS_LINUX.union(OFBORG_PLATFORMS_DARWIN)


class CheckoutOption(Enum):
Expand Down Expand Up @@ -127,13 +124,9 @@ def __init__(
case 0:
raise NixpkgsReviewError("Systems is empty")
case 1:
system = list(systems)[0]
if system == "current":
self.systems = set([current_system()])
elif system == "all":
self.systems = OFBORG_PLATFORMS
else:
self.systems = set([system])
self.systems = self._process_aliases_for_systems(
list(systems)[0].lower()
)
case _:
self.systems = set(systems)
self.allow = allow
Expand All @@ -143,6 +136,23 @@ def __init__(
self.extra_nixpkgs_config = extra_nixpkgs_config
self.num_parallel_evals = num_parallel_evals

def _process_aliases_for_systems(self, system: str) -> set[str]:
match system:
case "current":
return set([current_system()])
case "all":
return OFBORG_PLATFORMS
case "linux":
return OFBORG_PLATFORMS_LINUX
case "darwin" | "macos":
return OFBORG_PLATFORMS_DARWIN
case "x64" | "x86" | "x86_64" | "x86-64" | "x64_86" | "x64-86":
return OFBORG_PLATFORMS_X64
case "aarch64" | "arm64":
return OFBORG_PLATFORMS_AARCH64
case _:
return set([system])

def worktree_dir(self) -> str:
return str(self.builddir.worktree_dir)

Expand Down

0 comments on commit 1475798

Please sign in to comment.