mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 19:46:11 +01:00
add treefmt
This commit is contained in:
parent
6f38bdb647
commit
1133b15e75
4 changed files with 112 additions and 41 deletions
46
flake.lock
generated
46
flake.lock
generated
|
|
@ -1,20 +1,22 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
"nixpkgs-lib": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"lastModified": 1698882062,
|
||||
"narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "8c9fa2545007b49a5db5f650ae91f227672c3877",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
|
@ -36,22 +38,28 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"lastModified": 1699786194,
|
||||
"narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
41
flake.nix
41
flake.nix
|
|
@ -1,20 +1,29 @@
|
|||
{
|
||||
description = "A faster, persistent implementation of `direnv`'s `use_nix`, to replace the built-in one.";
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
nixConfig.extra-substituters = [ "https://cache.garnix.io" ];
|
||||
nixConfig.extra-trusted-public-keys = [ "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ];
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
outputs = inputs @ { flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; }
|
||||
({ lib, ... }: {
|
||||
imports = [ ./treefmt.nix ];
|
||||
systems = [
|
||||
"aarch64-linux"
|
||||
"x86_64-linux"
|
||||
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
perSystem = { config, pkgs, self', ... }: {
|
||||
packages = {
|
||||
default = pkgs.callPackage ./default.nix { };
|
||||
nix-direnv = pkgs.callPackage ./default.nix { };
|
||||
default = config.packages.nix-direnv;
|
||||
test-runner-stable = pkgs.callPackage ./test-runner.nix {
|
||||
nixVersion = "stable";
|
||||
};
|
||||
|
|
@ -25,12 +34,17 @@
|
|||
devShells.default = pkgs.callPackage ./shell.nix { };
|
||||
apps.test-runner = {
|
||||
type = "app";
|
||||
program = "${self.packages.${system}.test-runner}";
|
||||
program = "${config.packages.test-runner}";
|
||||
};
|
||||
checks = {
|
||||
lint = pkgs.callPackage ./lint.nix { };
|
||||
|
||||
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;
|
||||
};
|
||||
}) // {
|
||||
flake = {
|
||||
overlay = final: prev: {
|
||||
nix-direnv = final.callPackage ./default.nix { };
|
||||
};
|
||||
|
|
@ -39,4 +53,5 @@
|
|||
description = "nix flake new -t github:Mic92/nix-direnv .";
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ def direnv_project(test_root: Path, project_root: Path) -> Iterator[DirenvProjec
|
|||
shutil.copytree(test_root / "testenv", dir)
|
||||
shutil.copyfile(project_root / "flake.nix", dir / "flake.nix")
|
||||
shutil.copyfile(project_root / "flake.lock", dir / "flake.lock")
|
||||
shutil.copyfile(project_root / "treefmt.nix", dir / "treefmt.nix")
|
||||
nix_direnv = project_root / "direnvrc"
|
||||
|
||||
c = DirenvProject(Path(dir), nix_direnv)
|
||||
|
|
|
|||
47
treefmt.nix
Normal file
47
treefmt.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{ lib, inputs, ... }: {
|
||||
imports = [
|
||||
inputs.treefmt-nix.flakeModule
|
||||
];
|
||||
|
||||
perSystem = { pkgs, ... }: {
|
||||
treefmt = {
|
||||
# Used to find the project root
|
||||
projectRootFile = "flake.lock";
|
||||
|
||||
programs.deno.enable = true;
|
||||
programs.mypy.enable = true;
|
||||
programs.shellcheck.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" ];
|
||||
excludes = [ "nix/sources.nix" ];
|
||||
};
|
||||
|
||||
python = {
|
||||
command = "sh";
|
||||
options = [
|
||||
"-eucx"
|
||||
''
|
||||
${lib.getExe pkgs.ruff} --fix "$@"
|
||||
${lib.getExe pkgs.ruff} format "$@"
|
||||
''
|
||||
"--" # this argument is ignored by bash
|
||||
];
|
||||
includes = [ "*.py" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue