diff --git a/flake.lock b/flake.lock index 58b8eeb5..6cd43325 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1716791293, + "narHash": "sha256-zxFADJsXhODHH9rrF7gXjN+BYVkMoNY2NpLyjGQDOJA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "9af557bccdfa8fb6a425661c33dbae46afef0afa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -64,12 +85,30 @@ }, "root": { "inputs": { + "fenix": "fenix", "flake-compat": "flake-compat", "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", "treefmt-nix": "treefmt-nix" } }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1716714715, + "narHash": "sha256-xJ5vzVr5Et6wxHRQLOYicsa0gN2bwm4mj6AFHc8ugJc=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "71a816a90facb6546a0a06010da17598e11812f7", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 111f7d7f..6d946dbc 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-compat = { url = "github:edolstra/flake-compat"; flake = false; @@ -23,6 +28,7 @@ nixpkgs, flake-parts, treefmt-nix, + fenix, flake-compat, ... }: @@ -41,8 +47,12 @@ self', config, pkgs, + system, ... }: + let + rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml); + in { packages.default = config.packages.bcachefs-tools; packages.bcachefs-tools = pkgs.callPackage ./build.nix { }; @@ -74,6 +84,9 @@ programs = { nixfmt-rfc-style.enable = true; + rustfmt.edition = rustfmtToml.edition; + rustfmt.enable = true; + rustfmt.package = fenix.packages.${system}.default.rustfmt; }; }; };