-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
105 lines (96 loc) · 3.13 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
105
{
inputs = {
# nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
systems.url = "github:nix-systems/default";
nix-github-actions.url = "github:nix-community/nix-github-actions";
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
systems,
nixpkgs,
nix-github-actions,
...
} @ inputs: let
eachSystem = f:
nixpkgs.lib.genAttrs (import systems) (
system:
f (import nixpkgs {
inherit system;
overlays = [inputs.rust-overlay.overlays.default];
})
);
rustToolchain = eachSystem (pkgs: pkgs.rust-bin.stable.latest);
name = "nju-schedule-ics";
version = "0.9.0";
in rec {
devShells = eachSystem (pkgs: {
# Based on a discussion at https://github.com/oxalica/rust-overlay/issues/129
default = pkgs.mkShell (with pkgs; {
nativeBuildInputs = [
clang
# Use mold when we are runnning in Linux
(lib.optionals stdenv.isLinux mold)
];
buildInputs = [
rustToolchain.${pkgs.system}.default
rust-analyzer-unwrapped
cargo
# pkg-config
# openssl
] ++
(pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
SystemConfiguration
])) ++
(pkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs; [
openssl
]));
RUST_SRC_PATH = "${
rustToolchain.${pkgs.system}.rust-src
}/lib/rustlib/src/rust/library";
});
});
packages = eachSystem (pkgs: {
default = pkgs.rustPlatform.buildRustPackage {
pname = name;
inherit version;
src = pkgs.lib.cleanSourceWith {
filter = (path: type:
(
let
name = builtins.baseNameOf path;
in
(builtins.match ".*src.*" path != null || name == "Cargo.toml" || name == "Cargo.lock") &&
builtins.match ".*\.DS_Store" path == null
)
);
src = (pkgs.lib.cleanSource ./.);
} ;
cargoSha256 = "sha256-PYdLuWNz3I2xeNE65oddNBoAJJ+v2svJq/+RmAiMftE=";
buildInputs = [] ++
(pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
SystemConfiguration
])) ++
(pkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs; [
openssl
]));
nativeBuildInputs = (pkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs; [
pkg-config
]));
doCheck=false;
};
docker = pkgs.dockerTools.buildImage {
inherit name;
copyToRoot = [ pkgs.cacert ];
config = {
Cmd = [ "${packages.${pkgs.system}.default}/bin/nju-schedule-ics" "--config" "/config.toml" ];
Env = [ "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
};
};
});
githubActions = nix-github-actions.lib.mkGithubMatrix {
checks = nixpkgs.lib.getAttrs [ "x86_64-linux" "x86_64-darwin" ] self.packages;
};
};
}