Skip to content

Commit

Permalink
introduce formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiskae committed Sep 9, 2023
1 parent e3b0146 commit 5042673
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 365 deletions.
7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

24 changes: 3 additions & 21 deletions dev/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 26 additions & 7 deletions dev/flake.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
{
description = "nvidia.nix dev flake";

inputs = {
flake.url = "path:../";

nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small";

treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { self, nixpkgs, flake-utils, ... }: {};
outputs = {
self,
nixpkgs,
systems,
treefmt-nix,
...
}: let
# Small tool to iterate over each systems
eachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system});

# Eval the treefmt modules from ./treefmt.nix
treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
in {
# for `nix fmt`
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
# for `nix flake check`
checks = eachSystem (pkgs: {
formatting = treefmtEval.${pkgs.sytem}.config.build.check self;
});
};

/*
outputs = {
self,
nixpkgs,
Expand Down Expand Up @@ -57,5 +76,5 @@
// {
formatter.x86_64-linux = alejandra.packages.x86_64-linux.default;
};
*/
}
*/
}
9 changes: 9 additions & 0 deletions dev/treefmt.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{pkgs, ...}: {
projectRootFile = ".git/config";
programs.alejandra.enable = true;
programs.black.enable = true;
programs.isort = {
enable = true;
profile = "black";
};
}
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "nvidia.nix flake";

outputs = { self }: {};
outputs = {self}: {};
}
Loading

0 comments on commit 5042673

Please sign in to comment.