diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index e16d4ad..ef67b78 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -46,10 +46,13 @@ Boot up the documentation site locally, with live reloading of the source code: $ pnpm run docs:dev ``` -If you made a lot of changes, run the following command to check for typos before submitting a pull request: +If you made a lot of changes, run the following command to check for typos & format the docs before submitting a pull request: + +> Generally, `nix develop` will add a pre-commit hook to run the following command before you commit. ```sh $ typos -w +$ prettier --write . ``` After executing the above command, visit and try modifying the source code. You'll get live update. diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..b0c35e7 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +LICENSE.md +dist +pnpm-lock.yaml +flake.lock +vercel.json +cache +temp +.temp diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 0000000..cf12abe --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,5 @@ +# https://prettier.io/docs/en/options +semi: false +singleQuote: false +printWidth: 80 +trailingComma: es5 diff --git a/README.md b/README.md index 283d165..6497b0b 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,9 @@ An unofficial and opinionated NixOS & Flakes :book: for beginners: https://nixos > If you're using macOS, [ryan4yin/nix-darwin-kickstarter](https://github.com/ryan4yin/nix-darwin-kickstarter) may be a good starting point for you, > you can learn how to use Nix with this book and take nix-darwin-kickstarter as a start point to build your own Nix configuration. - ## Feedback and Discussion -I’m not an expert on NixOS, and I’ve only been using NixOS for less than 9 months until now(2024-02), +I’m not an expert on NixOS, and I’ve only been using NixOS for less than 9 months until now(2024-02), so there must be some misconceptions or inappropriate examples in the book. If anyone finds anything incorrect or have any questions / suggestions, just let me know about it by open an issue or join the discussion on [GitHub Discussions](https://github.com/ryan4yin/nixos-and-flakes-book/discussions), I'm glad continue to optimize the content of this book. @@ -24,7 +23,6 @@ Even though I knew I could make mistakes, it's much better than do nothing. My hope is that this book can help more people, enabling them to experience the joys of NixOS. Hope you like it! - ## Introduction to Flakes The flakes experimental feature is a major development for Nix, it introduces a policy for managing dependencies between Nix expressions, it improves reproducibility, composability and usability in the Nix ecosystem. Although it's still an experimental feature, flakes have been widely used by the Nix community.[^1] @@ -58,7 +56,6 @@ Thank you to [all the people](https://github.com/ryan4yin/nixos-and-flakes-book/ [NixOS & Flakes Book](https://github.com/ryan4yin/nixos-and-flakes-book) © 2023 by Ryan Yin is licensed under [CC BY-SA 4.0](./LICENSE.md) - [^1]: [Flakes - NixOS Wiki](https://nixos.wiki/index.php?title=Flakes) [^2]: [Flakes are such an obviously good thing](https://grahamc.com/blog/flakes-are-an-obviously-good-thing/) [^3]: [Draft: 1 year roadmap - NixOS Foundation](https://nixos-foundation.notion.site/1-year-roadmap-0dc5c2ec265a477ea65c549cd5e568a9) diff --git a/flake.nix b/flake.nix index e1de9ba..ed5a328 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,7 @@ nodejs = super.nodejs_20; pnpm = super.nodePackages.pnpm; yarn = super.yarn.override {inherit nodejs;}; + prettier = super.nodePackages.prettier; }) ]; pkgs = import nixpkgs {inherit overlays system;}; @@ -28,6 +29,7 @@ nodejs pnpm yarn + prettier git typos @@ -40,12 +42,17 @@ hooks = { typos.enable = true; # Source code spell checker alejandra.enable = true; # Nix linter + prettier.enable = true; # Markdown & TS formatter }; settings = { typos = { write = true; # Automatically fix typos ignored-words = []; }; + prettier = { + write = true; # Automatically format files + configPath = "./.prettierrc.yaml"; + }; }; }; };