-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
huginn: init at 2016-09-14 #18590
huginn: init at 2016-09-14 #18590
Conversation
@mogorman, thanks for your PR! By analyzing the annotation information on this pull request, we identified @edolstra, @joachifm and @offlinehacker to be potential reviewers |
fixed merge conflict |
bumped id number again to fix merge conflict |
What's up with the need to add ~3,600 lines of code to the main repo for a single package and a service? |
the majority of the bloat was just defining the config file completely so it can be easily configured by nix. it isn't really bloat is it? |
@@ -0,0 +1,169 @@ | |||
Encoding.default_external = Encoding::UTF_8 |
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.
This file could be probably replaced by
source "https://rubygems.org"
gem 'huginn', git: "https://github.com/cantino/huginn.git", ref: '005be58d30181b1e0ca5b29cc9a8729ee0d7bcab'
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.
ok, this will not work, because you apply patches.
preStart = '' | ||
rm -rf ${cfg.statePath}/tmp | ||
mkdir -p ${cfg.statePath}/log | ||
mkdir -p ${cfg.statePath}/tmp/pids |
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.
can be replaced by a single mkdir:
mkdir -p ${cfg.statePath}/log ${cfg.statePath}/tmp/{pids,cache,sockets}
mkdir -p ${cfg.statePath}/tmp/sockets | ||
touch ${cfg.statePath}/tmp/secrets | ||
if [ "${cfg.appSecretToken}" = "" ]; then |
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.
In general, can you fix the indentation?
${config.services.postgresql.package}/bin/createdb --owner ${cfg.databaseUser} ${cfg.databaseName} huginn || true | ||
if [ "${cfg.databasePassword}" = "" ]; then | ||
echo "creating db" | ||
${huginn-rake}/bin/huginn-rake db:create RAILS_ENV=production APP_SECRET_TOKEN="null" DATABASE_PASSWORD=`cat ${cfg.statePath}/db-password` |
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.
rake accepts multiple tasks at once: ${huginn-rake}/bin/huginn-rake db:create db:migrate db:seed
|
||
in { | ||
|
||
options = { |
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.
wow, many options here. This could be split into a separate file probably
cp -r . $out/share/huginn | ||
cp ${gemfile} $out/share/huginn/Gemfile | ||
cp ${lockfile} $out/share/huginn/Gemfile.lock | ||
#I dont know why these need to exist but what can i say |
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.
here you could also use a single mkdir
|
||
installPhase = '' | ||
export LD_LIBRARY_PATH=${curl.out}/lib:${postgresql}/lib | ||
RAILS_ENV=production APP_SECRET_TOKEN=REPLACE_ME_NOW! DATABASE_ADAPTER=nulldb HUGINN_STATE_PATH=tmp/ SKIP_STORAGE_VALIDATION=true bundle exec rake assets:precompile |
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.
this could be break into multiple lines using \
for readability.
ASSET_HOST=cfg.assetHost; | ||
FORCE_SSL= (if cfg.forceSSL then "true" else "false"); | ||
INVITATION_CODE=cfg.registration.invitationCode; | ||
SKIP_INVITATION_CODE=(if cfg.registration.skipInvitation then "true" else "false"); |
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.
maybe replace by a helper function:
toBool = option : if option then "true" else "false";
...
SKIP_INVITATION_CODE=(toBool cfg.registration.skipInvitation);
echo "migrating db" | ||
${huginn-rake}/bin/huginn-rake db:migrate RAILS_ENV=production APP_SECRET_TOKEN="null" | ||
echo "seeding db" | ||
${huginn-rake}/bin/huginn-rake db:seed RAILS_ENV=production APP_SECRET_TOKEN="null" SEED_USERNAME=${cfg.initialUser} SEED_PASSWORD=${cfg.initialPassword} SKIP_INVITATION_CODE=true REQUIRE_CONFIRMED_EMAIL=false |
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.
what happens if you pass DATABASE_PASSWORD=
to rake? If this works you could save the if expression.
if [ "${cfg.appSecretToken}" = "" ]; then | ||
printf "APP_SECRET_TOKEN=" >> ${cfg.statePath}/tmp/secrets | ||
tr -dc A-Za-z0-9 < /dev/urandom 2> /dev/null | head -c 32 >> ${cfg.statePath}/tmp/secrets | ||
echo "" >> ${cfg.statePath}/tmp/secrets |
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.
printf 'APP_SECRET_TOKEN=%s\n' "$(tr -dc A-Za-z0-9 < /dev/urandom 2> /dev/null|head -c32)" > ${cfg.statePath}/tmp/secrets
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.
maybe this could be also wrapped and reused in a shell function
gen_secret() {
printf "$1=%s\n" "$(tr -dc A-Za-z0-9 < /dev/urandom 2> /dev/null|head -c32)" > "$2"
}
gen_secret "APP_SECRET_TOKEN" "${cfg.statePath}/tmp/secrets"
@mogorman I would also like to see this finished. Do you need any help? |
This would really be nice to have. Might work on it later if nobody picks this up. |
Motivation for this change
This is a new package huginn, http://github.com/cantino/huginn , it is an agent platform. This is my first service module, as well as my first ruby package. I would appreciate people looking it over. this pr also depends on #18361 or it can't be built due to unicode ruby files in the dependencies. I would also like to backport this into 16.09 after master if someone could show me how.
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)