~edwardloveall/scribe

0c018a898a0c8c6f78f45f2c5248c62e8fbc87a4 — Martin Puppe a month ago 56b6d54
Add support for development with Nix

This patch adds support for development with the Nix package manager. In
order to support the traditional nix-shell tool as well as the (still
experimental) Nix Flakes feature of the upcoming version of Nix, this
patch adds shell.nix *and* flake.nix/flake.lock.  Usage instructions
have been added to the README.
4 files changed, 83 insertions(+), 1 deletions(-)

M README.md
A flake.lock
A flake.nix
A shell.nix
M README.md => README.md +17 -1
@@ 12,12 12,28 @@ Hopefully a more comprehensive guide will be written at some point, but for now 

## Contributing

1. [Install required dependencies](https://luckyframework.org/guides/getting-started/installing#install-required-dependencies)
1. Install required dependencies (see sub-sections below)
1. Run `script/setup`
1. Run `lucky dev` to start the app
1. [Send a patch](https://man.sr.ht/git.sr.ht/#sending-patches-upstream) to `~edwardloveall/Scribe@lists.sr.ht` (yes that's an email address).
  * To be honest, I'm not sure how I feel about the send patch git workflow as opposed to the GitHub style pull request workflow. I'm trying it out for now. If you can't figure it out, get in contact and we can figure out a way to get your contributions in.

### Installing dependencies

General instructions for installing Lucky and its dependencies can be found at <https://luckyframework.org/guides/getting-started/installing#install-required-dependencies>.

### Installing dependencies with Nix

If you are using the [Nix](https://nixos.org/) package manager, you can get a shell with all dependencies with the following command(s):

``` shell
nix-shell

# Or if you are using the (still experimental) Nix Flakes feature
nix flake update # Update dependencies (optional)
nix develop
```

### Learning Lucky

Lucky uses the [Crystal](https://crystal-lang.org) programming language. You can learn about Lucky from the [Lucky Guides](https://luckyframework.org/guides/getting-started/why-lucky).

A flake.lock => flake.lock +41 -0
@@ 0,0 1,41 @@
{
  "nodes": {
    "flake-utils": {
      "locked": {
        "lastModified": 1631561581,
        "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1634282420,
        "narHash": "sha256-YOI78SSF4Q/ZFoEgfO8Xy3EnjCW/F9VgB2Qz9YljzhI=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "0a68ef410b40f49de76aecb5c8b5cc5111bac91d",
        "type": "github"
      },
      "original": {
        "id": "nixpkgs",
        "type": "indirect"
      }
    },
    "root": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}

A flake.nix => flake.nix +8 -0
@@ 0,0 1,8 @@
{
  inputs = { flake-utils.url = "github:numtide/flake-utils"; };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let pkgs = nixpkgs.legacyPackages.${system};
      in { devShell = import ./shell.nix { inherit pkgs; }; });
}

A shell.nix => shell.nix +17 -0
@@ 0,0 1,17 @@
{ pkgs ? import <nixpkgs> { } }:

pkgs.mkShell {
  shellHook = ''
    export PKG_CONFIG_PATH=${pkgs.openssl.dev}/lib/pkgconfig
  '';
  buildInputs = with pkgs; [
    crystal
    lucky-cli
    overmind
    nodejs
    openssl.dev
    postgresql
    shards
    yarn
  ];
}