-
Notifications
You must be signed in to change notification settings - Fork 13
/
flake.nix
66 lines (57 loc) · 2.13 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
{
description = "bsf";
inputs = {
# nixpkgs.url = "github:NixOS/nixpkgs";
};
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" "aarch64-linux" ];
forEachSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
inherit system;
pkgs = import nixpkgs { inherit system; };
});
getBinaryUrl = { system, version }:
let
urls = {
"x86_64-linux" = "https://github.com/buildsafedev/bsf/releases/download/v${version}/bsf_linux_amd64";
"aarch64-darwin" = "https://github.com/buildsafedev/bsf/releases/download/v${version}/bsf_darwin_arm64";
"x86_64-darwin" = "https://github.com/buildsafedev/bsf/releases/download/v${version}/bsf_darwin_amd64";
"aarch64-linux" = "https://github.com/buildsafedev/bsf/releases/download/v${version}/bsf_linux_arm64";
};
in urls.${system};
getBinaryHash = { system }:
let
hash = {
"aarch64-darwin" = "sha256-W553BRHGgRZXZHtcRxPZa/QNBjk5gyrWHOAKPApEhwQ=";
"x86_64-linux" = "sha256-p7o//av/y3qrDupdKnCi/YUy+pr1GsSRth6TFci4zEs=";
"x86_64-darwin" = "sha256-VP55fwVCg63oQjuS5ttQfUUx4MsTeDSYFPcJVSVZ9OY=";
"aarch64-linux" = "sha256-0WR3AkpnQ/qcrRJ5HXzjVYZcF5IMYhyNhFDd9GfaiDk=";
};
in hash.${system};
in
{
packages = forEachSystem ({ pkgs, ... }: {
default = pkgs.stdenvNoCC.mkDerivation rec {
name = "bsf";
version = "0.3.0";
src = pkgs.fetchurl {
url = getBinaryUrl { system = pkgs.system; version = version; };
sha256 = getBinaryHash {system = pkgs.system;};
};
dontUnpack = true;
phases = [ "installPhase" ];
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/bsf
chmod +x $out/bin/bsf
'';
shellHook = ''
echo $src
echo "bsf is available: $out/bin/bsf"
$out/bin/bsf
'';
};
});
};
}