Skip to content

Commit 907925d

Browse files
authored
Merge pull request #428 from PerchunPak/patch-1
Add more aliases for `--systems` flag
2 parents 055465e + 1475798 commit 907925d

File tree

2 files changed

+39
-20
lines changed

2 files changed

+39
-20
lines changed

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,20 @@ since the architecture/operating system mismatches.
351351

352352
By default, `nixpkgs-review` targets only the current system
353353
(`--systems current`). You can also explicitly provide one or several systems to
354-
target (`--systems "x86_64-linux aarch64-darwin"`). The `--systems all` value
355-
will build for the four major platforms supported by hydra (`--x86_64-linux`,
356-
`aarch64-linux`, `x86_64-darwin` and `aarch64-darwin`). Ensure that your system
357-
is capable of building for the specified architectures, either locally or
358-
through the remote builder protocol.
354+
target (`--systems "x86_64-linux aarch64-darwin"`). We also provide aliases for
355+
the flag:
356+
357+
| Alias | Transforms to |
358+
| ---------------------------------------------------- | --------------------------------------------------------- |
359+
| `current` | Your current system |
360+
| `all` | `aarch64-darwin aarch64-linux x86_64-darwin x86_64-linux` |
361+
| `linux` | `aarch64-linux x86_64-linux` |
362+
| `darwin`, `macos` | `aarch64-darwin x86_64-darwin` |
363+
| `x64`, `x86`, `x86_64`, `x86-64`, `x64_86`, `x64-86` | `x86_64-darwin x86_64-linux` |
364+
| `aarch64`, `arm64` | `aarch64-darwin aarch64-linux` |
365+
366+
Ensure that your system is capable of building for the specified architectures,
367+
either locally or through the remote builder protocol.
359368

360369
```console
361370
$ nixpkgs-review pr --system aarch64-linux 98734

nixpkgs_review/review.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@
2121

2222
# keep up to date with `supportedPlatforms`
2323
# https://github.com/NixOS/ofborg/blob/cf2c6712bd7342406e799110e7cd465aa250cdca/ofborg/src/outpaths.nix#L12
24-
OFBORG_PLATFORMS: set[str] = set(
25-
[
26-
"aarch64-darwin",
27-
"aarch64-linux",
28-
"x86_64-darwin",
29-
"x86_64-linux",
30-
]
31-
)
24+
OFBORG_PLATFORMS_LINUX: set[str] = {"aarch64-linux", "x86_64-linux"}
25+
OFBORG_PLATFORMS_DARWIN: set[str] = {"aarch64-darwin", "x86_64-darwin"}
26+
OFBORG_PLATFORMS_AARCH64: set[str] = {"aarch64-darwin", "aarch64-darwin"}
27+
OFBORG_PLATFORMS_X64: set[str] = {"x86_64-darwin", "x86_64-darwin"}
28+
OFBORG_PLATFORMS: set[str] = OFBORG_PLATFORMS_LINUX.union(OFBORG_PLATFORMS_DARWIN)
3229

3330

3431
class CheckoutOption(Enum):
@@ -127,13 +124,9 @@ def __init__(
127124
case 0:
128125
raise NixpkgsReviewError("Systems is empty")
129126
case 1:
130-
system = list(systems)[0]
131-
if system == "current":
132-
self.systems = set([current_system()])
133-
elif system == "all":
134-
self.systems = OFBORG_PLATFORMS
135-
else:
136-
self.systems = set([system])
127+
self.systems = self._process_aliases_for_systems(
128+
list(systems)[0].lower()
129+
)
137130
case _:
138131
self.systems = set(systems)
139132
self.allow = allow
@@ -143,6 +136,23 @@ def __init__(
143136
self.extra_nixpkgs_config = extra_nixpkgs_config
144137
self.num_parallel_evals = num_parallel_evals
145138

139+
def _process_aliases_for_systems(self, system: str) -> set[str]:
140+
match system:
141+
case "current":
142+
return set([current_system()])
143+
case "all":
144+
return OFBORG_PLATFORMS
145+
case "linux":
146+
return OFBORG_PLATFORMS_LINUX
147+
case "darwin" | "macos":
148+
return OFBORG_PLATFORMS_DARWIN
149+
case "x64" | "x86" | "x86_64" | "x86-64" | "x64_86" | "x64-86":
150+
return OFBORG_PLATFORMS_X64
151+
case "aarch64" | "arm64":
152+
return OFBORG_PLATFORMS_AARCH64
153+
case _:
154+
return set([system])
155+
146156
def worktree_dir(self) -> str:
147157
return str(self.builddir.worktree_dir)
148158

0 commit comments

Comments
 (0)