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