Add formatter

This commit is contained in:
Pim Kunis 2024-10-26 20:32:37 +02:00
parent 08b0fbcd0c
commit db14de3471
3 changed files with 61 additions and 1 deletions

View file

@ -549,6 +549,22 @@
"type": "github"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1726871744,
"narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nur": {
"locked": {
"lastModified": 1729855863,
@ -608,7 +624,8 @@
"nixpkgs-unstable": "nixpkgs-unstable",
"nur": "nur",
"sops-nix": "sops-nix",
"stylix": "stylix"
"stylix": "stylix",
"treefmt-nix": "treefmt-nix"
}
},
"rust-overlay": {
@ -721,6 +738,24 @@
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1729613947,
"narHash": "sha256-XGOvuIPW1XRfPgHtGYXd5MAmJzZtOuwlfKDgxX5KT3s=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "aac86347fb5063960eccb19493e0cadcdb4205ca",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",

View file

@ -7,6 +7,7 @@
nur.url = "github:nix-community/NUR";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
stylix.url = "github:pizzapim/stylix/release-24.05";
treefmt-nix.url = "github:numtide/treefmt-nix";
nix-index-database = {
url = "github:nix-community/nix-index-database";
@ -52,6 +53,23 @@
, ...
}@inputs:
let
supportedSystems = [
"x86_64-linux"
"i686-linux"
"aarch64-linux"
];
forAllSystems' = nixpkgs.lib.genAttrs;
forAllSystems = forAllSystems' supportedSystems;
pkgsForSystem =
system:
import nixpkgs {
inherit system;
};
treefmtEval = forAllSystems (
system: inputs.treefmt-nix.lib.evalModule (pkgsForSystem system) ./treefmt.nix
);
mkNixosSystem = {extraModule, nixpkgs' ? nixpkgs, useDefaultConfiguration ? true}: nixpkgs'.lib.nixosSystem rec {
system = "x86_64-linux";
@ -66,6 +84,8 @@
};
in
{
formatter = forAllSystems (system: (treefmtEval.${system}.config.build.wrapper));
nixosConfigurations = {
x260 = mkNixosSystem { extraModule = ({ pkgs, lib, ... }: {
imports = [ inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x260 ];

5
treefmt.nix Normal file
View file

@ -0,0 +1,5 @@
{ ... }:
{
projectRootFile = "flake.nix";
programs.alejandra.enable = true;
}