[buoh/ci-bump: 3/4] nix: Clean up
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [buoh/ci-bump: 3/4] nix: Clean up
- Date: Tue, 14 Jul 2020 00:11:52 +0000 (UTC)
commit 03af8ba16d1dd328d8683ddc9d17c48ad756dd00
Author: Jan Tojnar <jtojnar gmail com>
Date: Tue Jul 14 01:21:00 2020 +0200
nix: Clean up
Rewrite the comments to be more understandable, remove some sharp edges like the need to clean build
directory, and format the expression.
README.md | 2 +-
default.nix | 111 ++++++++++++++++++++++++++++++++++++++----------------------
shell.nix | 17 +++++++---
3 files changed, 85 insertions(+), 45 deletions(-)
---
diff --git a/README.md b/README.md
index 62ef1f6..991a9b7 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ Buoh aims to help the comic lovers by providing an easy way of browsing and read
* Merge requests: https://gitlab.gnome.org/GNOME/buoh/merge_requests
## Building
-For building Buoh, you will need `meson`, `ninja` and `pkgconfig`, as well as the following libraries with
their development headers.
+For building Buoh, you will need `meson`, `ninja` and `pkg-config`, as well as the following libraries with
their development headers.
* `glib2`
* `gtk3`
diff --git a/default.nix b/default.nix
index d53b9a5..13dc285 100644
--- a/default.nix
+++ b/default.nix
@@ -1,25 +1,38 @@
-# 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 use?
+***********
-# How to tweak default arguments?
+If you have Nix installed, you can get an environment with everything
+needed to compile buoh by running:
-# nix-shell supports the --arg option (see Nix doc) that allows you for
-# instance to do this:
-# $ nix-shell --arg doCheck false
+ $ nix-shell
-# 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.
+at the root of the buoh repository.
+
+You can also compile buoh and ‘install’ it by running:
+
+ $ nix-build
+
+at the root of the buoh repository. The command will install
+buoh to a location under Nix store and create a ‘result’ symlink
+in the current directory pointing to the in-store location.
+
+How to tweak default arguments?
+*******************************
+
+Nix supports the ‘--arg’ option (see nix-build(1)) that allows you
+to override the top-level arguments.
+
+For instance, to use your local copy of nixpkgs:
+
+ $ nix-build --arg pkgs "import $HOME/Projects/nixpkgs {}"
+
+Or to speed up the build by not running the test suite:
+
+ $ nix-build --arg doCheck false
+
+*/
{ pkgs ?
(import (fetchTarball {
@@ -28,43 +41,61 @@
}) {})
, doCheck ? true
, shell ? false
- # We don't use lib.inNixShell because that would also apply
+ # We do not 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 {
-
+let
+ inherit (pkgs.stdenv) lib;
+in pkgs.stdenv.mkDerivation rec {
name = "buoh";
- nativeBuildInputs = [
- meson ninja pkgconfig gettext python3 xvfb_run libxslt wrapGAppsHook
+ src =
+ let
+ # Do not copy to the store:
+ # - build directory, since Meson will want to use it
+ # - .git directory, since it would unnecessarily bloat the source
+ cleanSource = path: _: !lib.elem (builtins.baseNameOf path) [ "build" ".git" ];
+ in
+ if shell then null else builtins.filterSource cleanSource ./.;
+
+ # Dependencies for build platform
+ nativeBuildInputs = with pkgs; [
+ meson
+ ninja
+ pkg-config
+ gettext
+ python3
+ xvfb_run
+ libxslt
+ wrapGAppsHook
];
- buildInputs = [
- glib gtk3 libsoup libxml2
+ # Dependencies for host platform
+ buildInputs = with pkgs; [
+ glib
+ gtk3
+ libsoup
+ libxml2
];
- checkInputs = [
- desktop-file-utils appstream-glib
+ checkInputs = with pkgs; [
+ desktop-file-utils
+ appstream-glib
];
- src =
- if shell then null
- else
- with builtins; filterSource
- (path: _: !elem (baseNameOf path) [ ".git" "result" ]) ./.;
+ inherit doCheck;
+
+ # Hardening does not work in debug mode
+ hardeningDisable = lib.optionals shell [ "all" ];
checkPhase = ''
+ runHook preCheck
+
export NO_AT_BRIDGE=1
xvfb-run -s '-screen 0 800x600x24' \
meson test --print-errorlogs
- '';
-
- # Hardening does not work in debug mode
- hardeningDisable = optionals shell [ "all" ];
- inherit doCheck;
+ runHook postCheck
+ '';
}
diff --git a/shell.nix b/shell.nix
index 3cb7758..ae8057f 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,7 +1,16 @@
-# 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
+/*
+
+Some developers do not want a pinned package set by default.
+If you want to use the pinned nix-shell or a more sophisticated set of arguments:
+
+ $ nix-shell default.nix --arg shell true
+
+*/
+
+{ pkgs ? import <nixpkgs> {}
+, doCheck ? true
+}:
import ./default.nix {
- pkgs = import <nixpkgs> {};
+ inherit pkgs doCheck;
shell = true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]