-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathflake.nix
More file actions
93 lines (87 loc) · 2.83 KB
/
Copy pathflake.nix
File metadata and controls
93 lines (87 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
description = "basic-cli release platform and development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# nixos-unstable no longer supports Intel macOS.
nixpkgs-x86-darwin.url = "github:NixOS/nixpkgs/nixpkgs-26.05-darwin";
roc-overlay = {
url = "github:roc-lang/roc-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-darwin.follows = "nixpkgs-x86-darwin";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
nixpkgs,
nixpkgs-x86-darwin,
roc-overlay,
rust-overlay,
...
}:
let
inherit (nixpkgs) lib;
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = lib.genAttrs supportedSystems;
rustToolchainConfig = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)).toolchain;
# scripts/build.py cross-compiles the host with `zig cc` for the musl
# targets, so those work from any host. The macOS targets need an Apple
# SDK for the bundled C dependencies, so only ship their standard
# libraries where they can actually be built.
muslRustTargets = [
"x86_64-unknown-linux-musl"
"aarch64-unknown-linux-musl"
];
darwinRustTargets = [
"x86_64-apple-darwin"
"aarch64-apple-darwin"
];
rustTargetsFor =
system: muslRustTargets ++ lib.optionals (lib.hasSuffix "-darwin" system) darwinRustTargets;
pkgsFor =
system:
import (if system == "x86_64-darwin" then nixpkgs-x86-darwin else nixpkgs) {
inherit system;
overlays = [
roc-overlay.overlays.default
rust-overlay.overlays.default
];
};
releaseFor = system: import ./nix/release.nix { pkgs = pkgsFor system; };
in
{
formatter = forAllSystems (system: (pkgsFor system).nixfmt);
packages = forAllSystems (system: (releaseFor system).packages);
checks = forAllSystems (system: (releaseFor system).checks);
devShells = forAllSystems (
system:
let
pkgs = pkgsFor system;
rustToolchain = pkgs.rust-bin.fromRustupToolchain (
rustToolchainConfig // { targets = rustTargetsFor system; }
);
in
{
default = pkgs.mkShell {
packages = [
# Keep in sync with the nightly pinned in .github/workflows.
pkgs.rocpkgs."nightly-2026-09-26-d6267b4"
pkgs.python3
rustToolchain
pkgs.simple-http-server
pkgs.zig_0_16
]
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.valgrind ];
};
}
);
};
}