Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init project #1

Merged
merged 10 commits into from
Nov 20, 2023
Merged
7 changes: 7 additions & 0 deletions .cz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "$version"
version_scheme = "semver"
version = "0.1.0"
update_changelog_on_bump = true
major_version_zero = true
8 changes: 8 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi

if ! use flake .#dev --impure
then
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi
20 changes: 20 additions & 0 deletions .github/workflows/check-on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Run various checks on merge (pull) request"

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
check:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4

- name: Complete nix setup
uses: DeterminateSystems/nix-installer-action@main

- name: pre-commit checks
run: nix develop .#dev --impure --command bash -c "pre-commit run --all-files"

- name: Check the flake
run: nix develop .#dev --impure --command bash -c "nix flake check --impure --show-trace"
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# OS generated files #
######################
.DS_Store
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db

# IDEA Ignores #
################
*.iml
*.ipr
*.iws
.idea/
out/
local.properties

# Project related #
################
result/
build/

result
.direnv/
.devenv/

.devcontainer.json
.pre-commit-config.yaml
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

## 0.1.0 (2023-11-20)

### Feat

- **README**: add usage note
- **README**: add a proper README
- **main-template**: add other examples, add some documentation
- **CI**: add github and gitlab default config
- **project**: add conventional commits and changelog
- **main-template**: add main template + devenv, treefmt, examples
- **main-template**: init
- **flake**: init dev environment
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
# practical-flakes-template
# practical-flakes-template

## Description

_PracticalFlakes_ are a set of highly opinionated templates to quickly bootstrap
your next [nix](https://github.com/NixOS/nix) project in
[flakes](https://nixos.wiki/wiki/Flakes) 😎

To quickly initialize a new project run

```bash
nix flake init -t github:tsandrini/practical-flakes-template
```

And you're good to go! 👍

## Features

1. Drop-in modularity using
[flake-parts](https://github.com/hercules-ci/flake-parts) ⚙️
- the main idea is that if you have a bunch of projects using this template you
can simply just copy the individual `parts/` directories to share functionality
- this way, no matter if you're developing language features, packages,
[NixOS modules](https://nixos.wiki/wiki/NixOS_Modules),
[home-manager](https://github.com/nix-community/home-manager) userspace,
you can always use the same underlying structure
2. [devenv.sh](https://github.com/cachix/devenv) is awesome! 🔥
- includes a devenv shell already preconfigured to format and lint nix
3. [treefmt](https://github.com/numtide/treefmt) is the one and only formatter
to rule them all 🙏
4. Already preconfigured [github actions](https://docs.github.com/en/actions)
and [gitlab CI](ttps://docs.gitlab.com/ee/ci/) 💪
5. Prepared for custom `lib` overrides 🤓
- depending on what you're currently aiming to write, you might need some
custom helpers or library functions, this template
already set ups all the necessary boilerplate to get it all going
6. And finally, examples included 🖌️

## Usage

After a proper installation process you can enter the development environment

1. either using [direnv](https://github.com/direnv/direnv) `direnv allow`
2. or directly `nix develop .#dev --impure`

While not many, the code has some required references to the `practicalFlake`
identifier. This can be renamed in the whole project using the script
`rename-project` (which is available in the dev environment)

```bash
rename-project . myAwesomeApp
```

## Resources
Loading