-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
113 lines (105 loc) · 3.77 KB
/
Copy pathflake.nix
File metadata and controls
113 lines (105 loc) · 3.77 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
description = "tribuchet - RBE-style remote build execution for Nix";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.crane.url = "github:ipetkov/crane";
# only used to evaluate the darwin module in checks
inputs.nix-darwin = {
url = "github:nix-darwin/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
crane,
nix-darwin,
}:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (pkgs: {
# Nix patched to let external builders implement recursive-nix:
# the rejection in external-derivation-builder.cc is dropped,
# and a result.json sidecar populates addedPaths so the output
# reference scan sees inner-built paths. Off-tree because the
# change is not upstream; opt in via
# services.tribuchet-hub.externalBuilders.recursiveNix.
nix-recursive = pkgs.nixVersions.latest.appendPatches [
./nix/patches/recursive-nix-external-builders.patch
];
default = pkgs.callPackage ./nix/package.nix {
craneLib = crane.mkLib pkgs;
};
});
darwinModules.default = import ./nix/darwin-module.nix self;
nixosModules.default = import ./nix/nixos-module.nix self;
# CI builds every package and devShell on every system, plus the
# x86_64-linux-only checks below.
checks = forAllSystems (
pkgs:
let
inherit (pkgs.stdenv.hostPlatform) system;
prefix = p: nixpkgs.lib.mapAttrs' (n: nixpkgs.lib.nameValuePair "${p}-${n}");
in
prefix "package" self.packages.${system}
// prefix "devshell" self.devShells.${system}
// nixpkgs.lib.optionalAttrs (system == "x86_64-linux") {
nixos-test = pkgs.testers.runNixOSTest (
import ./nix/test.nix {
tribuchet = self.packages.x86_64-linux.default;
nixosModule = self.nixosModules.default;
}
);
# Evaluation-only check of the darwin module (the launchd plist
# and activation script); building a darwin system needs a mac.
darwin-module =
let
eval = nix-darwin.lib.darwinSystem {
modules = [
self.darwinModules.default
{
nixpkgs.hostPlatform = "aarch64-darwin";
system.stateVersion = 6;
services.tribuchet-hub.enable = true;
services.tribuchet-worker = {
enable = true;
settings.hub = "https://hub.example.org:7437";
};
}
];
};
in
pkgs.writeText "tribuchet-darwin-module" (
# plists reference the aarch64-darwin package; drop the
# context so the check stays eval-only on Linux
builtins.unsafeDiscardStringContext (
builtins.toJSON {
hub = eval.config.launchd.daemons.tribuchet-hub.serviceConfig;
worker = eval.config.launchd.daemons.tribuchet-worker.serviceConfig;
activation = eval.config.system.activationScripts.postActivation.text;
}
)
);
}
);
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
cargo
rustc
rustfmt
clippy
rust-analyzer
protobuf
];
PROTOC = "${pkgs.protobuf}/bin/protoc";
};
});
};
}