From d2fed9c4d02051dfc8303bfa0c5db02308eebf8b Mon Sep 17 00:00:00 2001 From: dfh Date: Wed, 4 Sep 2024 20:43:13 +0000 Subject: [PATCH] This is dfh@ playing with jj These are some more descriptions. --- README.md | 2 +- flake.lock | 23 ++++++++++++++++- flake.nix | 25 ++++++++++++++----- overlays/lix-docs/default.nix | 2 +- packages/aux-wiki/default.nix | 2 +- packages/lix-docs/default.nix | 2 +- packages/nixos-options/default.nix | 2 +- packages/nixpkgs-lib-docs/locations-json.nix | 4 +-- .../nixpkgs-manual/python-interp-table.nix | 2 +- treefmt.nix | 24 ++++++++++++++++++ 10 files changed, 73 insertions(+), 15 deletions(-) create mode 100644 treefmt.nix diff --git a/README.md b/README.md index 0d23265..020240b 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -Test change... \ No newline at end of file +Test change... diff --git a/flake.lock b/flake.lock index 297cb7a..9f7c4c0 100644 --- a/flake.lock +++ b/flake.lock @@ -89,7 +89,8 @@ "inputs": { "aux-wiki": "aux-wiki", "nixpkgs": "nixpkgs", - "snowfall-lib": "snowfall-lib" + "snowfall-lib": "snowfall-lib", + "treefmt-nix": "treefmt-nix" } }, "snowfall-lib": { @@ -128,6 +129,26 @@ "repo": "default", "type": "github" } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1725271838, + "narHash": "sha256-VcqxWT0O/gMaeWTTjf1r4MOyG49NaNxW4GHTO3xuThE=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "9fb342d14b69aefdf46187f6bb80a4a0d97007cd", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 4da74cb..2422edf 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,11 @@ inputs.aux-wiki.url = "git+https://git.auxolotl.org/auxolotl/wiki"; inputs.aux-wiki.flake = false; + inputs.treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + outputs = inputs: inputs.snowfall-lib.mkFlake { @@ -21,11 +26,19 @@ title = "Aux Manual Generator"; }; }; - - outputs-builder = channels: { - checks."//tmp/this-is-path-traversal" = inputs.self.packages.${channels.nixpkgs.system}.aux-wiki; - checks."/aux-wiki/path-traversal-2" = inputs.self.packages.${channels.nixpkgs.system}.aux-wiki; - checks."aux-wiki/all-good" = inputs.self.packages.${channels.nixpkgs.system}.aux-wiki; - }; + + outputs-builder = + channels: + let + treefmt = inputs.treefmt-nix.lib.evalModule channels.nixpkgs ./treefmt.nix; + in + { + checks."//tmp/this-is-path-traversal" = inputs.self.packages.${channels.nixpkgs.system}.aux-wiki; + checks."/aux-wiki/path-traversal-2" = inputs.self.packages.${channels.nixpkgs.system}.aux-wiki; + checks."aux-wiki/all-good" = inputs.self.packages.${channels.nixpkgs.system}.aux-wiki; + + formatter = treefmt.config.build.wrapper; + checks.formatting = treefmt.config.build.check inputs.self; + }; }; } diff --git a/overlays/lix-docs/default.nix b/overlays/lix-docs/default.nix index 752ea60..7083bc0 100644 --- a/overlays/lix-docs/default.nix +++ b/overlays/lix-docs/default.nix @@ -1,5 +1,5 @@ { channels, ... }: -final: prev: { +_final: _prev: { lix-docs = channels.nixpkgs.lix.overrideAttrs { pname = "lix-docs"; postBuild = '' diff --git a/packages/aux-wiki/default.nix b/packages/aux-wiki/default.nix index 593c1fb..f10cbab 100644 --- a/packages/aux-wiki/default.nix +++ b/packages/aux-wiki/default.nix @@ -12,7 +12,7 @@ cp -r community $out/community cp -r contributing $out/contributing cp -r docs $out/docs - + # foo, bar, baz, qux, quxx ''; diff --git a/packages/lix-docs/default.nix b/packages/lix-docs/default.nix index 9700500..a2db244 100644 --- a/packages/lix-docs/default.nix +++ b/packages/lix-docs/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation { inherit (lix-docs) version; pname = "lix-docs-md"; - src = lix-docs.src; + inherit (lix-docs) src; nativeBuildInputs = [ vim diff --git a/packages/nixos-options/default.nix b/packages/nixos-options/default.nix index 979b706..26321fc 100644 --- a/packages/nixos-options/default.nix +++ b/packages/nixos-options/default.nix @@ -40,7 +40,7 @@ let ); options = - (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux; + (buildFromConfig (_: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux; customPython = pkgs.python312.withPackages (ps: [ ps.jq diff --git a/packages/nixpkgs-lib-docs/locations-json.nix b/packages/nixpkgs-lib-docs/locations-json.nix index e060172..dd7e6a7 100644 --- a/packages/nixpkgs-lib-docs/locations-json.nix +++ b/packages/nixpkgs-lib-docs/locations-json.nix @@ -20,7 +20,7 @@ let libset = toplib: builtins.map (subsetname: { - subsetname = subsetname; + inherit subsetname; functions = libDefPos [ ] toplib.${subsetname}; }) (builtins.map (x: x.name) lib.amg.libsets); @@ -58,7 +58,7 @@ let }; }; - relativeLocs = (builtins.map fnLocationRelative liblocations); + relativeLocs = builtins.map fnLocationRelative liblocations; sanitizeId = builtins.replaceStrings [ "'" ] [ "-prime" ]; urlPrefix = "https://github.com/NixOS/nixpkgs/blob/${revision}"; diff --git a/packages/nixpkgs-manual/python-interp-table.nix b/packages/nixpkgs-manual/python-interp-table.nix index 5c6222d..f134deb 100644 --- a/packages/nixpkgs-manual/python-interp-table.nix +++ b/packages/nixpkgs-manual/python-interp-table.nix @@ -7,7 +7,7 @@ ), }: let - lib = pkgs.lib; + inherit (pkgs) lib; inherit (lib.attrsets) attrNames filterAttrs; inherit (lib.lists) filter diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..33345c2 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,24 @@ +_: { + # Used to find the project root + projectRootFile = "flake.nix"; + + # Files not to format. + settings.global.excludes = [ + ".editorconfig" + ".jj/**" + "LICENSE" + ]; + + # nix + programs.nixfmt-rfc-style.enable = true; + programs.statix.enable = true; + programs.deadnix.enable = true; + + # markdown + programs.prettier = { + enable = true; + settings = { + editorconfig = true; + }; + }; +}