aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-03-28 18:39:08 -0400
committerXe Iaso <me@xeiaso.net>2023-03-28 18:39:08 -0400
commit079757bde2712ba787288c99fddbd9115d52bf92 (patch)
treee7af75ad1a170219972a50378405db476d45c0db
parent95c888fc35692228d7951f461508cd59fae0f691 (diff)
downloadx-079757bde2712ba787288c99fddbd9115d52bf92.tar.xz
x-079757bde2712ba787288c99fddbd9115d52bf92.zip
add buildGoModule override example
Signed-off-by: Xe Iaso <me@xeiaso.net>
-rw-r--r--flake.nix16
-rw-r--r--wasm/go.mod3
-rw-r--r--wasm/main.go7
3 files changed, 25 insertions, 1 deletions
diff --git a/flake.nix b/flake.nix
index 3317105..326e48b 100644
--- a/flake.nix
+++ b/flake.nix
@@ -134,13 +134,20 @@
echo "go-wasip1-dev-${wasigo.shortRev}" > $out/VERSION
cp -vrf ${wasigo}/* $out
'';
- });
+ }) // {
+ GOOS = "wasip1";
+ GOARCH = "wasm";
+ };
gowasi = pkgs.writeShellScriptBin "gowasi" ''
export GOOS=wasip1
export GOARCH=wasm
exec ${wasigo'}/bin/go $*
'';
+
+ buildGoWasiModule = pkgs.callPackage "${nixpkgs}/pkgs/build-support/go/module.nix" {
+ go = wasigo';
+ };
in {
overlays.default = final: prev:
let
@@ -153,6 +160,13 @@
wasigo = wasigo';
+ wasigoExample = buildGoWasiModule {
+ pname = "wasigo-example";
+ version = "latest";
+ src = ./wasm;
+ vendorHash = null;
+ };
+
mastosan-wasm = naersk'.buildPackage {
src = ./web/mastosan;
targets = [ "wasm32-wasi" ];
diff --git a/wasm/go.mod b/wasm/go.mod
new file mode 100644
index 0000000..900b645
--- /dev/null
+++ b/wasm/go.mod
@@ -0,0 +1,3 @@
+module foo.bar/wasm
+
+go 1.20
diff --git a/wasm/main.go b/wasm/main.go
new file mode 100644
index 0000000..7eab755
--- /dev/null
+++ b/wasm/main.go
@@ -0,0 +1,7 @@
+package main
+
+import "fmt"
+
+func main() {
+ fmt.Println("testing a wasm module from buildGoWasiModule")
+}