Skip to content

Commit c3efb9c

Browse files
authored
🎀 Introduce Nix linting (#8)
This prevents dead nix code and improves overall code style consistency.
1 parent 291a660 commit c3efb9c

File tree

6 files changed

+49
-46
lines changed

6 files changed

+49
-46
lines changed

‎flake-module.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ lib, self, flake-parts-lib, ... }:
1+
{ lib, flake-parts-lib, ... }:
22
let
33
inherit (lib)
44
mkOption

‎flake.nix

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,21 @@
3434
# nixpkgs used by nativelink as the the "global" nixpkgs. We do this by
3535
# setting `nixpkgs.follows = "nativelink/nixpkgs"` above.
3636

37-
inputs.flake-utils.follows = "flake-utils";
38-
inputs.flake-parts.follows = "flake-parts";
39-
inputs.pre-commit-hooks.follows = "pre-commit-hooks";
37+
inputs = {
38+
flake-utils.follows = "flake-utils";
39+
flake-parts.follows = "flake-parts";
40+
pre-commit-hooks.follows = "pre-commit-hooks";
41+
};
4042
};
4143
rules_ll = {
4244
url = "github:eomii/rules_ll/5ac0546db310da08d44f14271066e0b159611c25";
43-
inputs.nixpkgs.follows = "nixpkgs";
44-
inputs.flake-utils.follows = "flake-utils";
45-
inputs.flake-parts.follows = "flake-parts";
46-
inputs.pre-commit-hooks.follows = "pre-commit-hooks";
47-
inputs.nativelink.follows = "nativelink";
45+
inputs = {
46+
nixpkgs.follows = "nixpkgs";
47+
flake-utils.follows = "flake-utils";
48+
flake-parts.follows = "flake-parts";
49+
pre-commit-hooks.follows = "pre-commit-hooks";
50+
nativelink.follows = "nativelink";
51+
};
4852
};
4953
nix2container = {
5054
follows = "nativelink/nix2container";
@@ -54,7 +58,6 @@
5458
outputs =
5559
{ self
5660
, nixpkgs
57-
, flake-utils
5861
, pre-commit-hooks
5962
, flake-parts
6063
, nativelink
@@ -81,17 +84,16 @@
8184
, ...
8285
}:
8386
let
87+
inherit (inputs.nativelink.packages.${system}) native-cli lre-cc nativelink-debug;
88+
8489
tinfo6-bin = pkgs.callPackage ./tinfo6-bin.nix { };
8590

8691
ncurses6-bin = pkgs.callPackage ./ncurses6-bin.nix { };
8792

88-
native-cli = inputs.nativelink.packages.${system}.native-cli;
89-
9093
lre-mojo-cluster = pkgs.callPackage ./local-remote-execution/lre-mojo-cluster.nix {
9194
inherit native-cli;
9295
};
9396

94-
lre-cc = nativelink.packages.${system}.lre-cc;
9597
inherit (nix2container.packages.${system}.nix2container) buildImage;
9698

9799
mojo = pkgs.callPackage ./mojo.nix {
@@ -114,7 +116,7 @@
114116

115117
createWorker = pkgs.callPackage ./local-remote-execution/create-worker.nix {
116118
inherit buildImage self;
117-
nativelink = nativelink.packages.${system}.nativelink-debug;
119+
nativelink = nativelink-debug;
118120
};
119121

120122
bazel = pkgs.writeShellScriptBin "bazel" ''
@@ -139,7 +141,7 @@
139141
};
140142
rules_ll.settings.llEnv =
141143
let
142-
openssl = (pkgs.openssl.override { static = true; });
144+
openssl = pkgs.openssl.override { static = true; };
143145
in
144146
rules_ll.lib.defaultLlEnv {
145147
inherit pkgs;

‎lre-bazel.nix

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
, ...
55
}:
66

7-
let
8-
# The specific commit to use
9-
nativelinkCommit = "75105df746c626da76f74e412764e6755296a8ab";
10-
11-
# Base URL for GitHub access
12-
githubBaseUrl = "github:TraceMachina/nativelink/";
13-
in
14-
157
writeShellScriptBin "lre-bazel" ''
168
EXECUTOR=$(${kubectl}/bin/kubectl get gtw scheduler -o=jsonpath='{.status.addresses[0].value}')
179
CACHE=$(${kubectl}/bin/kubectl get gtw cache -o=jsonpath='{.status.addresses[0].value}')

‎modules/rules_mojo.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
let
33
inherit (lib) mkOption types;
44

5-
inherit (pkgs) runCommand writeText git;
5+
inherit (pkgs) runCommand git;
66

77
processedActionEnvs = map (x: "build --@rules_mojo//mojo:" + x) config.mojoEnv;
88

‎pre-commit-hooks.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878

7979
# Nix
8080
nixpkgs-fmt.enable = true;
81+
statix.enable = true;
82+
deadnix.enable = true;
8183

8284
# Vale
8385
vale = {

‎templates/default/flake.nix

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,48 @@
3434
# nixpkgs used by nativelink as the the "global" nixpkgs. We do this by
3535
# setting `nixpkgs.follows = "nativelink/nixpkgs"` above.
3636

37-
inputs.flake-utils.follows = "flake-utils";
38-
inputs.flake-parts.follows = "flake-parts";
39-
inputs.pre-commit-hooks.follows = "pre-commit-hooks";
37+
inputs = {
38+
flake-utils.follows = "flake-utils";
39+
flake-parts.follows = "flake-parts";
40+
pre-commit-hooks.follows = "pre-commit-hooks";
41+
};
4042
};
4143
rules_ll = {
4244
# Keep this commit in sync with the rules_ll commit in `MODULE.bazel`.
4345
url = "github:eomii/rules_ll/5ac0546db310da08d44f14271066e0b159611c25";
44-
inputs.nixpkgs.follows = "nixpkgs";
45-
inputs.flake-utils.follows = "flake-utils";
46-
inputs.flake-parts.follows = "flake-parts";
47-
inputs.pre-commit-hooks.follows = "pre-commit-hooks";
48-
inputs.nativelink.follows = "nativelink";
46+
inputs = {
47+
nixpkgs.follows = "nixpkgs";
48+
flake-utils.follows = "flake-utils";
49+
flake-parts.follows = "flake-parts";
50+
pre-commit-hooks.follows = "pre-commit-hooks";
51+
nativelink.follows = "nativelink";
52+
};
4953
};
5054
nix2container = {
5155
follows = "nativelink/nix2container";
5256
};
5357
rules_mojo = {
5458
# Keep this commit in sync with the rules_mojo commit in `MODULE.bazel`
5559
url = "github:TraceMachina/rules_mojo/<TODO: Specify rules_mojo commit>";
56-
inputs.nixpkgs.follows = "nixpkgs";
57-
inputs.flake-utils.follows = "flake-utils";
58-
inputs.flake-parts.follows = "flake-parts";
59-
inputs.pre-commit-hooks.follows = "pre-commit-hooks";
60-
inputs.nativelink.follows = "nativelink";
61-
inputs.rules_ll.follows = "rules_ll";
60+
inputs = {
61+
nixpkgs.follows = "nixpkgs";
62+
flake-utils.follows = "flake-utils";
63+
flake-parts.follows = "flake-parts";
64+
pre-commit-hooks.follows = "pre-commit-hooks";
65+
nativelink.follows = "nativelink";
66+
rules_ll.follows = "rules_ll";
67+
};
6268
};
6369
};
6470

