Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
66 lines (64 loc) · 3.02 KB
/
Copy pathflake.nix
File metadata and controls
66 lines (64 loc) · 3.02 KB
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
# Nix flake for Bend, written by release.ts (in the bend-lang.com repo,
# from release/flake.nix.in) with the version and the sha256 of each
# release archive filled in: do not bump it by hand. The package fetches
# the host's archive from GitHub Releases, the same one install.sh and
# the Homebrew formula install, lands it whole in libexec/bend (bin/bend
# beside bend2/ and guide/, the layout the executable expects) and puts
# a wrapper at bin/bend that adds clang to PATH on Linux (bend -o needs
# clang 14+) and names Apple's clang on macOS. On Linux the Bun
# executable is patched to find the store's glibc. Use:
# `nix profile install github:bendlang/bend`, `nix run github:bendlang/bend`,
# or `inputs.bend.url = "github:bendlang/bend"` and
# `inputs.bend.packages.${system}.default` in a flake.
{
description = "Bend: C speed, CUDA parallelism, Lean proofs, Python syntax";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { self, nixpkgs }:
let
ver = "2.0.40";
archives = {
aarch64-darwin = { target = "darwin-arm64"; sha256 = "b2be003b041eb6cfc65326be18f79eb2e0bae2189be79a18c507e661b4b6900b"; };
x86_64-darwin = { target = "darwin-x64"; sha256 = "9229c8bdd0a93f63fa45cc5af5e9e56389ebb620d655920915daf966c6ca561c"; };
aarch64-linux = { target = "linux-arm64"; sha256 = "2f42a6fa34ecdaa71ae105e5fa734f9a07e129d333e45448ab6d2ff03a837570"; };
x86_64-linux = { target = "linux-x64"; sha256 = "c9ff8d67bd903fb6ad9a26b43d8a62c01021de82a44d55ce4a3dcd4732113d6b"; };
};
each = f: nixpkgs.lib.mapAttrs (system: archive:
f (import nixpkgs { inherit system; }) archive) archives;
in {
packages = each (pkgs: archive: {
default = pkgs.stdenv.mkDerivation {
pname = "bend";
version = ver;
src = pkgs.fetchurl {
url = "https://github.com/bendlang/bend/releases/download/v${ver}/"
+ "bend-${ver}-${archive.target}.tar.gz";
inherit (archive) sha256;
};
nativeBuildInputs = [ pkgs.makeWrapper ]
++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isLinux pkgs.autoPatchelfHook;
dontBuild = true;
dontStrip = true;
installPhase = ''
mkdir -p $out/libexec/bend $out/bin
cp -r . $out/libexec/bend
makeWrapper $out/libexec/bend/bin/bend $out/bin/bend \
${if pkgs.stdenv.hostPlatform.isLinux
then ''--prefix PATH : "${pkgs.lib.makeBinPath [ pkgs.clang ]}"''
else "--set-default CC /usr/bin/clang"}
'';
meta = {
description = "Bend: C speed, CUDA parallelism, Lean proofs, Python syntax";
homepage = "https://bend-lang.com";
license = pkgs.lib.licenses.asl20;
mainProgram = "bend";
};
};
});
apps = each (pkgs: archive: {
default = {
type = "app";
program = "${self.packages.${pkgs.system}.default}/bin/bend";
};
});
};
}