Coder Social home page Coder Social logo

headcounter / shabitica Goto Github PK

View Code? Open in Web Editor NEW
144.0 12.0 16.0 1.81 MB

Run your own self-hosted Habitica instance

License: GNU General Public License v3.0

Nix 77.94% Python 9.36% Shell 1.19% Haskell 10.51% Mustache 1.00%
nix nixos nixos-service habitica self-hosted

shabitica's Introduction

Shabitica - Self-hosted Habitica

This is a fork of Habitica, a habit tracker which treats your goals like a Role Playing Game.

The main target OS for this project is NixOS and while it is possible to run it on other distributions/operating systems running Nix it will be harder to set up.

Differences from the upstream project

Primarily the goal is to track the upstream project as much as possible and contribute back any changes that might be useful for Habitica overall.

However, there are a few fundamental differences we can't (easily) get upstream:

Do not use any 3rd-party services

The upstream project has a lot of them, ranging from payment providers to analytics, social integration and more. In order to make sure we don't accidentally introduce new 3rd-party services we have canaries in the source build that check for certain services.

Sandboxing by default whenever possible

We're running Habitica in a network namespace with only the loopback interface available. Communication with services such as the mailer or the database is done solely via UNIX Domain Sockets.

Instead of the MongoDB NixOS service we run our own MongoDB service patched to support systemd startup notifications and only connecting via UNIX Domain Sockets as well.

This is to make sure we have a very low attack surface and ideally compromising the service should only affect Habitica itself and not other services running on the machine.

Invite-only by default

Only allow to publicly register the first user. Attempts to register another user will only work via invitation link.

Free subscriptions for all users

We have stripped out all payment systems, so getting gems can be done by converting Gold into Gems. All features requiring a subscription are also unlocked for every user.

Use a custom mailer daemon

Habitica uses Mandrill for sending emails and the templates for these emails are not publicly available. So we do have our own mailer daemon, which replicates the API endpoints required to send it out. Right now the daemon only supports sending via the sendmail binary.

No censorship of messages

Word banning is not only error prone but also doesn't make sense on private servers (if the person you've invited does offend you, why did you invite them?) and can be easily circumvented anyway (eg. using unicode).

No support for the mobile apps

Maintaining forks for these apps would be way too much work and would also make it difficult to run without 3rd-party services, so the long term goal is to make the browser client less painful on mobile phones.

Getting started on NixOS

Simply adding the path of the source to the imports list of your NixOS configuration (typically /etc/nixos/configuration.nix) will start a local instance.

While the source tree can be obtained by cloning this repository (or using fetchGit/fetchTarball), it's recommended to use one of the Hydra channels, which only contain the latest tested version of the source code.

If you're on NixOS 20.09, you can add the channel via:

# nix-channel --add https://headcounter.org/hydra/channel/custom/shabitica/nixos-20.09/shabitica
# nix-channel --update shabitica

If you're on NixOS 21.05, you can add the channel via:

# nix-channel --add https://headcounter.org/hydra/channel/custom/shabitica/nixos-21.05/shabitica
# nix-channel --update shabitica

If you're using NixOS Unstable, you can add it like this:

# nix-channel --add https://headcounter.org/hydra/channel/custom/shabitica/nixos-unstable/shabitica
# nix-channel --update shabitica

Example configuration

{
  imports = [ <shabitica> ];
  shabitica.hostName = "shabitica.example.org";
  shabitica.adminMailAddress = "[email protected]";
  shabitica.senderMailAddress = "[email protected]";
}

This configures Shabitica to run on shabitica.example.org with an NGINX reverse proxy. If you don't provide any options, it will run on your local machine only.

Please take a look at latest manual for all of the available options.

Development/Testing

There is a Nix expression in a file called tools/build-vm.nix, which builts a script to boot up a local VM with a fully running Shabitica instance, useful for testing and development.

The NGINX web server listening on port 3000 is forwarded to the host, so you can access Shabitica by pointing your browser at http://localhost:3000/.

All mails sent within than VM (to any address) are routed to the root user's mailbox which can be viewed by simply running mutt inside the VM. This is particularly useful if you want to add another user, so you can send an invitation mail and get the link via mutt.

This should also work on other distributions running Nix.

shabitica's People

Contributors

aszlig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shabitica's Issues

Is anyone still working on this?

Hello,
last commit is over a year ago, is this project abandoned or will it be picked up again?
And would this still work or would there be problems installing because it tried to pull a version that is too old of habitica?

Adding shabitica channel makes `nix-env` stop working

This might be expected, and it's not a big deal because I don't do imperative package management on the server that runs my instance of shabitica, but if I add the shabitica channel like:

nix-channel --add https://headcounter.org/hydra/channel/custom/shabitica/nixos-18.09/shabitica shabitica

and do a nix-channel --update, then calling nix-env -qa as a root user gives:

error: cannot auto-call a function that has an argument without a default value ('config')

This error stops as soon as I remove the shabitica channel.

Is this something that's expected and I just should either not be adding shabitica as a channel or not mixing it with imperative package management?

Errors when running nixos-rebuild switch

Hello,

I'm super sorry if it turns out to be noob-ness. I'm trying to run up a shabitica instance and am having all kinds of issues. Important note is that I've never used NixOS before last night so have been limping along based on hours of Google searches and blind luck.

