-
-
Notifications
You must be signed in to change notification settings - Fork 447
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
Add Nix as a installation method #4185
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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,22 @@ | ||
**Nix** | ||
|
||
If you have [Nix](https://nixos.org) installed you can use the [flake.nix](flake.nix) configuration file located at the root of the project to build and develop within an environment without needing to install `rvm`, `postgresql` or other tools separately. | ||
The environment also uses the `gemset.nix` file to automatically download and install all the gems necessary to get the server up and running. This means you will not need run `bundle exec` or any `bundle` commands. | ||
|
||
INSTRUCTIONS: | ||
|
||
1. Install [Nix](https://zero-to-nix.com/concepts/nix-installer) | ||
2. Add the following to `~/.config/nix/nix.conf` or `/etc/nix/nix.conf`: | ||
|
||
``` | ||
experimental-features = nix-command flakes | ||
``` | ||
|
||
3. `cd` into human-essentials | ||
4. Copy `.env.example` to `.env` and set correct values | ||
5. `nix develop` and wait for the packages to be downloaded and the environment to be built | ||
6. If the Gemfile changes run `update-deps` to update `gemset.nix` | ||
|
||
The database will be created when running `nix develop` for the first time. If you did not set up your `.env` and database creating failed you can run `setup-db` or use `rails db:` commands. | ||
|
||
This will run on Linux and macOS. |
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,145 @@ | ||
{ | ||
description = "A Ruby dev environment for Human Essentials Development"; | ||
|
||
nixConfig = { | ||
extra-substituters = "https://nixpkgs-ruby.cachix.org"; | ||
extra-trusted-public-keys = | ||
"nixpkgs-ruby.cachix.org-1:vrcdi50fTolOxWCZZkw0jakOnUI1T19oYJ+PRYdK4SM="; | ||
}; | ||
|
||
inputs = { | ||
nixpkgs.url = "nixpkgs"; | ||
ruby-nix = { | ||
url = "github:inscapist/ruby-nix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
bundix = { | ||
url = "github:inscapist/bundix/main"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
fu.url = "github:numtide/flake-utils"; | ||
bob-ruby = { | ||
url = "github:bobvanderlinden/nixpkgs-ruby"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
outputs = { self, nixpkgs, fu, ruby-nix, bundix, bob-ruby }: | ||
with fu.lib; | ||
eachDefaultSystem (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ bob-ruby.overlays.default ]; | ||
}; | ||
rubyNix = ruby-nix.lib pkgs; | ||
|
||
gemset = | ||
if builtins.pathExists ./gemset.nix then import ./gemset.nix else { }; | ||
|
||
gemConfig = { | ||
mini_racer = attrs: { | ||
buildInputs = [ pkgs.icu ]; | ||
dontBuild = false; | ||
NIX_LDFLAGS = "-licui18n"; | ||
}; | ||
libv8-node = | ||
let | ||
noopScript = pkgs.writeShellScript "noop" "exit 0"; | ||
linkFiles = pkgs.writeShellScript "link-files" '' | ||
cd ../.. | ||
|
||
mkdir -p vendor/v8/${system}/libv8/obj/ | ||
ln -s "${pkgs.nodejs_18.libv8}/lib/libv8.a" "vendor/v8/${system}/libv8/obj/libv8_monolith.a" | ||
|
||
ln -s ${pkgs.nodejs_18.libv8}/include vendor/v8/include | ||
|
||
mkdir -p ext/libv8-node | ||
echo '--- !ruby/object:Libv8::Node::Location::Vendor {}' >ext/libv8-node/.location.yml | ||
''; | ||
in | ||
attrs: { | ||
dontBuild = false; | ||
postPatch = '' | ||
cp ${noopScript} libexec/build-libv8 | ||
cp ${noopScript} libexec/build-monolith | ||
cp ${noopScript} libexec/download-node | ||
cp ${noopScript} libexec/extract-node | ||
cp ${linkFiles} libexec/inject-libv8 | ||
''; | ||
}; | ||
}; | ||
|
||
updateDeps = pkgs.writeScriptBin "update-deps" (builtins.readFile | ||
(pkgs.substituteAll { | ||
src = ./scripts/nix-update.sh; | ||
bundix = "${pkgs.bundix}/bin/bundix"; | ||
})); | ||
setupDb = pkgs.writeScriptBin "setup-db" (builtins.readFile | ||
(pkgs.substituteAll { | ||
src = ./scripts/nix-db-setup.sh; | ||
})); | ||
|
||
# See available versions here: https://github.com/bobvanderlinden/nixpkgs-ruby/blob/master/ruby/versions.json | ||
ruby = pkgs."ruby-3.2.2"; | ||
|
||
bundixcli = bundix.packages.${system}.default; | ||
in rec { | ||
inherit (rubyNix { | ||
inherit gemset ruby; | ||
name = "ruby-env-human-essentials"; | ||
gemConfig = pkgs.defaultGemConfig // gemConfig; | ||
}) | ||
env; | ||
|
||
devShells = rec { | ||
default = dev; | ||
dev = pkgs.mkShell { | ||
BUNDLE_FORCE_RUBY_PLATFORM = "true"; | ||
shellHook = '' | ||
export PS1='\n\[\033[1;34m\][💎:\w]\$\[\033[0m\] ' | ||
|
||
# Setup postgres database | ||
export PGHOST=$HOME/postgres | ||
export PG_HOST=$PGHOST | ||
export PGDATA=$PGHOST/data | ||
export PGDATABASE=postgres | ||
export PGLOG=$PGHOST/postgres.log | ||
|
||
mkdir -p $PGHOST | ||
|
||
if [ ! -d $PGDATA ]; then | ||
initdb --auth=trust --no-locale --encoding=UTF8 | ||
pg_ctl start -l $PGLOG -o "--unix_socket_directories='$PGHOST'" | ||
setup-db | ||
fi | ||
|
||
if ! pg_ctl status | ||
then | ||
pg_ctl start -l $PGLOG -o "--unix_socket_directories='$PGHOST'" | ||
fi | ||
|
||
trap 'pg_ctl stop -D "$PGDATA" -s -m fast' EXIT | ||
''; | ||
|
||
buildInputs = [ | ||
env | ||
updateDeps | ||
setupDb | ||
bundixcli | ||
pkgs.bundix | ||
pkgs.bundler-audit | ||
pkgs.direnv | ||
pkgs.git | ||
pkgs.gnumake | ||
pkgs.libpcap | ||
pkgs.libpqxx | ||
pkgs.libxml2 | ||
pkgs.libxslt | ||
pkgs.pkg-config | ||
pkgs.postgresql | ||
]; | ||
}; | ||
}; | ||
}); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk why but sassc is very unhappy unless the line is fixed,