-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
112 lines (97 loc) · 3.46 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
106
107
108
109
110
111
112
{
description = "A https://flakehub.com/ pusher.";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.514192.tar.gz";
crane = {
url = "https://flakehub.com/f/ipetkov/crane/0.14.1.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "https://flakehub.com/f/nix-community/fenix/0.1.1885.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = forSystems supportedSystems;
forDockerSystems = forSystems [ "x86_64-linux" ];
forSystems = s: f: inputs.nixpkgs.lib.genAttrs s (system: f rec {
inherit system;
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ inputs.self.overlays.default ];
};
});
in
{
overlays.default = final: prev: rec {
system = final.stdenv.hostPlatform.system;
rustToolchain = with inputs.fenix.packages.${system};
combine ([
stable.clippy
stable.rustc
stable.cargo
stable.rustfmt
stable.rust-src
] ++ final.lib.optionals (system == "x86_64-linux") [
targets.x86_64-unknown-linux-musl.stable.rust-std
] ++ final.lib.optionals (system == "aarch64-linux") [
targets.aarch64-unknown-linux-musl.stable.rust-std
]);
craneLib = (inputs.crane.mkLib final).overrideToolchain rustToolchain;
flakehub-push = inputs.self.packages.${final.stdenv.system}.flakehub-push;
};
packages = forAllSystems ({ system, pkgs, ... }: rec {
default = flakehub-push;
flakehub-push = pkgs.craneLib.buildPackage
({
pname = "flakehub-push";
version = "0.1.0";
src = pkgs.craneLib.path ./.;
buildInputs = pkgs.lib.optionals (pkgs.stdenv.isDarwin) (with pkgs; [
libiconv
darwin.apple_sdk.frameworks.SystemConfiguration
]);
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
});
});
devShells = forAllSystems ({ system, pkgs, ... }: {
default = pkgs.mkShell {
name = "dev";
buildInputs = with pkgs; [
nixpkgs-fmt
rustfmt
cargo-outdated
cargo-watch
rust-analyzer
rustc
cargo
nodejs_latest
nodePackages_latest.pnpm
bacon
]
++ inputs.self.packages.${system}.flakehub-push.buildInputs
++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ Security ]);
nativeBuildInputs = with pkgs; [
]
++ inputs.self.packages.${system}.flakehub-push.nativeBuildInputs;
};
});
dockerImages = forDockerSystems ({ system, pkgs, ... }: {
default = pkgs.dockerTools.buildLayeredImage {
name = pkgs.flakehub-push.name;
contents = [ pkgs.cacert ];
config = {
#ExposedPorts."8080/tcp" = { };
Cmd = [ "${pkgs.flakehub-push}/bin/flakehub-push" ];
Env = [
"NIX_SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
];
};
};
});
};
}