6571
outputs =
6672
{ self
6773
, nixpkgs
68-
, flake-utils
6974
, pre-commit-hooks
7075
, flake-parts
7176
, nativelink
7277
, rules_ll
7378
, rules_mojo
74-
, nix2container
7579
, ...
7680
} @ inputs:
7781
flake-parts.lib.mkFlake { inherit inputs; }
@@ -92,6 +96,9 @@
9296
, lib
9397
, ...
9498
}:
99+
let
100+
inherit (inputs.nativelink.packages.${system}) lre-cc;
101+
in
95102
{
96103
_module.args.pkgs = import self.inputs.nixpkgs {
97104
inherit system;
@@ -100,14 +107,14 @@
100107
# config.cudaSupport = true;
101108
};
102109
local-remote-execution.settings = {
103-
inherit (nativelink.packages.${system}.lre-cc.meta) Env;
110+
inherit (lre-cc.meta) Env;
104111
};
105112
pre-commit.settings = {
106113
hooks = import ./pre-commit-hooks.nix { inherit pkgs; };
107114
};
108115
rules_ll.settings.llEnv =
109116
let
110-
openssl = (pkgs.openssl.override { static = true; });
117+
openssl = pkgs.openssl.override { static = true; };
111118
in
112119
rules_ll.lib.defaultLlEnv {
113120
inherit pkgs;
@@ -116,12 +123,12 @@
116123
};
117124
rules_mojo.settings.mojoEnv = rules_mojo.lib.defaultMojoEnv {
118125
inherit pkgs;
119-
mojo = inputs.rules_mojo.packages.${system}.mojo;
126+
inherit (inputs.rules_mojo.packages.${system}) mojo;
120127
};
121128
packages = {
122-
lre-mojo = rules_mojo.packages.${system}.lre-mojo;
123-
lre-cc = nativelink.packages.${system}.lre-cc;
124-
nativelink-worker-lre-mojo = rules_mojo.packages.${system}.lre-mojo;
129+
inherit lre-cc;
130+
inherit (inputs.rules_mojo.packages.${system}) lre-mojo;
131+
nativelink-worker-lre-mojo = lre-mojo;
125132
};
126133
devShells.default = pkgs.mkShell {
127134
nativeBuildInputs = [

0 commit comments

Comments
 (0)