terlar / dev-flake

Nix flake to support the pattern of using a separate development flake

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dev-flake

Nix flake to support the pattern of using a separate development sub-flake. dev-flake can also be used within the root flake. The integration is done via flake-parts.

Features

Features are enabled by default in order to get "the best experience out of the box", however it is possible to opt-out from the default configuration and/or add additional configuration. See available configuration options in the flake module interface and the corresponding documentation for each dependency flake module.

Dependency flake modules:

Default devShell

The default devShell is provided via devshell.

treefmt

treefmt is a nice abstraction on top of formatters to format the whole project.

To configure more formatters, see the treefmt-nix documentation.

pre-commit hooks

pre-commit is a framework to configure and run git hooks before commit. Usually formatting and linting.

  • Configures flake check to run pre-commit hooks
  • Enables hooks for:
    • deadnix
    • statix
    • treefmt

To configure more pre-commit hooks, see the pre-commit-hooks-nix documentation.

Usage

Subflake

To avoid polluting the top-level flake inputs with development inputs, dev-flake can be used in a subflake.

Within an existing project (template):

mkdir -p dev
cd dev
nix flake init -t github:terlar/dev-flake

Create a new project (template):

mkdir -p project
nix flake init -t github:terlar/dev-flake#subflake-project

Root flake

You can also use this flake in the root flake, when using flake-parts, all you need to do is import the flake.

{
  inputs = {
    flake-parts.url = "github:hercules-ci/flake-parts";
    dev-flake.url = "github:terlar/dev-flake";
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = inputs:
    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      systems = [ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ];
      imports = [ inputs.dev-flake.flakeModule ];
      dev.name = "my-project";
    };
}

Within an existing project (template):

mkdir -p dev
cd dev
nix flake init -t github:terlar/dev-flake#root

Create a new project (template):

mkdir -p project
nix flake init -t github:terlar/dev-flake#root-project

Examples

About

Nix flake to support the pattern of using a separate development flake

License:MIT License


Languages

Language:Nix 98.9%Language:Shell 1.1%