Merge pull request #19 from Xe/main

flake: support other systems
This commit is contained in:
SnO₂WMaN 2022-12-09 16:26:11 +09:00 committed by GitHub
commit 9586378845
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 54 deletions

View file

@ -2,15 +2,19 @@
"nodes": { "nodes": {
"devshell": { "devshell": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": [
"nixpkgs": "nixpkgs" "flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1654858401, "lastModified": 1667210711,
"narHash": "sha256-53bw34DtVJ2bnF6WEwy6Tym+qY0pNEiEwARUlvmTZjs=", "narHash": "sha256-IoErjXZAkzYWHEpQqwu/DeRNJGFdR7X2OGbkhMqMrpw=",
"owner": "numtide", "owner": "numtide",
"repo": "devshell", "repo": "devshell",
"rev": "f55e05c6d3bbe9acc7363bc8fc739518b2f02976", "rev": "96a9dd12b8a447840cc246e17a47b81a4268bba7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -22,11 +26,11 @@
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1650374568, "lastModified": 1668681692,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
"owner": "edolstra", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8", "rev": "009399224d5e398d03b22badca40a37ac85412a1",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -37,26 +41,11 @@
}, },
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1642700792, "lastModified": 1667395993,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -67,27 +56,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1643381941, "lastModified": 1670332253,
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=", "narHash": "sha256-O5SmhlIUt1s+vK4NXeGYqwcBIMwbBPAEZ3GHE3XT28c=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1655400192,
"narHash": "sha256-49OBVVRgb9H/PSmNT9W61+NRdDbuSJVuDDflwXlaUKU=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "3d7435c638baffaa826b85459df0fff47f12317d", "rev": "1c9ffcf70786f0966982ce0fc76ec05df2e1dec2",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -101,8 +74,8 @@
"inputs": { "inputs": {
"devshell": "devshell", "devshell": "devshell",
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs"
} }
} }
}, },

View file

@ -6,7 +6,11 @@
# dev # dev
inputs = { inputs = {
devshell.url = "github:numtide/devshell"; devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
flake-compat = { flake-compat = {
url = "github:edolstra/flake-compat"; url = "github:edolstra/flake-compat";
@ -26,6 +30,9 @@
} }
// flake-utils.lib.eachSystem [ // flake-utils.lib.eachSystem [
"x86_64-linux" "x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
] ]
( (
system: let system: let
@ -49,6 +56,7 @@
output = "bundled.js"; output = "bundled.js";
entrypoint = "./mod.ts"; entrypoint = "./mod.ts";
importMap = "./import_map.json"; importMap = "./import_map.json";
minify = true;
}; };
packages.bundled-wrapper = deno2nix.mkBundledWrapper { packages.bundled-wrapper = deno2nix.mkBundledWrapper {
pname = "example-bundled-wrapper"; pname = "example-bundled-wrapper";

View file

@ -1,3 +1,6 @@
{ {
"https://deno.land/std@0.118.0/fmt/colors.ts": "8368ddf2d48dfe413ffd04cdbb7ae6a1009cf0dccc9c7ff1d76259d9c61a0621" "version": "2",
"remote": {
"https://deno.land/std@0.118.0/fmt/colors.ts": "8368ddf2d48dfe413ffd04cdbb7ae6a1009cf0dccc9c7ff1d76259d9c61a0621"
}
} }

View file

@ -43,7 +43,7 @@ in {
} }
] ]
) )
(importJSON lockfile) (importJSON lockfile).remote
)) ))
); );
} }

View file

@ -10,6 +10,8 @@
src, src,
lockfile, lockfile,
output ? "bundled.js", output ? "bundled.js",
outPath ? "dist",
minify ? false,
entrypoint, entrypoint,
importMap ? null, importMap ? null,
additionalDenoFlags ? "", additionalDenoFlags ? "",
@ -18,7 +20,7 @@
in in
stdenv.mkDerivation { stdenv.mkDerivation {
inherit pname version entrypoint src; inherit pname version entrypoint src;
buildInputs = with pkgs; [deno jq]; buildInputs = with pkgs; [ deno jq nodePackages.uglify-js ];
buildPhase = '' buildPhase = ''
export DENO_DIR="/tmp/deno2nix" export DENO_DIR="/tmp/deno2nix"
@ -27,7 +29,7 @@ in
deno bundle \ deno bundle \
--lock="${lockfile}" \ --lock="${lockfile}" \
${ ${
if importMap != null if importMap != null
then "--import-map=\"$src/${importMap}\"" then "--import-map=\"$src/${importMap}\""
else "" else ""
@ -35,9 +37,18 @@ in
${additionalDenoFlags} \ ${additionalDenoFlags} \
"$src/${entrypoint}" \ "$src/${entrypoint}" \
"${output}" "${output}"
${
if minify
then ''
mv ${output} ${output}-non-min
uglifyjs ${output}-non-min -c -m > ${output}
''
else ""
}
''; '';
installPhase = '' installPhase = ''
mkdir -p $out/dist mkdir -p $out/${outPath}
install -t $out/dist "${output}" install -t $out/${outPath} "${output}"
''; '';
} }