aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsudoforge <no-reply@sudoforge.com>2024-07-18 21:01:04 -0700
committersudoforge <9c001b67637a@sudoforge.com>2024-07-20 16:45:55 -0700
commitbf753031d012b106ddafff2e3bfd4422db5e4935 (patch)
treeea47f526e9036e0ae09bf6bd76f2007e896dcc5f
parenteda0d6723978fa19711b538bf1e9641537959bb3 (diff)
downloadgit-bug-bf753031d012b106ddafff2e3bfd4422db5e4935.tar.gz
feat: add initial nix development shell
This change bootstraps the configuration of a development shell via nix. Change-Id: Ic171e7599b50bb29ecc07d9c4534bcbc117f2299
-rw-r--r--.envrc20
-rw-r--r--.gitignore6
-rw-r--r--CONTRIBUTING.md99
-rw-r--r--flake.lock61
-rw-r--r--flake.nix34
5 files changed, 220 insertions, 0 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 00000000..9b41f79b
--- /dev/null
+++ b/.envrc
@@ -0,0 +1,20 @@
+# this is required for versions of direnv older than 2.29.0, since they do not
+# support `use flake`, and is recommended in all cases, since it caches the
+# environment and prevents dependencies from being garbage-collected by nix.
+if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then
+ source_url \
+ "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" \
+ "sha256-RuwIS+QKFj/T9M2TFXScjBsLR6V3A17YVoEW/Q6AZ1w="
+fi
+
+# allow extending this .envrc with a user-defined .envrc.local
+source_env_if_exists .envrc.local
+
+# load the development shell defined in the flake.nix file
+# note: this automatically watches the following files:
+# - flake.nix
+# - flake.lock
+use flake
+
+# files to watch
+watch_file .envrc.local
diff --git a/.gitignore b/.gitignore
index c61d1233..d21e45da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,9 @@ dist
coverage.txt
.idea/
.git_bak*
+
+# nix and direnv related tooling
+.envrc
+.envrc.local
+/.direnv/
+!/.envrc
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..e929d672
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,99 @@
+# Contributing
+
+:wave: Hey there! Thanks for considering taking the time to contribute to
+`git-bug`. This page contains some general guidelines, and instructions for
+getting started as a contributor to this project.
+
+## Get the source code
+
+Clone this repository to your system in a way you're comfortable with. Below, we
+show a command that [clones the repository][how-to-clone] using SSH, and places
+it in `~/code/git-bug`.
+
+```
+git clone git@github.com:MichaelMure/git-bug ~/code/git-bug
+```
+
+> [!IMPORTANT]
+> If you wish to clone the repository to another location on disk, change
+> `~/code/git-bug` to your desired path. The rest of this documentation will
+> refer to `~/code/git-bug` in all instances, so make sure you change them
+> there, too.
+
+## Software recommendations
+
+While you can install Golang and hack on this project on your own, you're likely
+to have a better experience if you install the following software.
+
+### <a name="install-nix"></a> `nix` (_recommended_)
+
+[`nix`][install/nix] is used in this repository to provide a common development
+shell, with a complete set of the appropriate version of the tools used to work
+on `git-bug`.
+
+You can install `nix` by following [the official instructions][install/nix], but
+we recommend adding some additional flags in order to enable some (technically
+experimental, but largely stable) configuration options:
+
+```
+curl -L https://nixos.org/nix/install | sh -s -- --daemon --nix-extra-conf-file <( \
+cat << EOF | sed -e 's/^ *//'
+ experimental-features = nix-command flakes
+EOF
+)
+```
+
+> [!TIP]
+> Make sure you read the prompts from the installation script carefully. After
+> installation, you'll need to start a new shell.
+
+### <a name="install-direnv"></a> `direnv` (_recommended_)
+
+[`direnv`][install/direnv] is used to automatically activate the development
+shell (because of the `.envrc` in the root of this repository).
+
+#### <a name="install-direnv-with-nix"></a> With `nix`
+
+> [!IMPORTANT]
+> If you are not comfortable with `nix`, we recommend [installing `direnv`
+> without nix][install/install-direnv-without-nix].
+
+```
+nix --extra-experimental-options 'flakes nix-command' profile install nixpkgs\#direnv
+```
+
+There's a second step that is critical -- be sure to [configure your
+shell][install/direnv/shell].
+
+#### <a name="install-direnv-without-nix"></a> Without `nix`
+
+You can install `direnv` by following [the official
+instructions][install/direnv]. There's a second step that is critical -- be sure
+to [configure your shell][install/direnv/shell].
+
+After installation, you'll need to start a new shell.
+
+##### <a name="direnv-config"></a> direnv configuration (_recommended_)
+
+If you install `direnv`, it is recommended to set the following configuration
+options to improve your user experience. At the time of writing, these go in
+`~/.config/direnv/direnv.toml`.
+
+This configuration, namely, the `whitelist.exact` property, will ensure that
+`direnv` always automatically sources the `.envrc` in this repository.
+
+```
+hide_env_diff = true
+warn_timeout = 0
+
+[whitelist]
+exact = ["~/code/git-bug/.envrc"]
+```
+
+> [!IMPORTANT]
+> Make sure you change the `~/code/git-bug` portion of the string to the
+> appropriate path (the path that you cloned this repository to on your system).
+
+[install/nix]: https://nix.dev/install-nix
+[install/direnv]: https://github.com/direnv/direnv/blob/master/docs/installation.md
+[install/direnv/shell]: https://github.com/direnv/direnv/blob/master/docs/hook.md
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 00000000..a88843cc
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,61 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1710146030,
+ "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1721138476,
+ "narHash": "sha256-+W5eZOhhemLQxelojLxETfbFbc19NWawsXBlapYpqIA=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "ad0b5eed1b6031efaed382844806550c3dcb4206",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 00000000..10cb36bf
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,34 @@
+{
+ description = "workspace configuration for git-bug";
+
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ flake-utils.url = "github:numtide/flake-utils";
+ };
+
+ outputs =
+ {
+ self,
+ flake-utils,
+ nixpkgs,
+ }:
+ flake-utils.lib.eachDefaultSystem (
+ system:
+ let
+ pkgs = nixpkgs.legacyPackages.${system};
+ in
+ {
+ devShell = pkgs.mkShell {
+ packages = with pkgs; [
+ codespell
+ gh
+ git
+ go
+ golangci-lint
+ nixfmt-rfc-style
+ nodePackages.prettier
+ ];
+ };
+ }
+ );
+}