Forked from the-nix-way
. GO check their blog!
To initialize (where ${ENV}
is listed in the table below):
nix flake init --template github:dnswd/dev-templates#${ENV}
Here's an example (for the rust
template):
# Initialize in the current project
nix flake init --template github:dnswd/dev-templates#rust
# Create a new project
nix flake new --template github:dnswd/dev-templates#rust ${NEW_PROJECT_DIRECTORY}
Or you can add this line directly into .envrc
:
use flake "github:dnswd/dev-templates?dir=${ENV}"
By directly declaring flakes in the .envrc
you can compose multiple flakes:
use flake "github:dnswd/dev-templates?dir=python"
use flake "github:dnswd/dev-templates?dir=cpp"
Composing flakes may not always be the best idea, as Nix honors the flake listed last in case of a clash, for example in the case of two buildInputs named cargo that refer to different versions of Cargo.
Once your preferred template has been initialized, you can use the provided shell in two ways:
- If you have
nix-direnv
installed, you can initialize the environment by runningdirenv allow
. - If you don't have
nix-direnv
installed, you can runnix develop
to open up the Nix-defined shell.
Language/framework/tool | Template |
---|---|
Clojure | clojure |
Cue | cue |
Dhall | dhall |
Elixir | elixir |
Elm | elm |
Gleam | gleam |
Go | go |
Hashicorp tools | hashi |
Java | java |
Kotlin | kotlin |
Nickel | nickel |
Nim | nim |
Nix | nix |
Node.js | node |
OCaml | ocaml |
Open Policy Agent | opa |
PHP | php |
Protobuf | protobuf |
Purescript | purescript |
Ruby | ruby |
Rust | rust |
Scala | scala |
Zig | zig |
The sections below list what each template includes. In all cases, you're free to add and remove packages as you see fit; the templates are just boilerplate.
- Dhall 1.40.2
- dhall-bash
- dhall-csv (Linux only)
- dhall-docs
- dhall-json
- dhall-lsp-server
- dhall-nix
- dhall-nixpkgs
- dhall-openapi
- dhall-text (Linux only)
- dhall-toml
- dhall-yaml
- Gleam 0.22.1
- Go 1.19
- Standard Go tools (goimports, godoc, and others)
- golangci-lint
- Packer 1.8.2
- Terraform 1.2.7
- Nomad 1.2.9
- Vault 1.11.2
- nomad-autoscaler 0.3.6-dev
- nomad-pack 0.0.1-techpreview.3
- levant 0.3.1-dev
- damon
- Terragrunt 0.37.0
- tflint 0.39.3
- Nickel 0.2.0
- OCaml 4.13.1
- Dune 3.4.1
- odoc 2.1.1
- ocamlformat 0.24.0
- Open Policy Agent 0.43.0
- Conftest 0.34.0
- Python 3.11.0rc1
- pip 22.1.2
- Virtualenv 20.15.1
- mach-nix
- Ruby 3.1.2p20, plus the standard Ruby tools (
bundle
,gem
, etc.)
-
Rust, including cargo, Clippy, and the other standard tools. The Rust version is determined as follows, in order:
- From the
rust-toolchain.toml
file if present - From the
rust-toolchain
file if present - Version 1.63.0 if neither is present
- From the
-
rust-analyzer 2022-08-01
-
cargo-audit 0.17.0
-
cargo-deny 0.12.1
-
cross 0.2.4
- Zig 0.9.1
All of the templates have only the root flake as a flake input. That root flake provides a common revision of Nixpkgs and flake-utils
to all the templates.