forked from numtide/treefmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
67 lines (55 loc) · 1.53 KB
/
default.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
{ system ? builtins.currentSystem
, inputs ? import ./flake.lock.nix { }
, nixpkgs ? import inputs.nixpkgs {
inherit system;
# Makes the config pure as well. See <nixpkgs>/top-level/impure.nix:
config = { };
overlays = [ ];
}
, rustPackages ? nixpkgs.rustPackages
}:
let
cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml));
# What is used when invoking `nix run github:numtide/treefmt`
treefmt = rustPackages.rustPlatform.buildRustPackage {
inherit (cargoToml.package) name version;
src = nixpkgs.lib.cleanSource ./.;
# Those are being used in tests
nativeBuildInputs = with nixpkgs; [
# Build tools
rustPackages.clippy
rust-analyzer
# Code formatters
elmPackages.elm-format
go
haskellPackages.cabal-fmt
haskellPackages.ormolu
mdsh
nixpkgs-fmt
nodePackages.prettier
python3.pkgs.black
rufo
rustPackages.rustfmt
shellcheck
shfmt
terraform
mdbook
];
shellHook = ''
# Put the treefmt binary on the PATH when it's built
export PATH=$PWD/target/debug:$PATH
'';
buildInputs = with nixpkgs; lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security libiconv ];
doCheck = true;
cargoLock.lockFile = ./Cargo.lock;
meta.description = "one CLI to format the code tree";
};
in
{
inherit treefmt;
# A collection of packages for the project
docs = nixpkgs.callPackage ./docs { };
# Flake attributes
defaultPackage = treefmt;
devShell = treefmt;
}