Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
66 lines (64 loc) · 3.01 KB
/
Copy pathflake.nix
File metadata and controls
66 lines (64 loc) · 3.01 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 deploy/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.20";
archives = {
aarch64-darwin = { target = "darwin-arm64"; sha256 = "e8da8e28ea963e4d3956b4ab80f1c1df9a8c5208dbd6ef1e3e49bb913ed0f374"; };
x86_64-darwin = { target = "darwin-x64"; sha256 = "89b95a5de78cf3c9e76ab649ca62ee66b3e2e6e168b2baf862a0ad4e7e57f2e7"; };
aarch64-linux = { target = "linux-arm64"; sha256 = "0ca9183003ea2d5d52834fe4fbe36577f13254739cf32b1455888518914e8df4"; };
x86_64-linux = { target = "linux-x64"; sha256 = "dca589832e1645500ad258d27171ed6b5a30812bcc3088c9aedf437059be41e1"; };
};
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";
};
});
};
}