on master help sign in
compaREST/default.nix
114 lines 3.4 kB history raw
1{ sources ? import ./nix/sources.nix
2, haskellNix ? import sources.haskellNix { inherit system; }
3, pkgs ? import haskellNix.sources.nixpkgs-2105 (haskellNix.nixpkgsArgs // { inherit system; })
4, system ? builtins.currentSystem
5, nix-filter ? import sources.nix-filter
6}:
7let
8 masterPkgs = import sources.nixpkgs { inherit system; };
10 hsPkgs = pkgs.haskell-nix.stackProject {
11 src = nix-filter {
12 root = ./.;
13 name = "compaREST";
14 include = [
15 ./stack.yaml
16 ./stack.yaml.lock
17 ./compaREST.cabal
18 ];
19 };
21 modules = [
22 {
23 dontStrip = false;
24 dontPatchELF = false;
25 enableDeadCodeElimination = true;
26 ghcOptions = [
27 "-O2"
28 "-fexpose-all-unfoldings"
29 "-fspecialise-aggressively"
30 ];
31 packages.pandoc.ghcOptions = [ "-O1" ];
32 packages.compaREST.src = nix-filter {
33 root = ./.;
34 name = "compaREST-src";
35 include = with nix-filter; [
36 (./compaREST.cabal)
37 (inDirectory ./test)
38 (inDirectory ./src)
39 (inDirectory ./app)
40 (inDirectory ./github-action)
41 ./awsm-css/dist/awsm.min.css
42 ./LICENSE
43 ];
44 };
45 }
46 ];
47 };
49 staticify = name: drv: pkgs.runCommand name { } ''
50 mkdir -p $out/bin
51 cp ${drv + "/bin"}/* $out/bin
53 ${pkgs.nukeReferences}/bin/nuke-refs $out/bin/*
54 '';
56 compaRESTBin = hsPkgs.compaREST.components.exes.compaREST;
57 compaRESTStaticBin = (staticify "compaREST-static" hsPkgs.projectCross.musl64.hsPkgs.compaREST.components.exes.compaREST);
60 # doesn't work
61 armDarwinCompaREST = hsPkgs.projectCross.aarch64-darwin.hsPkgs.compaREST.components.exes.compaREST;
63 compaRESTImage = pkgs.dockerTools.buildImage {
64 name = "compaREST";
65 contents = [ compaRESTStaticBin ];
66 config = {
67 Entrypoint = [ "/bin/compaREST" ];
68 };
69 };
71 macOSCompaRESTBundle = pkgs.runCommand "compaREST-macOS-bundled"
72 {
73 buildInputs = [ masterPkgs.macdylibbundler ];
74 } ''
75 mkdir -p $out/lib
76 cp ${compaRESTBin}/bin/compaREST $out/compaREST
77 chmod 755 $out/compaREST
78 dylibbundler -b \
79 -x $out/compaREST \
80 -d $out/lib \
81 -p '@executable_path/lib'
82 '';
85 compaRESTGithubAction =
86 let
87 action = staticify "compaREST-GitHub-Action-static" hsPkgs.projectCross.musl64.hsPkgs.compaREST.components.exes.compaREST-GitHub-Action;
88 wrapped = pkgs.runCommand "wrapped-compaREST-GitHub-Action" { buildInputs = [ pkgs.makeWrapper ]; } ''
89 makeWrapper ${action}/bin/compaREST-GitHub-Action $out/bin/pre --add-flags "pre"
90 makeWrapper ${action}/bin/compaREST-GitHub-Action $out/bin/run --add-flags "run"
91 '';
92 in
93 pkgs.dockerTools.buildImage {
94 name = "typeable/compaREST-GitHub-Action";
95 tag = "latest";
96 contents = [ wrapped pkgs.cacert ];
97 };
99 WindowsCompaRESTBin = hsPkgs.projectCross.mingwW64.hsPkgs.compaREST.components.exes.compaREST;
100in
102 inherit
103 compaRESTImage
104 compaRESTGithubAction
105 compaRESTStaticBin
106 compaRESTBin
107 hsPkgs
108 macOSCompaRESTBundle
109 WindowsCompaRESTBin;
111 # We use the static version so that we don't have to rebuild everything on CI.
112 # The only binaries build on CI are static.
113 test = hsPkgs.projectCross.musl64.hsPkgs.compaREST.components.tests.compaREST-tests;