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": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"nixpkgs-lib": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1694529238,
|
"lastModified": 1698882062,
|
||||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
"narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=",
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
"rev": "8c9fa2545007b49a5db5f650ae91f227672c3877",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -36,22 +38,28 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs",
|
||||||
|
"treefmt-nix": "treefmt-nix"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"treefmt-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1699786194,
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
"narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=",
|
||||||
"owner": "nix-systems",
|
"owner": "numtide",
|
||||||
"repo": "default",
|
"repo": "treefmt-nix",
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
"rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-systems",
|
"owner": "numtide",
|
||||||
"repo": "default",
|
"repo": "treefmt-nix",
|
||||||
"type": "github"
|
"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.";
|
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.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-substituters = [ "https://cache.garnix.io" ];
|
||||||
nixConfig.extra-trusted-public-keys = [ "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ];
|
nixConfig.extra-trusted-public-keys = [ "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ];
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
outputs = inputs @ { flake-parts, ... }:
|
||||||
flake-utils.lib.eachDefaultSystem
|
flake-parts.lib.mkFlake { inherit inputs; }
|
||||||
(system:
|
({ lib, ... }: {
|
||||||
let
|
imports = [ ./treefmt.nix ];
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
systems = [
|
||||||
in
|
"aarch64-linux"
|
||||||
{
|
"x86_64-linux"
|
||||||
|
|
||||||
|
"x86_64-darwin"
|
||||||
|
"aarch64-darwin"
|
||||||
|
];
|
||||||
|
perSystem = { config, pkgs, self', ... }: {
|
||||||
packages = {
|
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 {
|
test-runner-stable = pkgs.callPackage ./test-runner.nix {
|
||||||
nixVersion = "stable";
|
nixVersion = "stable";
|
||||||
};
|
};
|
||||||
|
|
@ -25,12 +34,17 @@
|
||||||
devShells.default = pkgs.callPackage ./shell.nix { };
|
devShells.default = pkgs.callPackage ./shell.nix { };
|
||||||
apps.test-runner = {
|
apps.test-runner = {
|
||||||
type = "app";
|
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: {
|
overlay = final: prev: {
|
||||||
nix-direnv = final.callPackage ./default.nix { };
|
nix-direnv = final.callPackage ./default.nix { };
|
||||||
};
|
};
|
||||||
|
|
@ -39,4 +53,5 @@
|
||||||
description = "nix flake new -t github:Mic92/nix-direnv .";
|
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.copytree(test_root / "testenv", dir)
|
||||||
shutil.copyfile(project_root / "flake.nix", dir / "flake.nix")
|
shutil.copyfile(project_root / "flake.nix", dir / "flake.nix")
|
||||||
shutil.copyfile(project_root / "flake.lock", dir / "flake.lock")
|
shutil.copyfile(project_root / "flake.lock", dir / "flake.lock")
|
||||||
|
shutil.copyfile(project_root / "treefmt.nix", dir / "treefmt.nix")
|
||||||
nix_direnv = project_root / "direnvrc"
|
nix_direnv = project_root / "direnvrc"
|
||||||
|
|
||||||
c = DirenvProject(Path(dir), nix_direnv)
|
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