-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
86 lines (78 loc) · 2.63 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
# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.22)
{
# A helpful description of your flake
description = "fh fetch example project";
# Flake inputs
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2411.*";
fenix = {
url = "https://flakehub.com/f/nix-community/fenix/0.1.*";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# Flake outputs that other flakes can use
outputs = inputs:
let
# Helpers for producing system-specific outputs
supportedSystems = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" "aarch64-linux" ];
forEachSupportedSystem = f: inputs.nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ inputs.self.overlays.default ];
};
});
in
{
# Nixpkgs overlays
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
] ++ inputs.nixpkgs.lib.optionals (system == "x86_64-linux") [
targets.x86_64-unknown-linux-musl.stable.rust-std
] ++ inputs.nixpkgs.lib.optionals (system == "aarch64-linux") [
targets.aarch64-unknown-linux-musl.stable.rust-std
]);
};
# Packages
packages = forEachSupportedSystem ({ pkgs }:
let
rustPlatform = pkgs.makeRustPlatform {
cargo = pkgs.rustToolchain;
rustc = pkgs.rustToolchain;
};
in
rec {
default = server;
server = rustPlatform.buildRustPackage {
name = "server";
src = ./server;
cargoHash = "sha256-UrMy3lbNTf9Fc4P7I3Ao86SiiowPIfYt8X0DRnvONn4=";
buildInputs = with pkgs; [ iconv ];
};
});
# Docker image outputs
dockerImages =
let
system = "x86_64-linux";
linuxPkgs = inputs.nixpkgs.legacyPackages.${system};
serverPkg = inputs.self.packages.${system}.server;
in
{
${system}.server = linuxPkgs.dockerTools.buildLayeredImage {
name = "web-server";
contents = with linuxPkgs; [ cacert ];
config = {
Entrypoint = [ "${serverPkg}/bin/server" ];
};
};
};
# The formatter that's invoked when you run `nix fmt`
formatter = forEachSupportedSystem ({ pkgs }: pkgs.nixpkgs-fmt);
};
}