-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
104 lines (90 loc) · 3.66 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# SPDX-FileCopyrightText: 2023 Serokell <https://serokell.io>
# SPDX-License-Identifier: MPL-2.0
{
description = "The xrefcheck flake";
nixConfig.flake-registry = "https://github.com/serokell/flake-registry/raw/master/flake-registry.json";
outputs = { self, flake-utils, haskell-nix, serokell-nix, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = haskell-nix.legacyPackages.${system}.extend
(haskell-nix.legacyPackages.${system}.lib.composeManyExtensions [
serokell-nix.overlay
]);
flake = (pkgs.haskell-nix.stackProject {
src = builtins.path {
name = "xrefcheck";
path = ./.;
};
modules = [({ pkgs, ... }: {
packages.xrefcheck = {
ghcOptions =
[ "-Werror" ];
components.tests = {
ftp-tests = {
build-tools = [ pkgs.vsftpd ];
preCheck = ''
echo "Starting vsftpd..."
touch /tmp/vsftpd.log
vsftpd \
-orun_as_launching_user=yes \
-olisten_port=2221 \
-olisten=yes \
-oftp_username=$(whoami) \
-oanon_root=${./ftp-tests/ftp_root} \
-opasv_min_port=2222 \
-ohide_file='{.*}' \
-odeny_file='{.*}' \
-oseccomp_sandbox=no \
-olog_ftp_protocol=yes \
-oxferlog_enable=yes \
-ovsftpd_log_file=/tmp/vsftpd.log &
sleep 1
tail -f /tmp/vsftpd.log &
'';
testFlags = [ "--ftp-host" "ftp://localhost:2221" ];
};
xrefcheck-tests.build-tools = [ pkgs.git ];
};
};
# bitvec compilation on mingw64 with 'simd' flag fails with
# unknown symbol `__cpu_model'
packages.bitvec.flags.simd = !pkgs.stdenv.targetPlatform.isWindows;
})];
}).flake { crossPlatforms = p: [ p.musl64 p.mingwW64 ]; };
in
pkgs.lib.lists.foldr pkgs.lib.recursiveUpdate {} [
{ inherit (flake) packages apps devShells; }
{
legacyPackages = pkgs;
apps.default = self.apps.${system}."x86_64-unknown-linux-musl:xrefcheck:exe:xrefcheck";
packages = {
default = self.packages.${system}.xrefcheck;
xrefcheck = self.packages.${system}."xrefcheck:exe:xrefcheck";
xrefcheck-static = self.packages.${system}."x86_64-unknown-linux-musl:xrefcheck:exe:xrefcheck";
xrefcheck-windows = self.packages.${system}."x86_64-w64-mingw32:xrefcheck:exe:xrefcheck";
docker-image =
let
executable = self.packages.${system}.xrefcheck-static;
binOnly = pkgs.runCommand "xrefcheck-bin" {} ''
mkdir -p $out/bin
cp ${executable}/bin/xrefcheck $out/bin
${pkgs.nukeReferences}/bin/nuke-refs $out/bin/xrefcheck
'';
in pkgs.dockerTools.buildImage {
name = "xrefcheck";
contents = [ binOnly pkgs.cacert ];
config.Entrypoint = "xrefcheck";
};
};
checks = {
trailing-whitespace = pkgs.build.checkTrailingWhitespace ./.;
reuse-lint = pkgs.build.reuseLint ./.;
shellcheck = pkgs.build.shellcheck ./.;
hlint = pkgs.build.haskell.hlint ./.;
stylish-haskell = pkgs.build.haskell.stylish-haskell ./.;
test = self.packages.${system}."xrefcheck:test:xrefcheck-tests";
};
}
]
);
}