Skip to content

Commit

Permalink
refactor: Move to DevEnv (#139)
Browse files Browse the repository at this point in the history
This pull request includes significant changes to the project
configuration by removing Nix-related files and dependencies. The
primary goal is to simplify the development environment setup.

Configuration cleanup:

*
[`.idx/dev.nix`](diffhunk://#diff-f125b5c587e59caaff53b6f8d462794de438d6c035ad281c5beebcabff623d9eL1-L55):
Removed the entire Nix configuration, including packages, environment
variables, and workspace setup.
*
[`flake.nix`](diffhunk://#diff-206b9ce276ab5971a2489d75eb1b12999d4bf3843b7988cbe8d687cfde61dea0L1-L86):
Deleted the flake configuration file, which included inputs, outputs,
and development environment setups.

Other changes:

*
[`.envrc`](diffhunk://#diff-d33e979799a45c7c51752e9c8d96a3e452015d1a40b1e4b6ec6a98e92c4d8430L1):
Removed the use of the `flake` command.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Chores**
- Removed configuration files for development environment setup,
including `.envrc`, `.idx/dev.nix`, and `flake.nix`, streamlining the
project by eliminating unused dependencies and configurations.
- Updated `.gitignore` to include new entries for `devenv` environment
files and modified existing entries for clarity.
- Removed specific VSCode extension recommendations to simplify the
development environment.
- **New Features**
- Introduced `devenv.nix` and `devenv.yaml` for a more accessible
development environment configuration.
- Updated `README.md` to reflect the shift to Devenv, providing clearer
instructions for users.
- **Bug Fixes**
- Adjusted spell-check settings in `.vscode/settings.json` to include
new terms relevant to the project.
- **Updates**
- Updated `go.mod` to reflect changes in dependency versions and
management.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
blackfyre authored Oct 29, 2024
1 parent 9127255 commit 79a8556
Show file tree
Hide file tree
Showing 16 changed files with 802 additions and 656 deletions.
4 changes: 3 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
use flake
source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k="

use devenv
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ meta.json
/blob-report/
/playwright/.cache/

.direnv
.direnv# Devenv
.devenv*
devenv.local.nix

# direnv
.direnv

# pre-commit
.pre-commit-config.yaml
55 changes: 0 additions & 55 deletions .idx/dev.nix

This file was deleted.

2 changes: 0 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"recommendations": [
"mjmlio.vscode-mjml",
"sibiraj-s.vscode-scss-formatter",
"esbenp.prettier-vscode",
"alexcvzz.vscode-sqlite",
"mrmlnc.vscode-scss"
]
}
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
"awid",
"bluemonday",
"bulma",
"cachix",
"Cloners",
"cssnano",
"daisyui",
"daos",
"devenv",
"esbuild",
"fontawesome",
"fsys",
Expand All @@ -37,6 +39,8 @@
"metafile",
"migratecmd",
"Miklós",
"nixos",
"nixpkgs",
"onclick",
"outbase",
"outdir",
Expand All @@ -50,5 +54,6 @@
"trix",
"Upsert",
"viewerjs"
]
],
"codeQL.githubDatabase.download": "never"
}
32 changes: 12 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,23 @@ The database is populated on first start, and if you want to have images availab

This will go through the contents of the database and will use placeholder images to "generate" the necessary images to the designated S3 compatible file hosting solution designated in the `.env` file.

## With Nix
## With DevEnv

This project has a Nix `flake.nix` with the full development environment configuration in it. Start it with:
Devenv is a Nix based development environment that's more easily accessible than a pure nix based approach.
You can check [devenv.sh](https://devenv.sh/getting-started/) for installation and usage details.

```sh
nix develop
```

If you want to start the development environment automatically when entering the directory, [install direnv](https://direnv.net/docs/installation.html) and run `direnv allow` in this directory.


### First time installing Nix
For first-time setup:

With Nix installed, you do not need to install Go, ASDF, node, npm, bun or other development tools. **Nix package manager** will handle it for you, and makes sure the versions are correct for this project. This has been tested on both Linux and macOS.
Nix is a package manager for the whole system/development environment, not just 1 part of it, like NPM is for Node. There is also NixOS, which works in the same way but for the whole OS, making it declarative and versioned. The config in this project works for both. With the Nix Flake in this project, you are using Nix only to manage the development environment.
1. Install Devenv following the [getting started guide](https://devenv.sh/getting-started/)
2. (optional) copy the `devenv.local.stub.nix` file to `devenv.local.nix`
3. Run `devenv up` to start the development environment

### Install Nix package manager

For both Linux and macOS, you can use the installer from determinate systems. On the site [Zero to nix](https://zero-to-nix.com/start) you can find more info to get started.

```sh
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
```
Checking the [/devenv.nix](devenv.nix) file for more details is also recommended.
This file contains:

If you installed Nix differently, make sure that you **[enable flakes](https://nixos.wiki/wiki/Flakes)**. [Flake concepts explained](https://zero-to-nix.com/concepts/flakes). Flakes are experimental, but highly recommended and included with Nix for years.
- Development dependencies
- Environment variables
- Service configurations

## License

Expand Down
Binary file modified bun.lockb
Binary file not shown.
6 changes: 6 additions & 0 deletions devenv.local.stub.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ pkgs, lib, config, inputs, ... }:

{
services.minio.accessKey = "minio";
services.minio.secretKey = "minio123";
}
116 changes: 116 additions & 0 deletions devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1730028891,
"owner": "cachix",
"repo": "devenv",
"rev": "a337f8862efa9bde348c48a48b5b943f710604dd",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1716977621,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "4267e705586473d3e5c8d50299e71503f16a6fb6",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1729973466,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cd3e8833d70618c4eea8df06f95b364b016d4950",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1729104314,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},
"root": "root",
"version": 7
}
60 changes: 60 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{ pkgs, lib, config, inputs, ... }:

{

# https://devenv.sh/packages/
packages = [
pkgs.git
pkgs.templ
] ++ lib.optionals (!config.container.isBuilding) [
pkgs.flyctl
pkgs.nil
];

# https://devenv.sh/languages/
# languages.rust.enable = true;

languages.go.enable = true;
languages.go.enableHardeningWorkaround = true;

languages.javascript = {
enable = true;
bun = {
enable = true;
install.enable = true;
};
};

services.mailhog.enable = true;

services.minio.enable = true;
services.minio.buckets = [
"wga"
];

enterShell = ''
bun --version
git --version
go version
'';

scripts.generate-templates.exec = "templ generate";
scripts.tidy-modules.exec = "go mod tidy";
scripts.tidy.exec = ''
devenv shell generate-templates
devenv shell tidy-modules
'';
pre-commit.hooks = {
govet = {
enable = true;
pass_filenames = false;
};
gotest.enable = true;
golangci-lint = {
enable = true;
pass_filenames = false;
};
};

# See full reference at https://devenv.sh/reference/options/
}
14 changes: 14 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
# If you're using non-OSS software, you can set allowUnfree to true.
# allowUnfree: true

# If you're willing to use a package that's vulnerable
# permittedInsecurePackages:
# - "openssl-1.1.1w"

# If you have more than one devenv you can merge them
#imports:
# - ./backend
Loading

0 comments on commit 79a8556

Please sign in to comment.