forked from sile-typesetter/sile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
108 lines (105 loc) · 3.78 KB
/
flake.nix
File metadata and controls
108 lines (105 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
description = "Simon’s Improved Layout Engine";
# To make user overrides of the nixpkgs flake not take effect
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
outputs = { self
, nixpkgs
, flake-utils
, flake-compat
, gitignore
}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
# TODO: Should this be replaced with libtexpdf package from nixpkgs? or
# should we keep it that way, so that it'd be easy to test new versions
# of libtexpdf when developing?
libtexpdf-src = builtins.fetchGit {
url = "https://github.com/sile-typesetter/libtexpdf";
rev = "${(pkgs.lib.fileContents "${self}/libtexpdf.git-rev")}";
};
inherit (gitignore.lib) gitignoreSource;
# https://discourse.nixos.org/t/passing-git-commit-hash-and-tag-to-build-with-flakes/11355/2
version_rev = if (self ? rev) then (builtins.substring 0 8 self.rev) else "dirty";
# Use the expression from Nixpkgs instead of rewriting it here.
sile = pkgs.sile.overrideAttrs(oldAttr: rec {
version = "${(pkgs.lib.importJSON ./package.json).version}-${version_rev}-flake";
src = pkgs.lib.cleanSourceWith {
# Ignore many files that gitignoreSource doesn't ignore, see:
# https://github.com/hercules-ci/gitignore.nix/issues/9#issuecomment-635458762
filter = path: type:
! (builtins.any (r: (builtins.match r (builtins.baseNameOf path)) != null) [
# Nix files
"flake.nix"
"flake.lock"
"default.nix"
"shell.nix"
# git commit and editing format files
".commitlintrc.yml"
"package.json"
".husky"
".editorconfig"
# CI files
".cirrus.yml"
"action.yml"
"azure-pipelines.yml"
"Dockerfile"
# Git files
".github"
".gitattributes"
".gitignore"
".git"
])
;
src = gitignoreSource ./.;
};
# Add the libtexpdf src instead of the git submodule.
preAutoreconf = ''
rm -rf ./libtexpdf
# From some reason without this flag, libtexpdf/ is unwriteable
cp --no-preserve=mode -r ${libtexpdf-src} ./libtexpdf/
'';
# Pretend to be a tarball release so sile --version will not say `vUNKNOWN`.
postAutoreconf = ''
echo ${version} > .tarball-version
'';
# Don't build the manual as it's time consuming, and it requires fonts
# that are not available in the sandbox due to internet connection
# missing.
configureFlags = pkgs.lib.lists.remove "--with-manual" oldAttr.configureFlags;
nativeBuildInputs = oldAttr.nativeBuildInputs ++ [
pkgs.autoreconfHook
];
# TODO: This switch between the hooks can be moved to Nixpkgs'
postPatch = oldAttr.preConfigure;
preConfigure = "";
meta = oldAttr.meta // {
changelog = "https://github.com/sile-typesetter/sile/raw/master/CHANGELOG.md";
};
});
in rec {
devShell = pkgs.mkShell {
inherit (sile) checkInputs nativeBuildInputs buildInputs;
};
packages.sile = sile;
defaultPackage = sile;
apps.sile = {
type = "app";
program = "${sile}/bin/sile";
};
defaultApp = apps.sile;
}
);
}