flake: enable treefmt for formatting
- for now, uses only `nixfmt-rfc-style` - can be invoked with `nix flake check` and `nix fmt`
This commit is contained in:
parent
d25fffc899
commit
3a31c21ae2
21
flake.lock
21
flake.lock
|
@ -307,6 +307,7 @@
|
||||||
"nixos-unstable": "nixos-unstable",
|
"nixos-unstable": "nixos-unstable",
|
||||||
"nixpkgs": "nixpkgs_2",
|
"nixpkgs": "nixpkgs_2",
|
||||||
"nur": "nur",
|
"nur": "nur",
|
||||||
|
"treefmt-nix": "treefmt-nix",
|
||||||
"utils": "utils"
|
"utils": "utils"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -365,6 +366,26 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"treefmt-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1710278050,
|
||||||
|
"narHash": "sha256-Oc6BP7soXqb8itlHI8UKkdf3V9GeJpa1S39SR5+HJys=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "35791f76524086ab4b785a33e4abbedfda64bd22",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"utils": {
|
"utils": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems_2"
|
"systems": "systems_2"
|
||||||
|
|
18
flake.nix
18
flake.nix
|
@ -14,6 +14,10 @@
|
||||||
# deliberately do _not_ follow the nixpkgs input here, because paranoia and test coverage
|
# deliberately do _not_ follow the nixpkgs input here, because paranoia and test coverage
|
||||||
};
|
};
|
||||||
utils.url = "github:numtide/flake-utils";
|
utils.url = "github:numtide/flake-utils";
|
||||||
|
treefmt-nix = {
|
||||||
|
url = "github:numtide/treefmt-nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
nur.url = "github:nix-community/NUR";
|
nur.url = "github:nix-community/NUR";
|
||||||
# TODO: possible make this a flake as well
|
# TODO: possible make this a flake as well
|
||||||
|
@ -25,7 +29,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ self, nixpkgs, nur, lanzaboote, utils, home-manager, ... }@inputs:
|
{ self, nixpkgs, nur, lanzaboote, utils, home-manager, treefmt-nix, ... }@inputs:
|
||||||
let
|
let
|
||||||
# FIXME: allow different systems
|
# FIXME: allow different systems
|
||||||
systems = utils.lib.system;
|
systems = utils.lib.system;
|
||||||
|
@ -71,6 +75,10 @@
|
||||||
inherit inputs system;
|
inherit inputs system;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
treefmtConf = {pkgs, ...}:{
|
||||||
|
projectRootFile = "flake.nix";
|
||||||
|
programs.nixfmt-rfc-style.enable = true;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
overlays.default = import ./packages;
|
overlays.default = import ./packages;
|
||||||
|
@ -85,11 +93,19 @@
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = nixpkgs.lib.attrValues self.overlays;
|
overlays = nixpkgs.lib.attrValues self.overlays;
|
||||||
};
|
};
|
||||||
|
nixpkgs_unstable = import inputs.nixos-unstable {
|
||||||
|
inherit system;
|
||||||
|
overlays = nixpkgs.lib.attrValues self.overlays;
|
||||||
|
};
|
||||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||||
|
pkgs_unstable = inputs.nixos-unstable.legacyPackages.${system};
|
||||||
|
treefmtEval = treefmt-nix.lib.evalModule pkgs_unstable treefmtConf;
|
||||||
in {
|
in {
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
buildInputs = [];
|
buildInputs = [];
|
||||||
};
|
};
|
||||||
|
formatter = treefmtEval.config.build.wrapper;
|
||||||
|
checks.formatting = treefmtEval.config.build.check self;
|
||||||
# expose nixpkgs with overlay; TODO: figure out role of config
|
# expose nixpkgs with overlay; TODO: figure out role of config
|
||||||
#legacyPackages = nixpkgs;
|
#legacyPackages = nixpkgs;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue