1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-07-30 12:07:46 +00:00

feat: add a readme

This commit is contained in:
Kevin Amado 2022-01-26 18:24:38 -05:00
parent 1211194ba0
commit bbfb513aa9
No known key found for this signature in database
GPG key ID: FFF341057F503148
4 changed files with 136 additions and 12 deletions

96
README.md Normal file
View file

@ -0,0 +1,96 @@
<h1 align="center">Alejandra 💅</h2>
<p align="center">The Uncompromising Nix Code Formatter</p>
<p align="center">
<a
href="https://coveralls.io/github/kamadorueda/.github?branch=main"
>
<img
alt="Coverage"
src="https://coveralls.io/repos/github/kamadorueda/.github/badge.svg?branch=main"
>
</img>
</a>
<a
href="https://github.com/kamadorueda/alejandra/blob/main/UNLICENSE"
>
<img
alt="License: The Unlicense"
src="https://img.shields.io/badge/license-The Unlicense-green.svg"
>
</a>
<a
href="https://github.com/kamadorueda/alejandra"
>
<img
alt="style: Alejandra"
src="https://img.shields.io/badge/code%20style-Alejandra-green.svg"
>
</a>
</p>
## Getting started
Let's get Alejandra on our systems:
- Nix with Flakes:
```bash
$ nix run github:kamadorueda/alejandra -- --help
```
- Nix stable:
Pick one depending on your platform:
```bash
$ nix-env -ivA aarch64-darwin -f https://github.com/kamadorueda/alejandra/tarball/main
$ nix-env -ivA aarch64-linux -f https://github.com/kamadorueda/alejandra/tarball/main
$ nix-env -ivA i686-linux -f https://github.com/kamadorueda/alejandra/tarball/main
$ nix-env -ivA x86_64-darwin -f https://github.com/kamadorueda/alejandra/tarball/main
$ nix-env -ivA x86_64-linux -f https://github.com/kamadorueda/alejandra/tarball/main
```
Then run with:
```bash
$ alejandra --help
```
## Goals
- ✔️ **Fast**
It's written in rust
and formats [Nixpkgs](https://github.com/NixOS/nixpkgs)
in under 1 minute.
- ✔️ **Highly tested**
Coverage currently > 80%,
aiming to a 💯% soon.
- ✔️ **Comprehensive**
All elements in the Nix grammar have a rule,
so there won't be portions of code unformatted.
- ✔️ **Reproducible**
Formatting many times yields the same results.
- 🚧 **Beautiful**
Beauty is subjective, right?
Yet there are a few improvements to implement like:
- Multiline strings indentation `'' ... ''`.
- Multiline comments indentation `/* ... */`.
- Not indenting attr sets, lists, or parenthesis after binding `name = {`.
- And many more as community feedback drives.
Style is negotiable at this moment.
## Do I need to configure anything?
- No.

15
default.nix Normal file
View file

@ -0,0 +1,15 @@
let
lockData = builtins.readFile ./flake.lock;
lock = builtins.fromJSON lockData;
flakeCompat = lock.nodes.flakeCompat.locked;
flakeCompatSrc =
builtins.fetchTarball
{
url = "https://github.com/edolstra/flake-compat/archive/${ flakeCompat.rev }.tar.gz";
sha256 = flakeCompat.narHash;
};
flake = import flakeCompatSrc { src = ./.; };
in
flake
.defaultNix
.defaultPackage

17
flake.lock generated
View file

@ -1,5 +1,21 @@
{
"nodes": {
"flakeCompat": {
"flake": false,
"locked": {
"lastModified": 1641205782,
"narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flakeUtils": {
"locked": {
"lastModified": 1642700792,
@ -33,6 +49,7 @@
},
"root": {
"inputs": {
"flakeCompat": "flakeCompat",
"flakeUtils": "flakeUtils",
"nixpkgs": "nixpkgs"
}

View file

@ -1,6 +1,8 @@
{
inputs =
{
flakeCompat.url = github:edolstra/flake-compat;
flakeCompat.flake = false;
flakeUtils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
};
@ -11,20 +13,15 @@
system:
let
nixpkgs = import inputs.nixpkgs { inherit system; };
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
cargoToml = builtins.fromTOML ( builtins.readFile ./Cargo.toml );
in
{
checks =
{
defaultPackage = inputs.self.defaultPackage.${ system };
inherit (inputs.self.packages.${ system }) nixpkgsFormatted;
};
defaultApp =
{
type = "app";
program =
"${ inputs.self.defaultPackage.${ system } }/bin/alejandra";
inherit ( inputs.self.packages.${ system } ) nixpkgsFormatted;
};
defaultApp = { type = "app"; program = "${ inputs.self.defaultPackage.${ system } }/bin/alejandra"; };
defaultPackage =
nixpkgs.rustPlatform.buildRustPackage
{
@ -35,9 +32,9 @@
NIX_BUILD_CORES = 0;
meta =
{
description = inputs.self.description;
description = cargoToml.package.description;
homepage = "https://github.com/kamadorueda/alejandra";
license = nixpkgs.lib.licenses.mit;
license = nixpkgs.lib.licenses.unlicense;
maintainers = [ nixpkgs.lib.maintainers.kamadorueda ];
};
};
@ -69,8 +66,7 @@
git diff --no-index $nixpkgs $out > $diff || true
'';
buildInputs =
[ inputs.self.defaultPackage.${ system } nixpkgs.git ];
buildInputs = [ inputs.self.defaultPackage.${ system } nixpkgs.git ];
nixpkgs = inputs.nixpkgs.sourceInfo.outPath;
NIX_BUILD_CORES = 0;
outputs = [ "diff" "out" ];