feat: add flake

This commit is contained in:
Nicolas Duteil 2024-01-03 13:16:38 +01:00
parent 6037f2cdcf
commit 8bd63aab8e
2 changed files with 108 additions and 0 deletions

61
flake.lock generated Normal file
View File

@ -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
}

47
flake.nix Normal file
View File

@ -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 <binary> <source>" 1>&2
echo "To run a JS file, use qjs <source>" 1>&2
'';
};
});
}