[buoh/ci: 1/2] build: Add Nix expression



commit fa46bdbbcca67043994d0897c92cfd3fd5181413
Author: Jan Tojnar <jtojnar gmail com>
Date:   Wed Aug 29 15:27:54 2018 +0200

    build: Add Nix expression
    
    Nix [1] is purely functional package manager allowing to easily
    install dependencies in a reproducible manner.
    
    The expression is mostly taken from Coq [2] verbatim.
    
    [1]: https://nixos.org/nix/
    [2]: https://gitlab.com/coq/coq/blob/master/default.nix

 README.md   |  2 ++
 default.nix | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 shell.nix   |  7 +++++++
 3 files changed, 70 insertions(+)
---
diff --git a/README.md b/README.md
index ac51368..62ef1f6 100644
--- a/README.md
+++ b/README.md
@@ -21,5 +21,7 @@ ninja -C build
 ninja -C build install
 ```
 
+Alternately, with [Nix package manager](https://nixos.org/nix/), you can just run `nix-shell` in the project 
directory, and it will drop you into a shell with all the required dependencies.
+
 ## License
 Buoh is distributed under the terms of the GNU General Public License version 2, or (at your option) any 
later version. You can find the whole text of the license in the [COPYING](COPYING) file.
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..cc202b4
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,61 @@
+# How to use?
+
+# If you have Nix installed, you can get in an environment with everything
+# needed to compile buoh by running:
+# $ nix-shell
+# at the root of the buoh repository.
+
+# How to tweak default arguments?
+
+# nix-shell supports the --arg option (see Nix doc) that allows you for
+# instance to do this:
+# $ nix-shell --arg doCheck false
+
+# You can also compile buoh and "install" it by running:
+# $ rm -rf build # (only needed if you have left-over compilation files)
+# $ nix-build
+# at the root of the buoh repository.
+# nix-build also supports the --arg option, so you will be able to do:
+# $ nix-build --arg doCheck false
+# if you want to speed up things by not running the test-suite.
+# Once the build is finished, you will find, in the current directory,
+# a symlink to where buoh was installed.
+
+{ pkgs ?
+    (import (fetchTarball {
+      url = "https://github.com/NixOS/nixpkgs/archive/4477cf04b6779a537cdb5f0bd3dd30e75aeb4a3b.tar.gz";;
+      sha256 = "1i39wsfwkvj9yryj8di3jibpdg3b3j86ych7s9rb6z79k08yaaxc";
+    }) {})
+, doCheck ? true
+, shell ? false
+  # We don't use lib.inNixShell because that would also apply
+  # when in a nix-shell of some package depending on this one.
+}:
+
+with pkgs;
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+
+  name = "buoh";
+
+  nativeBuildInputs = [
+    meson ninja pkgconfig gettext python3 wrapGAppsHook
+  ];
+
+  buildInputs = [
+    glib gtk3 libsoup libxml2
+  ];
+
+  checkInputs = [
+    desktop-file-utils
+  ];
+
+  src =
+    if shell then null
+    else
+      with builtins; filterSource
+        (path: _: !elem (baseNameOf path) [ ".git" "result" ]) ./.;
+
+  inherit doCheck;
+}
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 0000000..3cb7758
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1,7 @@
+# Some developers don't want a pinned nix-shell by default.
+# If you want to use the pin nix-shell or a more sophisticated set of arguments:
+# $ nix-shell default.nix --arg shell true
+import ./default.nix {
+  pkgs = import <nixpkgs> {};
+  shell = true;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]