-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from tennox/devenv
π§βπ» add nix flake & devenv
- Loading branch information
Showing
8 changed files
with
600 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# Docs: https://direnv.net/ | ||
|
||
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then | ||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" | ||
fi | ||
|
||
nix_direnv_watch_file devenv.nix | ||
|
||
use flake . --impure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Setting up a devenv | ||
|
||
1. Install [nix](https://github.com/DeterminateSystems/nix-installer) (or install the required dependencies yourself, but for e.g. tests, there are a lot) | ||
2. Install [direnv](https://direnv.net/) (optional, recommended for ease of use) | ||
3. Run `direnv allow` / `nix develop --impure` | ||
|
||
### Tests | ||
Note: I did not manage to set up all dependencies yet - e.g. java tests are failing | ||
```bash | ||
# enter shell: | ||
nix develop --impure .#test | ||
# run directly: | ||
nix develop --impure .#test -c cargo test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Docs: https://devenv.sh/basics/ | ||
{ pkgs, ... }: { | ||
name = "tk test"; | ||
|
||
# Extend main devenv: | ||
imports = [ ./devenv.nix ]; | ||
|
||
languages = { | ||
# Docs: https://devenv.sh/languages/ | ||
java.enable = true; | ||
javascript.enable = true; | ||
python.enable = true; | ||
}; | ||
|
||
packages = with pkgs; [ | ||
# Search for packages: https://search.nixos.org/packages?channel=unstable&query=cowsay | ||
# (note: this searches on unstable channel, be aware your nixpkgs flake input might be on a release channel) | ||
|
||
go-task | ||
gnumake | ||
deno | ||
sbt | ||
go-task | ||
cargo-make | ||
jbang | ||
|
||
#handled by `languages` above: | ||
# python3 | ||
# nodejs | ||
# adoptopenjdk-jre-bin | ||
]; | ||
|
||
env = { | ||
NODE_HOME = "${pkgs.nodejs}"; | ||
# JAVA_HOME = "${pkgs.adoptopenjdk-jre-bin.home}"; - seems to be handled by languages.java | ||
JBANG_HOME = "${pkgs.jbang}/bin"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Docs: https://devenv.sh/basics/ | ||
{ pkgs, ... }: { | ||
|
||
languages = { | ||
# Docs: https://devenv.sh/languages/ | ||
nix.enable = true; | ||
rust = { | ||
enable = true; # https://github.com/cachix/devenv/blob/main/src/modules/languages/rust.nix | ||
channel = "nightly"; | ||
}; | ||
}; | ||
|
||
packages = with pkgs; [ | ||
# Search for packages: https://search.nixos.org/packages?channel=unstable&query=cowsay | ||
# (note: this searches on unstable channel, be aware your nixpkgs flake input might be on a release channel) | ||
cargo-watch | ||
]; | ||
|
||
#difftastic.enable = true; # Better git diff https://devenv.sh/integrations/difftastic/ | ||
|
||
pre-commit.hooks = { | ||
# Docs: https://devenv.sh/pre-commit-hooks/ | ||
# available pre-configured hooks: https://devenv.sh/reference/options/#pre-commithooks | ||
# adding hooks which are not included: https://github.com/cachix/pre-commit-hooks.nix/issues/31 | ||
nixpkgs-fmt.enable = true; # nix formatting | ||
nil.enable = true; # nix check | ||
|
||
clippy.enable = true; | ||
#cargo-check.enable = true; β alternative to clippy | ||
}; | ||
} |
Oops, something went wrong.