mirror of
https://github.com/Mic92/nix-fast-build.git
synced 2024-08-16 21:20:27 +03:00
add treefmt
This commit is contained in:
parent
114758a6d4
commit
47b1beff0e
23
flake.lock
23
flake.lock
@ -55,7 +55,28 @@
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1693817438,
|
||||
"narHash": "sha256-fg3+n4Ky1gCzDtPm0MomMTFw0YkH05Y8ojy5t7bkfHg=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "b8d3a059f5487d6767d07c3716386753e3132d9f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
13
flake.nix
13
flake.nix
@ -4,10 +4,14 @@
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = inputs@{ flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } ({ lib, ... }: {
|
||||
imports = [ ./treefmt.nix ];
|
||||
systems = [
|
||||
"aarch64-linux"
|
||||
"x86_64-linux"
|
||||
@ -16,8 +20,15 @@
|
||||
"aarch64-darwin"
|
||||
];
|
||||
perSystem = { pkgs, self', ... }: {
|
||||
packages.nix-ci-builds = pkgs.callPackage ./default.nix {};
|
||||
packages.nix-ci-builds = pkgs.callPackage ./default.nix { };
|
||||
packages.default = self'.packages.nix-ci-builds;
|
||||
|
||||
checks =
|
||||
let
|
||||
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self'.packages;
|
||||
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
|
||||
in
|
||||
packages // devShells;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
44
treefmt.nix
Normal file
44
treefmt.nix
Normal file
@ -0,0 +1,44 @@
|
||||
{ lib, inputs, ... }: {
|
||||
imports = [
|
||||
inputs.treefmt-nix.flakeModule
|
||||
];
|
||||
|
||||
perSystem = { pkgs, ... }: {
|
||||
treefmt = {
|
||||
# Used to find the project root
|
||||
projectRootFile = "flake.lock";
|
||||
|
||||
programs.mypy.enable = true;
|
||||
|
||||
settings.formatter = {
|
||||
nix = {
|
||||
command = "sh";
|
||||
options = [
|
||||
"-eucx"
|
||||
''
|
||||
# First deadnix
|
||||
${lib.getExe pkgs.deadnix} --edit "$@"
|
||||
# Then nixpkgs-fmt
|
||||
${lib.getExe pkgs.nixpkgs-fmt} "$@"
|
||||
''
|
||||
"--"
|
||||
];
|
||||
includes = [ "*.nix" ];
|
||||
};
|
||||
|
||||
python = {
|
||||
command = "sh";
|
||||
options = [
|
||||
"-eucx"
|
||||
''
|
||||
${lib.getExe pkgs.ruff} --fix "$@"
|
||||
${lib.getExe pkgs.black} "$@"
|
||||
''
|
||||
"--" # this argument is ignored by bash
|
||||
];
|
||||
includes = [ "*.py" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user