-
Notifications
You must be signed in to change notification settings - Fork 8
/
flake.nix
123 lines (104 loc) · 3.76 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
113
114
115
116
117
118
119
120
121
122
{
description = "The official CLI for FlakeHub: search for flakes, and add new inputs to your Nix flake.";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2411.*.tar.gz";
fenix = {
url = "https://flakehub.com/f/nix-community/fenix/0.1.1584.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "https://flakehub.com/f/nix-community/naersk/0.1.345.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, ... }@inputs:
let
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
version = "${builtins.substring 0 8 lastModifiedDate}-${self.shortRev or "dirty"}";
forSystems = s: f: inputs.nixpkgs.lib.genAttrs s (system: f rec {
inherit system;
pkgs = import inputs.nixpkgs { inherit system; overlays = [ self.overlays.default ]; };
});
forAllSystems = forSystems [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
fenixToolchain = system: 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
]);
in
{
overlays.default = final: prev: rec {
fh =
let
rustToolchain = fenixToolchain final.stdenv.hostPlatform.system;
naerskLib = final.callPackage inputs.naersk {
cargo = rustToolchain;
rustc = rustToolchain;
};
in
naerskLib.buildPackage {
name = "fh-${version}";
src = self;
doCheck = true;
nativeBuildInputs = with final; [
pkg-config
rustPlatform.bindgenHook
installShellFiles
];
buildInputs = with final; [
gcc.cc.lib
]
++ lib.optionals (stdenv.isDarwin) (with darwin.apple_sdk.frameworks; [
Security
SystemConfiguration
]);
postInstall = ''
installShellCompletion --cmd fh \
--bash <("$out/bin/fh" completion bash) \
--zsh <("$out/bin/fh" completion zsh) \
--fish <("$out/bin/fh" completion fish)
'';
env = {
SSL_CERT_FILE = "${final.cacert}/etc/ssl/certs/ca-bundle.crt";
LIBCLANG_PATH = "${final.libclang.lib}/lib";
NIX_CFLAGS_COMPILE = final.lib.optionalString final.stdenv.isDarwin "-I${final.libcxx.dev}/include/c++/v1";
};
};
};
packages = forAllSystems ({ system, pkgs }: rec {
inherit (pkgs) fh;
default = pkgs.fh;
});
devShells = forAllSystems ({ system, pkgs }:
{
default = pkgs.mkShell {
packages = with pkgs; [
(fenixToolchain system)
bacon
cargo-watch
rust-analyzer
nixpkgs-fmt
# For the Rust environment
pkg-config
clang
gcc.cc.lib
]
++ lib.optionals (stdenv.isDarwin) ([ libiconv ] ++ (with darwin.apple_sdk.frameworks; [
Security
SystemConfiguration
]));
env = {
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
NIX_CFLAGS_COMPILE = pkgs.lib.optionalString pkgs.stdenv.isDarwin "-I${pkgs.libcxx.dev}/include/c++/v1";
};
};
});
};
}