terlar/dev-flake
{ "createdAt": "2023-07-07T06:01:03Z", "defaultBranch": "main", "description": "Nix flake to support the pattern of using a separate development flake", "fullName": "terlar/dev-flake", "homepage": null, "language": "Nix", "name": "dev-flake", "pushedAt": "2025-11-20T16:48:41Z", "stargazersCount": 10, "topics": [], "updatedAt": "2025-11-03T08:32:52Z", "url": "https://github.com/terlar/dev-flake"}dev-flake
Section titled “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
Section titled “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]!(flake-module/interface.nix) and the corresponding documentation for each dependency flake module.
Dependency flake modules:
Default devShell
Section titled “Default devShell”The default devShell is provided via devshell.
- Installs pre-commit hooks.
- Menu with available commands.
- Named shell prompt
- Can be used together with direnv for seamless shell integration.
- See the example [subflake-project template]!(template/subflake-project).
treefmt
Section titled “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
Section titled “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 git-hooks-nix documentation.
Subflake
Section titled “Subflake”To avoid polluting the top-level flake inputs with development inputs, dev-flake can be used in a subflake.
Existing project
Section titled “Existing project”Within an existing project ([template]!(template/subflake)):
mkdir -p devcd devnix flake init -t github:terlar/dev-flakeAdd the following to your flake-parts config:
# ...imports = [ inputs.flake-parts.flakeModules.partitions ];
partitionedAttrs = { checks = "dev"; devShells = "dev";};
partitions.dev = { extraInputsFlake = ./dev; module = { imports = [ ./dev/flake-module.nix ]; };};# ...New project
Section titled “New project”Create a new project ([template]!(template/subflake-project)):
mkdir -p projectnix flake init -t github:terlar/dev-flake#subflake-projectSubflake (with nixpkgs)
Section titled “Subflake (with nixpkgs)”If you are creating a flake-parts library or some other flake that only produce system outputs for development purposes, you do not need to include nixpkgs within the main flake.
Existing project
Section titled “Existing project”Within an existing project ([template]!(template/subflake-nixpkgs)):
mkdir -p devcd devnix flake init -t github:terlar/dev-flake#subflake-nixpkgsAdd the following to your flake-parts config:
# ...imports = [ inputs.flake-parts.flakeModules.partitions ];
systems = [ ];
partitionedAttrs = { checks = "dev"; devShells = "dev";};
partitions.dev = { extraInputsFlake = ./dev; module = { imports = [ ./dev/flake-module.nix ]; };};# ...New project
Section titled “New project”Create a new project ([template]!(template/subflake-nixpkgs-project)):
mkdir -p projectnix flake init -t github:terlar/dev-flake#subflake-nixpkgs-projectRoot flake
Section titled “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]!(template/root)):
mkdir -p devcd devnix flake init -t github:terlar/dev-flake#rootCreate a new project ([template]!(template/root-project)):
mkdir -p projectnix flake init -t github:terlar/dev-flake#root-project