forked from eomii/rules_ll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
135 lines (124 loc) · 4.12 KB
/
flake.nix
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{
description = "rules_ll development environment";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
};
nixConfig = {
bash-prompt-prefix = "(rules_ll) ";
bash-prompt = ''\[\033]0;\u@\h:\w\007\]\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]'';
bash-prompt-suffix = " ";
};
outputs =
{ self
, nixpkgs
, flake-utils
, pre-commit-hooks
, flake-parts
, ...
} @ inputs:
flake-parts.lib.mkFlake { inherit inputs; }
{
systems = [
"x86_64-linux"
];
imports = [
inputs.pre-commit-hooks.flakeModule
./flake-module.nix
];
perSystem =
{ config
, pkgs
, system
, lib
, ...
}:
let
hooks = import ./pre-commit-hooks.nix { inherit pkgs; };
llvmPackages = pkgs.llvmPackages_17;
bazel = pkgs.bazel_7;
tag = "latest";
ll = import ./devtools/ll.nix { inherit pkgs tag bazel; };
in
{
_module.args.pkgs = import self.inputs.nixpkgs {
inherit system;
# CUDA support
config.allowUnfree = true;
config.cudaSupport = true;
};
pre-commit.settings = { inherit hooks; };
rules_ll.settings.actionEnv =
let
openssl = (pkgs.openssl.override { static = true; });
in
self.lib.action-env {
inherit pkgs;
LL_CFLAGS = "-I${openssl.dev}/include";
LL_LDFLAGS = "-L${openssl.out}/lib";
};
packages = {
ci-image = import ./rbe/image.nix {
inherit pkgs llvmPackages bazel tag;
};
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
bazel
ll
pkgs.git
(pkgs.python3.withPackages (pylib: [
pylib.mkdocs-material
]))
pkgs.mkdocs
pkgs.vale
pkgs.go
# Cloud tooling
pkgs.cilium-cli
pkgs.kubectl
pkgs.pulumi
pkgs.skopeo
pkgs.tektoncd-cli
];
shellHook = ''
# Generate the .pre-commit-config.yaml symlink when entering the
# development shell.
${config.pre-commit.installationScript}
# Generate .bazelrc.ll which containes action-env configuration
# when rules_ll is run from a nix environment.
${config.rules_ll.installationScript}
# Ensure that the ll command points to our ll binary.
[[ $(type -t ll) == "alias" ]] && unalias ll
# Ensure that the bazel command points to our custom wrapper.
[[ $(type -t bazel) == "alias" ]] && unalias bazel
# Prevent rules_cc from using anything other than clang.
export CC=clang
# Probably a bug in nix. Setting LD=ld.lld here doesn't work.
export LD=${llvmPackages.lld}/bin/ld.lld
# Java needs to be the same version as in the Bazel wrapper.
export JAVA_HOME=${pkgs.jdk17_headless}/lib/openjdk
# Prettier color output for the ls command.
alias ls='ls --color=auto'
'';
};
};
} // {
templates = {
default = {
path = "${./templates/default}";
description = "A basic rules_ll workspace";
};
};
flakeModule = ./flake-module.nix;
lib = { action-env = import ./modules/rules_ll-action-env.nix; };
};
}