Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jedimahdi/fourmolu-nix
fourmolu nix configuration
https://github.com/jedimahdi/fourmolu-nix
flake-parts fourmolu nix nix-flake
Last synced: 2 days ago
JSON representation
fourmolu nix configuration
- Host: GitHub
- URL: https://github.com/jedimahdi/fourmolu-nix
- Owner: jedimahdi
- License: mit
- Created: 2024-01-28T03:48:10.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-07T00:34:40.000Z (11 months ago)
- Last Synced: 2024-11-05T10:04:21.500Z (about 2 months ago)
- Topics: flake-parts, fourmolu, nix, nix-flake
- Language: Nix
- Homepage: https://jedimahdi.github.io/fourmolu-nix/
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fourmolu-nix
`fourmolu-nix` makes a wrapper for fourmolu with settings already pass to it so
you no longer need `fourmolu.yaml` or even to be in root of project to have
these options set for you.## Getting started
For creating the wrapper, you can use `mkWrapper` function from lib which takes
pkgs and configuration and returns wrapped fourmolu with the provided configuration.### Flakes
```nix
# flake.nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
fourmolu-nix.url = "github:jedimahdi/fourmolu-nix";
};outputs = {
nixpkgs,
utils,
fourmolu-nix,
...
}:
utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
fourmoluWrapper = fourmolu-nix.lib.mkWrapper pkgs {
settings = {
indentation = 4;
comma-style = "leading";
record-brace-space = true;
extensions = ["OverloadedRecordDot", "RecordWildCards"];
};
};
in {
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
fourmoluWrapper
];
};
}
);
}
```### Flake-parts
With flake-parts you don't need to call `mkWrapper`, just add
`inputs.fourmolu-nix.flakeModule` to list of imports.Fourmolu wrapper will be accessible via `config.fourmolu.wrapper`.
```nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
fourmolu-nix.url = "github:jedimahdi/fourmolu-nix";
};outputs = inputs:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.fourmolu-nix.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
pkgs,
...
}: {
fourmolu.settings = {
indentation = 4;
import-export-style = "diff-friendly";
extensions = ["ImportQualifiedPost" "OverloadedRecordDot"];
};devShells.default = pkgs.mkShell {
nativeBuildInputs = [
config.fourmolu.wrapper
];
};
};
};
}
```Note: `fourmolu-nix` will automatically set the wrapper package for `treefmt-nix`
fourmolu program.## Configuration
See [options](https://jedimahdi.github.io/fourmolu-nix/options.html) for the full list of configs.