diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..534c582 --- /dev/null +++ b/flake.lock @@ -0,0 +1,136 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703887061, + "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1704161960, + "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs", + "zig-overlay": "zig-overlay" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "zig-overlay": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1704414187, + "narHash": "sha256-augAzcGHaeuWknIsYSua1oJoCE0Mh12BRm3i4ZONcpc=", + "owner": "mitchellh", + "repo": "zig-overlay", + "rev": "aeb1f52d1ca19d836f0ef4a7f3f25deec661f75f", + "type": "github" + }, + "original": { + "owner": "mitchellh", + "repo": "zig-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1060de3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + inputs = + { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + zig-overlay.url = "github:mitchellh/zig-overlay"; + zig-overlay.inputs.nixpkgs.follows = "nixpkgs"; + + gitignore.url = "github:hercules-ci/gitignore.nix"; + gitignore.inputs.nixpkgs.follows = "nixpkgs"; + + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = inputs: + let + inherit (inputs) nixpkgs zig-overlay gitignore flake-utils; + systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + inherit (gitignore.lib) gitignoreSource; + in + flake-utils.lib.eachSystem systems (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + zig = zig-overlay.packages.${system}.master-2023-12-31; + in + rec { + formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; + packages.default = packages.sonic-pdb-parser; + packages.sonic-pdb-parser = pkgs.stdenvNoCC.mkDerivation { + name = "sonic-pdb-parser"; + version = "master"; + src = gitignoreSource ./.; + nativeBuildInputs = [ zig ]; + dontConfigure = true; + dontInstall = true; + doCheck = true; + buildPhase = '' + mkdir -p .cache + zig build install --cache-dir $(pwd)/zig-cache --global-cache-dir $(pwd)/.cache --prefix $out -Doptimize=ReleaseFast + ''; + checkPhase = '' + zig build test --cache-dir $(pwd)/zig-cache --global-cache-dir $(pwd)/.cache + ''; + }; + devShell = pkgs.mkShell { + buildInputs = [ packages.sonic-pdb-parser.nativeBuildInputs ]; + }; + + } + ); +}