diff --git a/.gitignore b/.gitignore index 880cd5d..ac13147 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ zig-out .zig-cache +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c508296 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1787736819, + "narHash": "sha256-cV5xEJJK3BvhU8rEd4mC9UsmDi5qscv/kzGPhBRC5WA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9fbb54b33e91ee4ca368e35a78e0613c720600b3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "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 0000000..c44093b --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = "HEX - a collection of terminal libraries"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = { self, nixpkgs }: + let + systems = [ "x86_64-linux" "aarch64-linux" ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + + package = pkgs: + let + inherit (pkgs) zig libssh pkg-config; + in + pkgs.stdenv.mkDerivation { + pname = "hex"; + version = "0.0.0"; + src = self; + + nativeBuildInputs = [ zig pkg-config ]; + + buildInputs = [ libssh ]; + + dontConfigure = true; + dontInstall = true; + + buildPhase = '' + runHook preBuild + export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-global" + export ZIG_LOCAL_CACHE_DIR="$TMPDIR/zig-local" + zig build --prefix "$out" demo + runHook postBuild + ''; + }; + in + { + packages = forAllSystems (system: { + default = package nixpkgs.legacyPackages.${system}; + }); + + devShells = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in { + default = pkgs.mkShell { + packages = [ pkgs.zig pkgs.pkg-config pkgs.libssh ]; + }; + }); + }; +}