diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..179b7d72 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1717847456, + "narHash": "sha256-IeEIq2AvgEdiRvuOIG+d2JktDqWpFSC11F/aKJjImuk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3d59539cc468b08fbe023ae7866eed93db0083ff", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..019e50d8 --- /dev/null +++ b/flake.nix @@ -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 + ''; + }; + }); + }; +}