diff --git a/.envrc b/.envrc index ce4386f..6de8a8a 100644 --- a/.envrc +++ b/.envrc @@ -1,11 +1,3 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" -fi +source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0=" -nix_direnv_watch_file devenv.nix -nix_direnv_watch_file devenv.lock -nix_direnv_watch_file devenv.yaml -if ! use flake . --impure -then - echo "devenv could not be build. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 -fi +use devenv \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 21eaf18..97b23a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,17 @@ concurrency: cancel-in-progress: true jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v24 + - uses: cachix/cachix-action@v12 + with: + name: devenv + - run: nix-env -if https://install.devenv.sh/latest + - run: devenv ci + test: strategy: matrix: @@ -25,6 +36,7 @@ jobs: - plugin: stack fail-fast: true runs-on: ${{ matrix.os }} + needs: [check] steps: - uses: asdf-vm/actions/plugin-test@v3 with: diff --git a/.gitignore b/.gitignore index acb2ca6..9f543cd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ .ghcup/ node_modules/ +.devenv.flake.nix .pre-commit-config.yaml diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index b7efcb4..0000000 --- a/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "test/bats"] - path = test/bats - url = https://github.com/bats-core/bats-core.git -[submodule "test/test_helper/bats-support"] - path = test/test_helper/bats-support - url = https://github.com/bats-core/bats-support.git -[submodule "test/test_helper/bats-assert"] - path = test/test_helper/bats-assert - url = https://github.com/bats-core/bats-assert.git diff --git a/flake.lock b/devenv.lock similarity index 51% rename from flake.lock rename to devenv.lock index 04a6509..791a8d2 100644 --- a/flake.lock +++ b/devenv.lock @@ -1,21 +1,17 @@ { "nodes": { "devenv": { - "inputs": { - "flake-compat": "flake-compat", - "nix": "nix", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks" - }, "locked": { - "lastModified": 1686642933, - "narHash": "sha256-5Z4uitx27QtZIrG9sOSJlZRNcVQn/TI36nj7o70n5Dw=", + "dir": "src/modules", + "lastModified": 1701187605, + "narHash": "sha256-NctguPdUeDVLXFsv6vI1RlEiHLsXkeW3pgZe/mwn1BU=", "owner": "cachix", "repo": "devenv", - "rev": "f5278b5d56e39f86a299a2e1889906933a26f762", + "rev": "a7c4dd8f4eb1f98a6b8f04bf08364954e1e73e4f", "type": "github" }, "original": { + "dir": "src/modules", "owner": "cachix", "repo": "devenv", "type": "github" @@ -38,12 +34,15 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", "type": "github" }, "original": { @@ -55,7 +54,6 @@ "gitignore": { "inputs": { "nixpkgs": [ - "devenv", "pre-commit-hooks", "nixpkgs" ] @@ -74,53 +72,13 @@ "type": "github" } }, - "lowdown-src": { - "flake": false, - "locked": { - "lastModified": 1633514407, - "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", - "owner": "kristapsdz", - "repo": "lowdown", - "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", - "type": "github" - }, - "original": { - "owner": "kristapsdz", - "repo": "lowdown", - "type": "github" - } - }, - "nix": { - "inputs": { - "lowdown-src": "lowdown-src", - "nixpkgs": [ - "devenv", - "nixpkgs" - ], - "nixpkgs-regression": "nixpkgs-regression" - }, - "locked": { - "lastModified": 1676545802, - "narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=", - "owner": "domenkozar", - "repo": "nix", - "rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f", - "type": "github" - }, - "original": { - "owner": "domenkozar", - "ref": "relaxed-flakes", - "repo": "nix", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1678875422, - "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", + "lastModified": 1701432845, + "narHash": "sha256-06sd2rQ+DPMSueh+hW4MiXbpMSdhQHJOi/sw0vuwqvs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", + "rev": "77da99a144cd341408308e0a37622f5edcc6c5ba", "type": "github" }, "original": { @@ -130,74 +88,38 @@ "type": "github" } }, - "nixpkgs-regression": { - "locked": { - "lastModified": 1643052045, - "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - } - }, "nixpkgs-stable": { "locked": { - "lastModified": 1678872516, - "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1686751072, - "narHash": "sha256-i4TGoVhWiwSkGV8D8Hk8A3MZ68rmAxknEVwTYkE3Wjk=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "98be10c950909515f626a776e862c24589fde969", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-22.11", + "ref": "nixos-23.05", "repo": "nixpkgs", "type": "github" } }, "pre-commit-hooks": { "inputs": { - "flake-compat": [ - "devenv", - "flake-compat" - ], + "flake-compat": "flake-compat", "flake-utils": "flake-utils", "gitignore": "gitignore", "nixpkgs": [ - "devenv", "nixpkgs" ], "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1686050334, - "narHash": "sha256-R0mczWjDzBpIvM3XXhO908X5e2CQqjyh/gFbwZk/7/Q=", + "lastModified": 1700922917, + "narHash": "sha256-ej2fch/T584b5K9sk1UhmZF7W6wEfDHuoUYpFN8dtvM=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "6881eb2ae5d8a3516e34714e7a90d9d95914c4dc", + "rev": "e5ee5c5f3844550c01d2131096c7271cec5e9b78", "type": "github" }, "original": { @@ -209,8 +131,8 @@ "root": { "inputs": { "devenv": "devenv", - "nixpkgs": "nixpkgs_2", - "systems": "systems" + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" } }, "systems": { diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..6b39607 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: + +{ + languages.javascript.enable = true; + + pre-commit.hooks = { + shellcheck.enable = true; + shfmt.enable = true; + }; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..c7cb5ce --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,3 @@ +inputs: + nixpkgs: + url: github:NixOS/nixpkgs/nixpkgs-unstable diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 1af4195..0000000 --- a/flake.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; - systems.url = "github:nix-systems/default"; - devenv.url = "github:cachix/devenv"; - }; - - outputs = { self, nixpkgs, devenv, systems, ... } @ inputs: - let - forEachSystem = nixpkgs.lib.genAttrs (import systems); - in - { - devShells = forEachSystem - (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - default = devenv.lib.mkShell { - inherit inputs pkgs; - modules = [ - { - # https://devenv.sh/reference/options/ - packages = [ - pkgs.shellcheck - ]; - - languages.javascript.enable = true; - - pre-commit.hooks.shellcheck.enable = true; - } - ]; - }; - }); - }; -} diff --git a/lib/utils.bash b/lib/utils.bash index 8e84ed6..056ab31 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -1,44 +1,42 @@ #!/usr/bin/env bash asdf_plugin_path() { - echo "$(dirname "$(dirname "$0")")" + dirname "$(dirname "$0")" } ghcup_bin_dir() { - echo "$(asdf_plugin_path)/.ghcup/bin" + echo "$(asdf_plugin_path)/.ghcup/bin" } ensure_ghcup() { - if ! test -f "$(ghcup_bin_dir)/ghcup" - then - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | env \ - BOOTSTRAP_HASKELL_MINIMAL=1 \ - BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \ - GHCUP_INSTALL_BASE_PREFIX="$(asdf_plugin_path)" \ - sh > /dev/null - fi + if ! test -f "$(ghcup_bin_dir)/ghcup"; then + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | env \ + BOOTSTRAP_HASKELL_MINIMAL=1 \ + BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \ + GHCUP_INSTALL_BASE_PREFIX="$(asdf_plugin_path)" \ + sh >/dev/null + fi } list_all_versions() { - ensure_ghcup - "$(ghcup_bin_dir)/ghcup" list -t "$1" -r | awk '{printf $2" "}' + ensure_ghcup + "$(ghcup_bin_dir)/ghcup" list -t "$1" -r | awk '{printf $2" "}' } ver() { - echo "$1" | awk -F . '{ printf("%02d%02d", $1,$2); }' + echo "$1" | awk -F . '{ printf("%02d%02d", $1,$2); }' } install_version() { - local tool="$1" - local version="$2" - local path="$3" - - ensure_ghcup - - if [[ "$tool" == "ghc" ]] || { [[ "$tool" == "hls" ]] && [[ $(ver "$version") -ge $(ver "1.7") ]]; } - then - "$(ghcup_bin_dir)/ghcup" install "$tool" "$version" -i "$path" - else - "$(ghcup_bin_dir)/ghcup" install "$tool" "$version" -i "${path}/bin" - fi + local tool="$1" + local version="$2" + local path="$3" + + ensure_ghcup + + if [[ $tool == "ghc" ]] || { [[ $tool == "hls" ]] && [[ $(ver "$version") -ge $(ver "1.7") ]]; }; then + "$(ghcup_bin_dir)/ghcup" install "$tool" "$version" -i "$path" + else + "$(ghcup_bin_dir)/ghcup" install "$tool" "$version" -i "${path}/bin" + fi } diff --git a/test/bats b/test/bats deleted file mode 160000 index e9fd17a..0000000 --- a/test/bats +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e9fd17a70721e447313691f239d297cecea6dfb7 diff --git a/test/install.bats b/test/install.bats deleted file mode 100644 index 2873818..0000000 --- a/test/install.bats +++ /dev/null @@ -1,70 +0,0 @@ -# vi: ft=bash - -setup() { - load 'test_helper/bats-support/load' - load 'test_helper/bats-assert/load' - DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" - PATH="$DIR/../bin:$PATH" - export ASDF_INSTALL_PATH=$(mktemp -dt asdf-XXXX) -} - -teardown() { - rm -rf "${ASDF_INSTALL_PATH}" - unset ASDF_INSTALL_PATH -} - -@test "cabal 3.6.2.0" { - ASDF_INSTALL_VERSION="3.6.2.0" install cabal - run "${ASDF_INSTALL_PATH}/bin/cabal" --version - assert_success - assert_output --partial "${ASDF_INSTALL_VERSION}" -} - -@test "cabal 3.8.1.0" { - ASDF_INSTALL_VERSION="3.8.1.0" install cabal - run "${ASDF_INSTALL_PATH}/bin/cabal" --version - assert_success - assert_output --partial "${ASDF_INSTALL_VERSION}" -} - -@test "ghc 9.2.4" { - ASDF_INSTALL_VERSION="9.2.4" install ghc - run "${ASDF_INSTALL_PATH}/bin/ghc" --version - assert_success - assert_output --partial "${ASDF_INSTALL_VERSION}" -} - -@test "ghc 9.4.2" { - ASDF_INSTALL_VERSION="9.4.2" install ghc - run "${ASDF_INSTALL_PATH}/bin/ghc" --version - assert_success - assert_output --partial "${ASDF_INSTALL_VERSION}" -} - -@test "hls 1.6.1.0" { - ASDF_INSTALL_VERSION="1.6.1.0" install hls - run "${ASDF_INSTALL_PATH}/bin/haskell-language-server-wrapper" --version - assert_success - assert_output --partial "${ASDF_INSTALL_VERSION}" -} - -# @test "hls 1.7.0.0" { -# ASDF_INSTALL_VERSION="1.7.0.0" install hls -# run "${ASDF_INSTALL_PATH}/bin/haskell-language-server-wrapper" --version -# assert_success -# assert_output --partial "${ASDF_INSTALL_VERSION}" -# } - -@test "stack 2.5.1" { - ASDF_INSTALL_VERSION="2.5.1" install stack - run "${ASDF_INSTALL_PATH}/bin/stack" --version - assert_success - assert_output --partial "${ASDF_INSTALL_VERSION}" -} - -@test "stack 2.7.5" { - ASDF_INSTALL_VERSION="2.7.5" install stack - run "${ASDF_INSTALL_PATH}/bin/stack" --version - assert_success - assert_output --partial "${ASDF_INSTALL_VERSION}" -} diff --git a/test/list-all.bats b/test/list-all.bats deleted file mode 100644 index 6305f9e..0000000 --- a/test/list-all.bats +++ /dev/null @@ -1,32 +0,0 @@ -# vi: ft=bash - -setup() { - load 'test_helper/bats-support/load' - load 'test_helper/bats-assert/load' - DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" - PATH="$DIR/../bin:$PATH" -} - -@test "cabal" { - run list-all cabal - assert_success - assert_output --partial "3.8.1.0" -} - -@test "ghc" { - run list-all ghc - assert_success - assert_output --partial "9.4.2" -} - -@test "hls" { - run list-all hls - assert_success - assert_output --partial "1.7.0.0" -} - -@test "stack" { - run list-all stack - assert_success - assert_output --partial "2.7.5" -} diff --git a/test/test_helper/bats-assert b/test/test_helper/bats-assert deleted file mode 160000 index e2d855b..0000000 --- a/test/test_helper/bats-assert +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e2d855bc78619ee15b0c702b5c30fb074101159f diff --git a/test/test_helper/bats-support b/test/test_helper/bats-support deleted file mode 160000 index 9bf10e8..0000000 --- a/test/test_helper/bats-support +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9bf10e876dd6b624fe44423f0b35e064225f7556