add treefmt-nix to repository
This commit is contained in:
parent
d4b7281357
commit
fea7e110c2
5 changed files with 86 additions and 2 deletions
2
ci.nix
2
ci.nix
|
@ -12,4 +12,4 @@ in
|
||||||
# FIXME: maybe find a more generic solution here?
|
# FIXME: maybe find a more generic solution here?
|
||||||
devShell-x86_64 = self.outputs.devShells.x86_64-linux.default;
|
devShell-x86_64 = self.outputs.devShells.x86_64-linux.default;
|
||||||
devShell-aarch64 = self.outputs.devShells.aarch64-linux.default;
|
devShell-aarch64 = self.outputs.devShells.aarch64-linux.default;
|
||||||
}
|
} // self.outputs.checks.x86_64-linux # mainly for treefmt at the moment...
|
||||||
|
|
18
flake.lock
generated
18
flake.lock
generated
|
@ -223,7 +223,8 @@
|
||||||
"nixpkgs-update-pypi-releases": "nixpkgs-update-pypi-releases",
|
"nixpkgs-update-pypi-releases": "nixpkgs-update-pypi-releases",
|
||||||
"nur-update": "nur-update",
|
"nur-update": "nur-update",
|
||||||
"sops-nix": "sops-nix",
|
"sops-nix": "sops-nix",
|
||||||
"srvos": "srvos"
|
"srvos": "srvos",
|
||||||
|
"treefmt-nix": "treefmt-nix"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sops-nix": {
|
"sops-nix": {
|
||||||
|
@ -266,6 +267,21 @@
|
||||||
"repo": "srvos",
|
"repo": "srvos",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"treefmt-nix": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1672170030,
|
||||||
|
"narHash": "sha256-hvTMwlutePPQ4eNMVHiI0crixCyeSTKJIDhLD/66t2g=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "c97bb3db343ccd2f04dd4e5fa8750e821560e9ca",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
disko.url = "github:nix-community/disko";
|
disko.url = "github:nix-community/disko";
|
||||||
disko.inputs.nixpkgs.follows = "nixpkgs";
|
disko.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs @ {flake-parts, ...}:
|
outputs = inputs @ {flake-parts, ...}:
|
||||||
|
@ -39,13 +41,19 @@
|
||||||
{
|
{
|
||||||
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
|
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./treefmt.nix
|
||||||
|
];
|
||||||
|
|
||||||
perSystem = {
|
perSystem = {
|
||||||
inputs',
|
inputs',
|
||||||
pkgs,
|
pkgs,
|
||||||
|
self',
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
devShells.default = pkgs.callPackage ./shell.nix {
|
devShells.default = pkgs.callPackage ./shell.nix {
|
||||||
inherit (inputs'.sops-nix.packages) sops-import-keys-hook;
|
inherit (inputs'.sops-nix.packages) sops-import-keys-hook;
|
||||||
|
inherit (self'.packages) treefmt;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
flake.nixosConfigurations = let
|
flake.nixosConfigurations = let
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{ pkgs
|
{ pkgs
|
||||||
, sops-import-keys-hook
|
, sops-import-keys-hook
|
||||||
|
, treefmt
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with pkgs;
|
with pkgs;
|
||||||
|
@ -26,6 +27,7 @@ mkShellNoCC {
|
||||||
]
|
]
|
||||||
))
|
))
|
||||||
rsync
|
rsync
|
||||||
|
treefmt
|
||||||
|
|
||||||
sops-import-keys-hook
|
sops-import-keys-hook
|
||||||
];
|
];
|
||||||
|
|
58
treefmt.nix
Normal file
58
treefmt.nix
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
{ inputs, ... }: {
|
||||||
|
imports = [
|
||||||
|
inputs.treefmt-nix.flakeModule
|
||||||
|
];
|
||||||
|
perSystem = { pkgs, ... }: {
|
||||||
|
treefmt = {
|
||||||
|
# Used to find the project root
|
||||||
|
projectRootFile = "flake.lock";
|
||||||
|
|
||||||
|
programs.terraform.enable = true;
|
||||||
|
|
||||||
|
settings.formatter = {
|
||||||
|
nix = {
|
||||||
|
command = "sh";
|
||||||
|
options = [
|
||||||
|
"-eucx"
|
||||||
|
''
|
||||||
|
# First deadnix
|
||||||
|
${pkgs.lib.getExe pkgs.deadnix} --edit "$@"
|
||||||
|
# Then nixpkgs-fmt
|
||||||
|
${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@"
|
||||||
|
''
|
||||||
|
"--"
|
||||||
|
];
|
||||||
|
includes = [ "*.nix" ];
|
||||||
|
excludes = [ "nix/sources.nix" ];
|
||||||
|
};
|
||||||
|
shell = {
|
||||||
|
command = "sh";
|
||||||
|
options = [
|
||||||
|
"-eucx"
|
||||||
|
''
|
||||||
|
# First shellcheck
|
||||||
|
${pkgs.lib.getExe pkgs.shellcheck} --external-sources --source-path=SCRIPTDIR "$@"
|
||||||
|
# Then format
|
||||||
|
${pkgs.lib.getExe pkgs.shfmt} -i 2 -s -w "$@"
|
||||||
|
''
|
||||||
|
"--"
|
||||||
|
];
|
||||||
|
includes = [ "*.sh" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
python = {
|
||||||
|
command = "sh";
|
||||||
|
options = [
|
||||||
|
"-eucx"
|
||||||
|
''
|
||||||
|
${pkgs.lib.getExe pkgs.ruff} --fix "$@"
|
||||||
|
${pkgs.lib.getExe pkgs.python3.pkgs.black} "$@"
|
||||||
|
''
|
||||||
|
"--" # this argument is ignored by bash
|
||||||
|
];
|
||||||
|
includes = [ "*.py" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue