Skip to content

Commit

Permalink
pull bsf binaries using flake
Browse files Browse the repository at this point in the history
Signed-off-by: Horiodino <[email protected]>
  • Loading branch information
Horiodino authored and dr-housemd committed Jun 9, 2024
1 parent 5ecbcb4 commit 99ff7ea
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
26 changes: 26 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,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-gml63JR7k9/YCcbsptauaD3WT4G7G7xyMRCM1RnB3P4=";
"x86_64-linux" = "sha256-u+60Zxf8RTActuXEShah1XguXwicXLqR3Oa9bTOrv80=";
"x86_64-darwin" = "sha256-07yqkelltfg6ptVxT7WnIq3gZerooPE1GLiVsCoVLMI=";
"aarch64-linux" = "sha256-xdrHvsN0bBednAY080CTUkPpVhQDeOl388ZKrkSitEc=";
};
in hash.${system};

in
{
packages = forEachSystem ({ pkgs, ... }: {
default = pkgs.stdenv.mkDerivation rec {
name = "bsf";
version = "0.1";

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
'';
};
});
};
}

0 comments on commit 99ff7ea

Please sign in to comment.