- Nix 100%
| .envrc | ||
| flake.nix | ||
| README.md | ||
nix-flake-template
Template flake for my own use, if you stumble upon this repo, feel free to use it.
Note
Generative AI has been used in making this flake template.
Features
Easy to drop-in, general-purpose development flake template that comes with:
- configuration for project details
- Packages
- Development shell
- Build, Run and Install with the flake (nix build, nix run, nix profile install .)
- Language templates:
- Shell
- Generic (C, C++, etc.)
- Python
- Rust
- Gleam (with gleescript)
- Go
- Zig
nix flake clone git+https://codeberg.org/Katacc/nix-flake-template --dest .
Just set your project name in (usually the same as in your Cargo.toml for example), uncomment the technology you are using, declare packages and make sure the build section is correct.
There is also included some extra niceties for rust developing like:
- Naersk
- rust-overlay
You just need to uncomment them and wire them to the inputs.
Then you are ready for developing
# Direnv and nix-direnv users
direnv allow
# Normal devshell users
nix develop
# Build
nix build
# Run the app
nix run
# If using profiles,
# You can install the app to your profile
nix profile install .
Note
The flake will not run without uncommenting one package definition!
Extra info
Rust
If you use the normal rust package definition without naersk, nix build will recompile
cargo dependencies each time you run or build through nix, which is fine for production
application, but for developing, you probably want to use cargo commands or use naersk
narsk allows the use of cargo cache so nix doesnt need to rebuild everything each time! lucky for you, naersk is allready included as a package definition, just start using it, uncomment the imports and such and include naersk in your inputs
Gleam
The gleam package requires you to commit your gleam packages to the git repo.
gleam deps download
git add build/packages -f
nix run