Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
109 lines (106 loc) · 3.44 KB
/
Copy pathflake.nix
File metadata and controls
109 lines (106 loc) · 3.44 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
109
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
};
outputs =
{
self,
flake-utils,
nixpkgs,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
scip-rust = pkgs.writeShellApplication {
name = "scip-rust";
runtimeEnv = {
SCIP_RUST_FALLBACK_CARGO = "${pkgs.cargo}/bin";
SCIP_RUST_FALLBACK_RUSTC = "${pkgs.rustc}/bin";
SCIP_RUST_FALLBACK_RUST_ANALYZER = "${pkgs.rust-analyzer}/bin";
};
text = builtins.readFile ./scip-rust;
};
# Distrust the roots behind the compromised eMudhra intermediate CAs
# (https://emudhra.we-have-a-problem.com/). The pinned cacert (3.123)
# already distrusts Comodo AAA Services root for TLS; it is listed as
# defence in depth. cacert 3.131.1 drops emSign ECC Root CA - G3, so
# this override fails the build after a nixpkgs bump to it; remove it
# then.
dockerTools = pkgs.dockerTools.override {
cacert = pkgs.cacert.override {
blacklist = [
"Comodo AAA Services root"
"emSign ECC Root CA - G3"
];
};
};
# Provides /bin/sh for callers that run commands in the container
# through a shell. wget and ssl_client are left out: BusyBox does
# not verify TLS certificates.
busybox = pkgs.busybox.override {
extraConfig = ''
CONFIG_WGET n
CONFIG_SSL_CLIENT n
'';
};
in
{
packages = {
inherit scip-rust;
default = scip-rust;
}
// pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
docker = dockerTools.buildLayeredImage {
name = "scip-rust";
tag = "latest";
contents = [
scip-rust
busybox
dockerTools.caCertificates
# Not pkgs.git: its Perl tools pull in Mozilla::CA, a separate
# CA bundle that still trusts emSign ECC Root CA - G3.
pkgs.gitMinimal
];
fakeRootCommands = "mkdir -p /work /tmp";
enableFakechroot = true;
config = {
Cmd = [ "scip-rust" ];
WorkingDir = "/work";
Env = [ "HOME=/tmp" ];
Labels = {
"org.opencontainers.image.source" = "https://github.com/scip-code/scip-rust";
};
};
};
};
checks = {
shellcheck = pkgs.runCommand "check-shellcheck" { } ''
${pkgs.shellcheck}/bin/shellcheck ${./scip-rust}
touch $out
'';
formatting = pkgs.runCommand "check-formatting" { } ''
${pkgs.nixfmt}/bin/nixfmt --check ${./flake.nix}
${pkgs.shfmt}/bin/shfmt -i 4 -ci -d ${./scip-rust}
touch $out
'';
renovate = pkgs.runCommand "check-renovate" { } ''
LOG_LEVEL=warn ${pkgs.renovate}/bin/renovate-config-validator \
${./.github/renovate.json}
touch $out
'';
};
devShells.default = pkgs.mkShellNoCC {
buildInputs = with pkgs; [
cargo
nixfmt
rust-analyzer
rustc
shellcheck
shfmt
];
};
}
);
}