Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: treefmt-nix #113

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
(import
(
import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).defaultNix
{src = ./.;}
)
.defaultNix
23 changes: 22 additions & 1 deletion flake.lock

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

16 changes: 15 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.nix.url = "github:NixOS/nix/latest-release";
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";

outputs = {
self,
Expand All @@ -17,8 +19,9 @@
flake-utils,
nix,
nixpkgs,
treefmt-nix,
}: let
inherit (nixpkgs.lib) optional;
inherit (nixpkgs.lib) optional mkForce;
in
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
Expand All @@ -32,6 +35,13 @@
};

cargoArtifacts = craneLib.buildDepsOnly commonArgs;

treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs.alejandra.enable = true;
programs.rustfmt.enable = true;
settings.formatter.rustfmt.command = mkForce "${toolchain}/bin/rustfmt";
};
in {
packages.default = craneLib.buildPackage (
commonArgs
Expand All @@ -52,5 +62,9 @@
pkgs.mob
];
};

formatter = treefmtEval.config.build.wrapper;

checks.formatting = treefmtEval.config.build.check self;
});
}