-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
114 lines (103 loc) · 3.51 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
{
description = "pijul, the sound distributed version control system";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{ self
, nixpkgs
, rust-overlay
, ...
} @ inputs:
let
nameValuePair = name: value: { inherit name value; };
genAttrs = names: f: builtins.listToAttrs (map (n: nameValuePair n (f n)) names);
allSystems = [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" ];
forAllSystems = f: genAttrs allSystems (system: f system);
rustOverlay = final: prev:
let
rustChannel = prev.rust-bin.stable."1.58.1";
in {
inherit rustChannel;
rustc = rustChannel.minimal;
};
in {
devShell = forAllSystems (system:
let
rustDevOverlay = final: prev: {
# rust-analyzer needs core source
rustc-with-src = prev.rustc.override { extensions = [ "rust-src" ]; };
};
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust-overlay)
rustOverlay
rustDevOverlay
];
};
in pkgs.mkShell {
name = "pijul";
inputsFrom = [ self.packages.${system}.pijul-git ];
# Eventually crate2nix will provide a devShell that includes transitive dependencies for us.
# https://github.com/kolloch/crate2nix/issues/111
packages = with pkgs; [
pkg-config
clang
openssl
rust-analyzer rustc-with-src
rustfmt
crate2nix
];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang}/lib";
});
packages = forAllSystems
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust-overlay)
rustOverlay
];
};
pijul =
let
cargoNix = import ./Cargo.nix {
inherit pkgs;
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
zstd-seekable = { ... }: {
nativeBuildInputs = [ pkgs.clang ]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.xcbuild ];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang}/lib";
};
blake3 = attr: {
nativeBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.xcbuild ];
};
pijul = { ... }: {
buildInputs = with pkgs; [
zstd
xxHash
libsodium
xxHash
libiconv
] ++ lib.optionals stdenv.isDarwin (
[ openssl ]
++ (with darwin.apple_sdk.frameworks; [
CoreServices
Security
SystemConfiguration
]));
};
};
};
in
cargoNix.workspaceMembers.pijul.build;
in {
inherit pijul;
pijul-git = pijul.override { features = [ "git" ]; };
});
defaultPackage = forAllSystems (system: self.packages.${system}.pijul);
};
}