-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
70 lines (62 loc) · 2.45 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
{
description = "oci-srm-server-mock, mocks interactions for OCI PunchOut/PunchIn and Call-Up interactions";
inputs = {
fenix.url = "github:nix-community/fenix";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
naersk.url = "github:nmattia/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, fenix, flake-utils, nixpkgs, naersk }:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = (import nixpkgs) {
inherit system;
};
toolchain = with fenix.packages.${system};
combine [
minimal.rustc
minimal.cargo
targets.x86_64-unknown-linux-musl.latest.rust-std
];
naersk' = naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
};
built = naersk'.buildPackage {
src = ./.;
doCheck = true;
nativeBuildInputs = with pkgs; [ pkgsStatic.stdenv.cc ];
# Tells Cargo that we're building for musl.
# (https://doc.rust-lang.org/cargo/reference/config.html#buildtarget)
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
# Tells Cargo to enable static compilation.
# (https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags)
#
# Note that the resulting binary might still be considered dynamically
# linked by ldd, but that's just because the binary might have
# position-independent-execution enabled.
# (see: https://github.com/rust-lang/rust/issues/79624#issuecomment-737415388)
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
};
in {
packages = {
defaultPackage = built;
docker-image = pkgs.dockerTools.buildLayeredImage {
name = "oci-srm-server-mock-rust";
config = {
Cmd =
[ "${built}/bin/oci-srm-server-mock" ];
Env = [
"OCI_SRM_SERVER_MOCK_PORT=80"
"OCI_SRM_SERVER_MOCK_BASE_URL=http://oci-srm-server-mock/"
"PUNCHOUT_SERVER_LOGIN_URI=http://punchout-server/punch-in?foo=bar&pass=example-supersecret"
"PUNCHOUT_SERVER_CONFIRMATION_URI=http://punchout-server/cxml-order-request-endpoint"
];
ExposedPorts = { "80/tcp" = { }; };
};
};
};
}
);
}