Verified Commit 03af8ba1 authored by Jan Tojnar's avatar Jan Tojnar
Browse files

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.
parent 78f3ca46
......@@ -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`
......
# 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
'';
}
# 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;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment