diff --git a/flake.lock b/flake.lock index bccba00..8b6288e 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -18,6 +34,49 @@ "type": "github" } }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1749636823, + "narHash": "sha256-WUaIlOlPLyPgz9be7fqWJA5iG6rHcGRtLERSCfUDne4=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "623c56286de5a3193aa38891a6991b28f9bab056", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1749285348, @@ -52,7 +111,29 @@ "root": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" + "hooks": "hooks", + "nixpkgs": "nixpkgs", + "treefmt": "treefmt" + } + }, + "treefmt": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1749194973, + "narHash": "sha256-eEy8cuS0mZ2j/r/FE0/LYBSBcIs/MKOIVakwHVuqTfk=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "a05be418a1af1198ca0f63facb13c985db4cb3c5", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index c4e243e..2d7aacb 100644 --- a/flake.nix +++ b/flake.nix @@ -4,25 +4,59 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; + hooks = { + url = "github:cachix/git-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + treefmt = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { - self, - nixpkgs, - flake-parts, - } @ inputs: - flake-parts.lib.mkFlake {inherit inputs;} { + outputs = + { + self, + nixpkgs, + flake-parts, + hooks, + treefmt, + }@inputs: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + hooks.flakeModule + treefmt.flakeModule + ]; + systems = nixpkgs.lib.systems.flakeExposed; - perSystem = {lib, pkgs, ...}: { - packages = let - packages = lib.packagesFromDirectoryRecursive { - inherit (pkgs) callPackage; - directory = ./packages; + perSystem = + { + config, + pkgs, + ... + }: + { + treefmt = { + projectRootFile = "flake.nix"; + + programs.nixfmt = { + enable = true; + package = pkgs.nixfmt-rfc-style; + }; }; - in packages // { - default = packages.helix; + + pre-commit.settings.hooks = { + treefmt.enable = true; + }; + + devShells.default = pkgs.mkShellNoCC { + shellHook = '' + ${config.pre-commit.installationScript} + ''; + }; + + packages.default = pkgs.callPackage ./package.nix { }; }; - }; }; } diff --git a/packages/helix/package.nix b/package.nix similarity index 74% rename from packages/helix/package.nix rename to package.nix index 776a7bc..c212475 100644 --- a/packages/helix/package.nix +++ b/package.nix @@ -3,7 +3,8 @@ symlinkJoin, makeWrapper, pkgs, -}: let +}: +let languageServers = [ # C & C++ pkgs.clang-tools @@ -60,17 +61,20 @@ pkgs.wl-clipboard ]; in - symlinkJoin { - inherit (helix) pname version meta passthru; +symlinkJoin { + inherit (helix) + pname + version + meta + passthru + ; - paths = [helix]; + paths = [ helix ]; - buildInputs = [makeWrapper]; + buildInputs = [ makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/${helix.meta.mainProgram} \ - --suffix PATH : ${pkgs.lib.makeBinPath ( - languageServers ++ debugAdapters ++ clipboardProviders - )} - ''; - } + postBuild = '' + wrapProgram $out/bin/${helix.meta.mainProgram} \ + --suffix PATH : ${pkgs.lib.makeBinPath (languageServers ++ debugAdapters ++ clipboardProviders)} + ''; +}