Skip to content

Commit d8a35e1

Browse files
committed
flake: add treefmt
1 parent f079afb commit d8a35e1

File tree

4 files changed

+385
-7
lines changed

4 files changed

+385
-7
lines changed

flake.lock

Lines changed: 241 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,26 @@
88
androidPkgs.url = "github:tadfisher/android-nixpkgs/stable";
99

1010
flake-compat.url = "github:nix-community/flake-compat";
11+
12+
treefmt.url = "github:numtide/treefmt";
13+
14+
treefmt-nix.url = "github:numtide/treefmt-nix";
15+
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs-unstable";
1116
};
1217

13-
outputs = { self, nixpkgs, nixpkgs-unstable, androidPkgs, flake-compat, ... }@inputs: let
18+
outputs = {
19+
self, nixpkgs, nixpkgs-unstable, androidPkgs, flake-compat, treefmt, treefmt-nix, ...
20+
}@inputs: let
1421
pkgs = import ./pkgs/default.nix { inherit inputs; };
22+
23+
treeFmt = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
24+
pythonForUpdaterScripts = pkgs.python3.withPackages (
25+
p: with p; [
26+
mypy
27+
flake8
28+
pytest
29+
]
30+
);
1531
in {
1632
# robotnixSystem evaluates a robotnix configuration
1733
lib.robotnixSystem = configuration: import ./default.nix {
@@ -33,9 +49,9 @@
3349

3450
devShell.x86_64-linux = pkgs.mkShell {
3551
name = "robotnix-scripts";
52+
inputsFrom = [ treeFmt.config.build.devShell ];
3653
nativeBuildInputs = with pkgs; [
37-
# For android updater scripts
38-
(python3.withPackages (p: with p; [ mypy flake8 pytest ]))
54+
pythonForUpdaterScripts
3955
gitRepo nix-prefetch-git
4056
curl pup jq
4157
shellcheck
@@ -49,5 +65,11 @@
4965
];
5066
PYTHONPATH=./scripts;
5167
};
68+
69+
formatter.x86_64-linux = treeFmt.config.build.wrapper;
70+
71+
checks.x86_64-linux = {
72+
formatting = treeFmt.config.build.check self;
73+
};
5274
};
5375
}

pkgs/overlay.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{ inputs }:
2+
let
3+
inherit (inputs) nixpkgs-unstable;
4+
5+
unstablePkgs = nixpkgs-unstable.legacyPackages.x86_64-linux;
6+
in
27
self: super: {
38
android-emulator = super.callPackage ./android-emulator {};
49

@@ -36,6 +41,10 @@ self: super: {
3641

3742
gitRepo = super.callPackage ./gitRepo { inherit inputs; };
3843

44+
nixfmt-rfc-style = unstablePkgs.nixfmt-rfc-style;
45+
46+
treefmt2 = inputs.treefmt.packages.x86_64-linux.treefmt;
47+
3948
###
4049

4150
# Robotnix helper derivations

0 commit comments

Comments
 (0)