-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup dev dependencies using nix flakes and devenv.sh
See https://devenv.sh/ and https://github.com/direnv/direnv. Start your development environment by copying .envrc.example to .envrc and use `direnv allow` to enable. After the build completes (it is cached) you can run `devenv up` to start PostgreSQL on port 6543. Use `devenv test` to create the databases and run the tests.
- Loading branch information
1 parent
7e87209
commit 6a33f31
Showing
4 changed files
with
355 additions
and
0 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,5 @@ | ||
# Use Nix to setup development dependencies, github hooks, and services with `devenv`. | ||
# See `flake.nix` for the setup. | ||
watch_file flake.nix | ||
watch_file flake.lock | ||
use flake . --no-pure-eval |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,85 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling"; | ||
systems.url = "github:nix-systems/default"; | ||
devenv.url = "github:cachix/devenv"; | ||
devenv.inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
nixConfig = { | ||
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="; | ||
extra-substituters = "https://devenv.cachix.org"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, devenv, systems, ... } @ inputs: | ||
let | ||
forEachSystem = nixpkgs.lib.genAttrs (import systems); | ||
in | ||
{ | ||
packages = forEachSystem (system: { | ||
devenv-up = self.devShells.${system}.default.config.procfileScript; | ||
devenv-test = self.devShells.${system}.default.config.test; | ||
}); | ||
|
||
devShells = forEachSystem | ||
(system: | ||
let | ||
postgresPort = 6543; | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
in | ||
{ | ||
default = devenv.lib.mkShell { | ||
inherit inputs pkgs; | ||
modules = [ | ||
{ | ||
env.PGPORT = postgresPort; | ||
|
||
enterTest = '' | ||
reset-database | ||
run-tests | ||
''; | ||
|
||
git-hooks.hooks.rubocop = { | ||
enable = true; | ||
name = "rubocop"; | ||
types = [ "ruby" ]; | ||
excludes = [ | ||
"^docs/.*$" | ||
"^integration-specs/rails-app/(bin|db)/.*$" | ||
"^integration-specs/rails-app/config/puma.rb$" | ||
]; | ||
entry = "bundle exec rubocop"; | ||
}; | ||
|
||
languages.ruby = { | ||
enable = true; | ||
package = pkgs.ruby; | ||
}; | ||
|
||
services.postgres = { | ||
enable = true; | ||
listen_addresses = "127.0.0.1"; | ||
port = postgresPort; | ||
initialScript = '' | ||
CREATE ROLE sequent LOGIN SUPERUSER; | ||
''; | ||
settings = { | ||
log_min_duration_statement = "100ms"; | ||
}; | ||
}; | ||
|
||
# https://devenv.sh/reference/options/ | ||
packages = with pkgs; [ | ||
libyaml | ||
pkg-config | ||
postgresql | ||
]; | ||
|
||
scripts.run-tests.exec = "bundle exec rspec"; | ||
scripts.reset-database.exec = "SEQUENT_ENV=test bundle exec rake sequent:db:drop sequent:db:create"; | ||
} | ||
]; | ||
}; | ||
}); | ||
}; | ||
} |