Skip to content
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 flake #11732

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ HOST ?= localhost
PORT ?= 3000
GZIP_COMMAND ?= gzip
ARTIFACT_DESTINATION_FILE ?= ./tmp/idp.tar.gz
OS := $(shell uname)
IS_NIXOS := $(shell grep -q NixOS /etc/os-release && echo true)

.PHONY: \
analytics_events \
Expand Down Expand Up @@ -219,8 +221,18 @@ tmp/$(HOST)-$(PORT).key tmp/$(HOST)-$(PORT).crt: ## Self-signed cert for local H
-keyout tmp/$(HOST)-$(PORT).key \
-out tmp/$(HOST)-$(PORT).crt

ifeq ($(OS), Darwin)
run: browsers.json ## Runs the development server
foreman start -p $(PORT)
else ifeq ($(OS), Linux)
ifeq ($(IS_NIXOS), true)
run: browsers.json
goreman -b $(PORT) start
else
run: browsers.json
foreman start -p $(PORT)
endif
endif

urn:
@echo "⚱️"
Expand Down
9 changes: 7 additions & 2 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,22 @@ Dir.chdir APP_ROOT do
run "cp pwned_passwords/pwned_passwords.txt.sample pwned_passwords/pwned_passwords.txt"

puts "\n== Installing dependencies =="
brew_installed = system "brew -v 2>&1"
brew_installed = system "brew -v >/dev/null 2>&1"
run "brew bundle" if brew_installed
run "gem install bundler --conservative"
run 'gem install foreman --conservative && gem update foreman'
run "bundle check || bundle install --without deploy production"
run "yarn install"

is_nixos = system "grep -q NixOS /etc/os-release && echo true"
puts "\n== NixOS detected ==" if is_nixos
puts "Please add Redis to your NixOS configuration" if is_nixos
puts " services.redis.servers.\"\".enable = true;" if is_nixos

puts "\n== Stopping running services to ensure clean start =="
run "brew services stop --all" if brew_installed

puts "\n== Starting services =="
puts "\n== Starting services ==" if brew_installed
run "brew services start redis" if brew_installed
run "brew services start postgresql@14" if brew_installed

Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
description = "DevShell for identity-idp";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{ nixpkgs, flake-utils, ... }:

flake-utils.lib.eachDefaultSystem (
system:

let
pkgs = import nixpkgs {
inherit system;
};
in
{
devShell =
with pkgs;

mkShell {
buildInputs = [
ruby
yarn
openssl.dev
postgresql.dev
libyaml.dev
zlib.dev
goreman # Use goreman since nginx launch will fail gracefully and launch Puma, as opposed to when using foreman
];

shellHook = ''
export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig:${pkgs.postgresql.dev}/lib/pkgconfig:${pkgs.libyaml.dev}/lib/pkgconfig:${pkgs.zlib.dev}/lib/pkgconfig:$PKG_CONFIG_PATH";
'';
};
}
);
}