-
Notifications
You must be signed in to change notification settings - Fork 77
/
flake.nix
90 lines (87 loc) · 3.14 KB
/
flake.nix
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
{
# This is a template created by `hix init`
inputs = {
haskellNix.url = "github:input-output-hk/haskell.nix";
nixpkgs.follows = "haskellNix/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
};
outputs = { self, nixpkgs, flake-utils, haskellNix, nix-filter }:
flake-utils.lib.eachDefaultSystem (system:
let
linker-workaround = pkgs: pkgs.writeShellScript "linker-workaround" ''
# put all flags into 'params' array
source ${pkgs.stdenv.cc}/nix-support/utils.bash
expandResponseParams "$@"
# check if '-shared' flag is present
printf '%s\0' "''${params[@]}" | grep -qFxze '-shared'
hasShared=$?
if [[ "$hasShared" -eq 0 ]]; then
exec "$CC" @<(printf '%q\n' "''${params[@]}" | grep -vFxe '-static')
else
# if '-shared' is not set, don't modify the params
exec "$CC" @<(printf '%q\n' "''${params[@]}")
fi
'';
hixProject = {ghc ? "ghc966"}: pkgs.haskell-nix.cabalProject' {
compiler-nix-name = ghc;
src = nix-filter.lib {
root = ./.;
include = [
./docs
./lib
./lib-internal
./src
./test
./pandoc-crossref.cabal
./cabal.project.freeze
./cabal.project
./Setup.hs
./.gitignore
./LICENSE
./README.md
./CHANGELOG.md
];
};
modules = [({pkgs, ...}: with pkgs; {
packages.pandoc-crossref.ghcOptions =
lib.optional stdenv.hostPlatform.isMusl "-pgml=${linker-workaround pkgs}";
})];
};
overlays = [ haskellNix.overlay ];
pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
flake_ = args: (hixProject args).flake {
crossPlatforms = ps: with ps; [ musl64 ];
};
flake = flake_ {};
in {
packages = {
default = flake.packages."pandoc-crossref:exe:pandoc-crossref";
static = flake.packages."x86_64-unknown-linux-musl:pandoc-crossref:exe:pandoc-crossref";
pandoc = (hixProject {}).hsPkgs.pandoc-cli.components.exes.pandoc;
pandoc-with-crossref = pkgs.symlinkJoin {
name = "pandoc-with-crossref";
paths = with self.packages.${system}; [ default pandoc ];
};
};
apps = {
default = flake.apps."pandoc-crossref:exe:pandoc-crossref";
test = flake.apps."pandoc-crossref:test:test-pandoc-crossref";
test-integrative = flake.apps."pandoc-crossref:test:test-integrative";
};
devShells.default = pkgs.mkShell {
buildInputs = [ self.packages.${system}.pandoc-with-crossref ];
};
});
# --- Flake Local Nix Configuration ----------------------------
nixConfig = {
extra-substituters = [
"https://cache.iog.io"
"https://pandoc-crossref.cachix.org"
];
extra-trusted-public-keys = [
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
"pandoc-crossref.cachix.org-1:LI9ABFTkGpPCTkUTzoopVSSpb1a26RSTJNMsqVbDtPM="
];
};
}