about summary refs log tree commit diff
path: root/nixpkgs/doc
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-09-08 00:46:04 +0000
committerAlyssa Ross <hi@alyssa.is>2019-09-16 22:13:21 +0000
commitafcf2d55332c5c01c2d989e9d010577d257cb6cc (patch)
treee1c816a271686b014a6403bcad7c57dd2ee4d9c7 /nixpkgs/doc
parent175b9acd282aaf65b5f354ea6e95c1348fe3daa3 (diff)
parent4e60699fa727e4a0f9a3e78948012f86da32cfef (diff)
downloadnixlib-afcf2d55332c5c01c2d989e9d010577d257cb6cc.tar
nixlib-afcf2d55332c5c01c2d989e9d010577d257cb6cc.tar.gz
nixlib-afcf2d55332c5c01c2d989e9d010577d257cb6cc.tar.bz2
nixlib-afcf2d55332c5c01c2d989e9d010577d257cb6cc.tar.lz
nixlib-afcf2d55332c5c01c2d989e9d010577d257cb6cc.tar.xz
nixlib-afcf2d55332c5c01c2d989e9d010577d257cb6cc.tar.zst
nixlib-afcf2d55332c5c01c2d989e9d010577d257cb6cc.zip
Merge commit '4e60699fa727e4a0f9a3e78948012f86da32cfef'
Diffstat (limited to 'nixpkgs/doc')
-rw-r--r--nixpkgs/doc/languages-frameworks/crystal.section.md71
-rw-r--r--nixpkgs/doc/languages-frameworks/index.xml1
-rw-r--r--nixpkgs/doc/package-specific-user-notes.xml4
3 files changed, 74 insertions, 2 deletions
diff --git a/nixpkgs/doc/languages-frameworks/crystal.section.md b/nixpkgs/doc/languages-frameworks/crystal.section.md
new file mode 100644
index 000000000000..07bfc65a553f
--- /dev/null
+++ b/nixpkgs/doc/languages-frameworks/crystal.section.md
@@ -0,0 +1,71 @@
+# Crystal
+
+## Building a Crystal package
+
+This section uses [Mint](https://github.com/mint-lang/mint) as an example for how to build a Crystal package.
+
+If the Crystal project has any dependencies, the first step is to get a `shards.nix` file encoding those. Get a copy of the project and go to its root directory such that its `shard.lock` file is in the current directory, then run `crystal2nix` in it
+```bash
+$ git clone https://github.com/mint-lang/mint
+$ cd mint
+$ git checkout 0.5.0
+$ nix-shell -p crystal2nix --run crystal2nix
+```
+
+This should have generated a `shards.nix` file.
+
+Next create a Nix file for your derivation and use `pkgs.crystal.buildCrystalPackage` as follows:
+```nix
+with import <nixpkgs> {};
+crystal.buildCrystalPackage rec {
+  pname = "mint";
+  version = "0.5.0";
+
+  src = fetchFromGitHub {
+    owner = "mint-lang";
+    repo = "mint";
+    rev = version;
+    sha256 = "0vxbx38c390rd2ysvbwgh89v2232sh5rbsp3nk9wzb70jybpslvl";
+  };
+
+  # Insert the path to your shards.nix file here
+  shardsFile = ./shards.nix;
+
+  ...
+}
+```
+
+This won't build anything yet, because we haven't told it what files build. We can specify a mapping from binary names to source files with the `crystalBinaries` attribute. The project's compilation instructions should show this. For Mint, the binary is called "mint", which is compiled from the source file `src/mint.cr`, so we'll specify this as follows:
+
+```nix
+  crystalBinaries.mint.src = "src/mint.cr";
+
+  # ...
+```
+
+Additionally you can override the default `crystal build` options (which are currently `--release --progress --no-debug --verbose`) with
+
+```nix
+  crystalBinaries.mint.options = [ "--release" "--verbose" ];
+```
+
+Depending on the project, you might need additional steps to get it to compile successfully. In Mint's case, we need to link against openssl, so in the end the Nix file looks as follows:
+
+```nix
+with import <nixpkgs> {};
+crystal.buildCrystalPackage rec {
+  version = "0.5.0";
+  pname = "mint";
+  src = fetchFromGitHub {
+    owner = "mint-lang";
+    repo = "mint";
+    rev = version;
+    sha256 = "0vxbx38c390rd2ysvbwgh89v2232sh5rbsp3nk9wzb70jybpslvl";
+  };
+
+  shardsFile = ./shards.nix;
+  crystalBinaries.mint.src = "src/mint.cr";
+
+  buildInputs = [ openssl_1_0_2 ];
+}
+```
diff --git a/nixpkgs/doc/languages-frameworks/index.xml b/nixpkgs/doc/languages-frameworks/index.xml
index 4564df98fe99..cd4e95cfae69 100644
--- a/nixpkgs/doc/languages-frameworks/index.xml
+++ b/nixpkgs/doc/languages-frameworks/index.xml
@@ -32,4 +32,5 @@
  <xi:include href="titanium.section.xml" />
  <xi:include href="vim.section.xml" />
  <xi:include href="emscripten.section.xml" />
+ <xi:include href="crystal.section.xml" />
 </chapter>
diff --git a/nixpkgs/doc/package-specific-user-notes.xml b/nixpkgs/doc/package-specific-user-notes.xml
index 196c760251f0..a176f4d13959 100644
--- a/nixpkgs/doc/package-specific-user-notes.xml
+++ b/nixpkgs/doc/package-specific-user-notes.xml
@@ -6,7 +6,7 @@
          answer some of the frequently asked questions
          related to Nixpkgs use.
 
-  Some useful information related to package use 
+  Some useful information related to package use
   can be found in <link linkend="chap-package-notes">package-specific development notes</link>.
 
  </para>
@@ -196,7 +196,7 @@ overrides = self: super: rec {
   haskell-mode = self.melpaPackages.haskell-mode;
   ...
 };
-((emacsPackagesNgGen emacs).overrideScope' overrides).emacsWithPackages (p: with p; [
+((emacsPackagesGen emacs).overrideScope' overrides).emacsWithPackages (p: with p; [
   # here both these package will use haskell-mode of our own choice
   ghc-mod
   dante