diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4a4a8b9ec12d9f2f728d5dbbe4b70540dd4ef64a..f43aefb5abcb457316d322bf5480d27f129445a8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -102,6 +102,16 @@ variables:
   only:
     - tags
 
+######## stack test ########
+
+test:linux:stack:
+  before_script:
+    - ./.gitlab/before_script/linux/install_deps_minimal.sh
+  script:
+    - ./.gitlab/script/ghcup_stack.sh
+  extends:
+    - .debian
+
 ######## bootstrap test ########
 
 test:linux:bootstrap_script:
diff --git a/.gitlab/script/ghcup_stack.sh b/.gitlab/script/ghcup_stack.sh
new file mode 100644
index 0000000000000000000000000000000000000000..e11c4c9005506c7e5b47ad8ac2eaf919b12cddb5
--- /dev/null
+++ b/.gitlab/script/ghcup_stack.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -eux
+
+. "$( cd "$(dirname "$0")" ; pwd -P )/../ghcup_env"
+
+mkdir -p "$CI_PROJECT_DIR"/.local/bin
+
+git describe --always
+
+### build
+
+curl -O https://get.haskellstack.org/stable/linux-x86_64.tar.gz
+tar xf linux-x86_64.tar.gz
+cp stack-*-linux-*/stack "$CI_PROJECT_DIR"/.local/bin/stack
+chmod +x "$CI_PROJECT_DIR"/.local/bin/stack
+
+stack --stack-root "$CI_PROJECT_DIR"/.stack_root build
diff --git a/stack.yaml b/stack.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..815e0856ff8e07e8f66efd785da6652be5d76989
--- /dev/null
+++ b/stack.yaml
@@ -0,0 +1,59 @@
+resolver: lts-16.16
+
+packages:
+  - .
+
+extra-deps:
+  - 3rdparty/lzma
+  - 3rdparty/lzma-clib
+  - 3rdparty/zlib
+
+  - git: https://github.com/haskus/packages.git
+    commit: 80a1c5fc07f7226c424250ec17f674cd4d618f42
+    subdirs:
+      - haskus-utils-types
+
+  - git: https://github.com/hasufell/hpath.git
+    commit: bf6d28cf989b70286e12fecc183d5bbf5454a1a2
+    subdirs:
+      - hpath-io
+      - hpath-directory
+
+  - git: https://github.com/hasufell/text-conversions.git
+    commit: 9abf0e5e5664a3178367597c32db19880477a53c
+
+  - IfElse-0.85@sha256:6939b94acc6a55f545f63a168a349dd2fbe4b9a7cca73bf60282db5cc6aa47d2,445
+  - ascii-string-1.0.1.4@sha256:fa34f1d9ba57e8e89c0d4c9cef5e01ba32cb2d4373d13f92dcc0b531a6c6749b,2582
+  - base64-bytestring-1.1.0.0@sha256:190264fef9e65d9085f00ccda419137096d1dc94777c58272bc96821dc7f37c3,2334
+  - brotli-0.0.0.0@sha256:2bf383a4cd308745740986be0b18381c5a0784393fe69b91456aacb2d603de46,2964
+  - brotli-streams-0.0.0.0@sha256:1af1e22f67b8bfd6ad0d05e61825e7a178d738f689ebbb21c1aab5f1bbcae176,2331
+  - chs-cabal-0.1.1.0@sha256:20ec6a9fb5ab6991f1a4adf157c537bd5d3b98d08d3c09c387c954c7c50bd011,1153
+  - chs-deps-0.1.0.0@sha256:0cdada6d2c682c41b20331b8c63c2ecfc7e806928585195fd544c9d41f3074fd,2496
+  - composition-prelude-3.0.0.0@sha256:7407835ce8c1e0e2fd6febd25391b12989b216773e685e3cf95bd89072af0ecc,1149
+  - haskus-utils-data-1.3@sha256:f62c4e49021b463185d043f7b69c727b63af641a71d7edd582d9f4f98e80e500,1466
+  - haskus-utils-variant-3.0@sha256:8d51e45d3b664e61ccc25a58b37c0ccc4ee7537138b9fee21cd15c356906dd34,2159
+  - hpath-0.11.0@sha256:12b8405bee13d0007d644a888ef8407069ce7bbbd76970f8746b801447124ade,1440
+  - hpath-filepath-0.10.4@sha256:e9e44fb5fdbade7f30b5b5451257dbee15b6ef1aae4060034d73008bb3b5d878,1269
+  - hpath-posix-0.13.2@sha256:eec4ff2b00dc86be847aca0f409fc8f6212ffd2170ec36a17dc9a52b46562392,1615
+  - http-io-streams-0.1.4.0@sha256:9a74a059daeddf7a41d361919190b9f4d4292f05e0e4bdf156e2098a116a8145,3582
+  - libarchive-3.0.0.0@sha256:e4157b307acf16cca0ec3d398ac5093cc06f092b33a9743be559ef0f6c6ae52f,11204
+  - os-release-1.0.1@sha256:1281c62081f438fc3f0874d3bae6a4887d5964ac25261ba06e29d368ab173467,2716
+  - primitive-extras-0.8@sha256:fca0310150496867f5b9421fe1541ecda87fae17eae44885a29f9c52dd00c8ff,2963
+  - primitive-unlifted-0.1.3.0@sha256:a98f827740f5dcf097d885b3a47c32f4462204449620abc9d51b8c4f8619f9e6,1427
+  - streamly-posix-0.1.0.1@sha256:5d89b806281035d34020387ed99dde1ddab282c7ed66df3b7cd010b38fd3517b,2138
+  - strict-base-0.4.0.0@sha256:2ff4e43cb95eedf2995558d7fc34d19362846413dd39e6aa6a5b3ea8228fef9f,1248
+  - tar-bytestring-0.6.3.2@sha256:88f29bed56b688c543a4cb3986402d64b360f76b3fd9b88ac618b8344f8da712,5715
+  - xor-0.0.1.0@sha256:f8362b4a68562b9afbcd727ff64c1a303970df3a032e0033d2f4c094c3501df3,2243
+
+
+flags:
+  http-io-streams:
+    brotli: false
+
+  libarchive:
+    system-libarchive: false
+
+ghc-options:
+  "$local": -O2
+  streamly: -O2 -fspec-constr-recursive=16 -fmax-worker-args=16
+  ghcup: -O2 -fspec-constr-recursive=16 -fmax-worker-args=16