NixOS Version: 18.09
Host: Hyper-V on Server 2019 - Gen-2 UEFI

Installed NixOS based on the instructions here

Added the hydra channels by running the 2 commands in the readme.
Originally it was failing to get something (sorry didn't take note of it, it was failing to get something from the hydra server). But after finding and running the nix-env -u '*' command in the hydra repo, it doesn't show the error anymore (don't know if it's related).

Using the configuration.nix file here

Took me forever to get the configuration file not to instantly fail. Had no idea if the code from the readme should be the total config or if it needed to be merged with the default. This config was the closest I've gotten.

Now when I run it, it runs for a while and then hits a ton of errors:

fixed-output derivation produced path '/nix/store/zl42hmz2y3xk29iryp96z2zvwya0ykx4-google-fonts-apidoc' with sha256 hash '02y4i0f8xdv5bqzlymir2dqihlf578474453sdrhrw4sijyljp3v' instead of the expected hash '1x0z8r8nb5pj073dyx66b25w9hxs33k07bhbj5cbgf5pyx3589x1'

building '/nix/store/cakyj1q3rnss28mqz0zan47a0jirf0m8-habitica-source-4.92.3.drv'...

cannot build derivation '/nix/store/m90vfamzav4013zhkbi8i7ia71kj1hx0-node-apidoc-0.17.7.drv': 1 dependencies couldn't be built

building '/nix/store/3rxc3wlyq8cyl6vw81yy0j1pqpilqmxb-query-db-version.drv'...

cannot build derivation '/nix/store/4vrjs69kj4z4qfj161zvf2a7g29vz6ny-shabitica-apidoc-4.92.3.drv': 1 dependencies couldn't be built

cannot build derivation '/nix/store/anw1v8h9cj9l90viirfasqlhhqn2lqbf-shabitica-client-4.92.3.drv': 1 dependencies couldn't be built

cannot build derivation '/nix/store/ki19p4aym1rsq20hf7sgywkwbyciy4q3-shabitica-migrator-4.92.3.drv': 1 dependencies couldn't be built

cannot build derivation '/nix/store/58gz8zfaqnysgmrmip6bwhb4rz3i4pfn-shabitica-server-4.92.3.drv': 1 dependencies couldn't be built

cannot build derivation '/nix/store/kjjs3pd2875c4jz54wkq6ziif8zk4byc-closure-info.drv': 1 dependencies couldn't be built

cannot build derivation '/nix/store/94j9jlskbbyjr5981388kl2r1v1kj5jw-nginx.conf.drv': 1 dependencies couldn't be built

cannot build derivation '/nix/store/kmcba83zd91xhpfg2gh2qq5s374wvpc6-unit-script-shabitica-db-update-start.drv': 1 dependencies couldn't be built

cannot build derivation '/nix/store/d7ywbj0qf5q5k71n10h9jnzf2pdf6lff-unit-shabitica.service.drv': 1 dependencies couldn't be built

building '/nix/store/dqsly1xgmvsnpm70h2f2d8k5js9gsj3n-remove-references-to.drv'...

cannot build derivation '/nix/store/w65hmalhwwx1ifwakk017w68yqri9iq5-shabitica-sandbox-paths.drv': 1 dependencies couldn't be built

cannot build derivation '/nix/store/4chz21mp8j7crra28qbrmkzagdy78y7y-system-units.drv': 1 dependencies couldn't be built

cannot build derivation '/nix/store/rygfcxkv2bln3irdlabqwmh8yh5idad0-etc.drv': 1 dependencies couldn't be built

cannot build derivation '/nix/store/n2ais7in5xxki403ac545pizcamcdwsr-nixos-system-habitica-01-18.09.2505.46d3867a08a.drv': 1 dependencies couldn't be built

error: build of '/nix/store/n2ais7in5xxki403ac545pizcamcdwsr-nixos-system-habitica-01-18.09.2505.46d3867a08a.drv' failed

Would be happy to write out a "for dummies by a dummy" guide to help others if this is something silly simple?

git:// not working anymore, can't change git:// to https://

Hello,

it would be a lot of fun to have my own shabitica running.

When I try to build shabitica on NixOS 21.05, then the build is stopping:

exporting git://github.com/habitrpg/vuejs-datepicker.git (rev 5d237615463a84a23dd6f3f77c6ab577d68593ec) into /nix/store/fxnrc3799iylgkmrc469w2gffhwg97iw-vuejs-datepicker-5d23761
Initialized empty Git repository in /nix/store/fxnrc3799iylgkmrc469w2gffhwg97iw-vuejs-datepicker-5d23761/.git/
fatal: unable to connect to github.com:
github.com[0: 140.82.121.3]: errno=Connection timed out

The git:// is not working anymore.

Normally I would change the git:// to https:// with e. g. "git config --global url.https://.insteadOf git://"
or change it /etc/gitconfig to

[url "https://"]
insteadOf = git://

But since the buildscript is running as nixosbld1, it does ignore the git:// to https:// changes in the /etc/gitconfig".

Do you maybe have a workaround for this?

Best regards, Frank

What about docker ?

I appreciate the idea and good luck with that !
But with a docker image, it will be so much better. ;)
You probably have your reasons to stick with nix, but it makes this project quite difficult to get into.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.