From 8bd63aab8ee6f9016c6dedd11d4e95fcdfa80a4c Mon Sep 17 00:00:00 2001 From: Nicolas Duteil Date: Wed, 3 Jan 2024 13:16:38 +0100 Subject: [PATCH] feat: add flake --- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..db536f5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "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" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1661972992, + "narHash": "sha256-50235YW76Jnx4okogoJv/sMz+WNnqC+0DqtkV3jm2XM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "067d5d5b89133efcda060bba31f9941c6396e3ee", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "067d5d5b89133efcda060bba31f9941c6396e3ee", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5d84467 --- /dev/null +++ b/flake.nix @@ -0,0 +1,47 @@ +{ + description = "QuickJS (Nova fork)"; + + inputs = { + nixpkgs = { + url = "github:nixos/nixpkgs?rev=067d5d5b89133efcda060bba31f9941c6396e3ee"; + }; + + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ] (system: + let + pkgs = import nixpkgs + { + inherit system; + overlays = [ + (self: super: { + quickjs = super.quickjs.overrideAttrs (old: { + # LTO support must be disabled on macos + buildFlags = if (system == "aarch64-darwin" || system == "x86_64-darwin") then [ "CONFIG_LTO=" ] else (old.buildFlags or [ ]); + installCheckPhase = ""; + src = ./.; + }) + ; + }) + ]; + }; + in + { + defaultPackage = pkgs.quickjs; + + devShell = pkgs.mkShell { + name = "quickjs"; + + buildInputs = [ + pkgs.quickjs + ]; + + shellHook = '' + echo "To compile a JS file, use qjsc -o " 1>&2 + echo "To run a JS file, use qjs " 1>&2 + ''; + }; + }); +}