From 1100f8e1e2461e4c023923408b0bfa0bca38c070 Mon Sep 17 00:00:00 2001 From: Sergey Gulin Date: Wed, 27 Sep 2023 10:55:52 +0300 Subject: [PATCH 01/16] [OPS-1448] Replace buildkite with github actions Problem: The current buildkite-based ci is being replaced with github actions. Solution: Add github ci config, remove buildkite config. --- .buildkite/pipeline.yml | 32 - .github/workflows/main.yml | 58 ++ flake.lock | 1148 +++++++++++++++++++++++++++++++++++- flake.nix | 13 +- 4 files changed, 1201 insertions(+), 50 deletions(-) delete mode 100644 .buildkite/pipeline.yml create mode 100644 .github/workflows/main.yml diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml deleted file mode 100644 index 8aa74bdc..00000000 --- a/.buildkite/pipeline.yml +++ /dev/null @@ -1,32 +0,0 @@ -# © 2019 Serokell -# © 2019 Lars Jellema -# -# SPDX-License-Identifier: MPL-2.0 - -env: - CDN_DISTRIBUTION_ID: E13UN1J1JFIWUZ - CDN_BUCKET: s3://nixfmt.serokell.io - -steps: - - label: reuse lint - commands: - - nix shell .#packages.x86_64-linux.reuse -c reuse lint - - label: nix-build - commands: - - nix build .#nixfmt-static | cachix push nixfmt - - nix build .#nixfmt-deriver | cachix push nixfmt - - label: build web demo - commands: - - set -o pipefail; nix build .#nixfmt-webdemo | cachix push nixfmt - - wait - - label: deploy web demo - branches: master - commands: - - nix build .#nixfmt-webdemo - - nix shell .#awscli -c - aws s3 cp --recursive result/ "$CDN_BUCKET" - # delete files that don't exist anymore, use `--size-only` so behavior won't depend on local file timestamps - - nix shell .#awscli -c - aws s3 sync --delete --size-only result/ "$CDN_BUCKET" - - nix shell .#awscli -c - aws cloudfront create-invalidation --distribution-id "$CDN_DISTRIBUTION_ID" --paths '/*' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..fbf87809 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,58 @@ +# © 2019-2023 Serokell +# © 2019-2023 Lars Jellema +# +# SPDX-License-Identifier: MPL-2.0 + +name: CI +on: + pull_request: + push: + branches: + - master + +env: + CDN_DISTRIBUTION_ID: E13UN1J1JFIWUZ + CDN_BUCKET: s3://nixfmt.serokell.io + +jobs: + check: + runs-on: [self-hosted, nix] + steps: + - uses: actions/checkout@v3 + + - name: reuse lint + run: nix shell .#packages.x86_64-linux.reuse -c reuse lint + + # - name: hlint + # run: nix build -L .#checks.x86_64-linux.hlint + # if: success() || failure() + + # - name: stylish-haskell + # run: nix build -L .#checks.x86_64-linux.stylish-haskell + # if: success() || failure() + + - name: build nixfmt + run: nix build -L .#nixfmt-static + if: success() || failure() + + - name: build webdemo + run: nix build -L .#nixfmt-webdemo + if: success() || failure() + + - name: build awscli + run: nix shell .#awscli + if: success() || failure() + + deploy: + runs-on: [self-hosted, nix] + if: ${{ github.ref == 'refs/heads/master' }} + steps: + - uses: actions/checkout@v3 + + - name: deploy webdemo + run: | + nix build .#nixfmt-webdemo + nix shell .#awscli -c aws s3 cp --recursive result/ "$CDN_BUCKET" + # delete files that don't exist anymore, use `--size-only` so behavior won't depend on local file timestamps + nix shell .#awscli -c aws s3 sync --delete --size-only result/ "$CDN_BUCKET" + nix shell .#awscli -c aws cloudfront create-invalidation --distribution-id "$CDN_DISTRIBUTION_ID" --paths '/*' diff --git a/flake.lock b/flake.lock index e2025e57..9215bbd2 100644 --- a/flake.lock +++ b/flake.lock @@ -1,33 +1,740 @@ { "nodes": { + "HTTP": { + "flake": false, + "locked": { + "lastModified": 1451647621, + "narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=", + "owner": "phadej", + "repo": "HTTP", + "rev": "9bc0996d412fef1787449d841277ef663ad9a915", + "type": "github" + }, + "original": { + "owner": "phadej", + "repo": "HTTP", + "type": "github" + } + }, + "blank": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "cabal-32": { + "flake": false, + "locked": { + "lastModified": 1603716527, + "narHash": "sha256-X0TFfdD4KZpwl0Zr6x+PLxUt/VyKQfX7ylXHdmZIL+w=", + "owner": "haskell", + "repo": "cabal", + "rev": "48bf10787e27364730dd37a42b603cee8d6af7ee", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.2", + "repo": "cabal", + "type": "github" + } + }, + "cabal-34": { + "flake": false, + "locked": { + "lastModified": 1645834128, + "narHash": "sha256-wG3d+dOt14z8+ydz4SL7pwGfe7SiimxcD/LOuPCV6xM=", + "owner": "haskell", + "repo": "cabal", + "rev": "5ff598c67f53f7c4f48e31d722ba37172230c462", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.4", + "repo": "cabal", + "type": "github" + } + }, + "cabal-36": { + "flake": false, + "locked": { + "lastModified": 1669081697, + "narHash": "sha256-I5or+V7LZvMxfbYgZATU4awzkicBwwok4mVoje+sGmU=", + "owner": "haskell", + "repo": "cabal", + "rev": "8fd619e33d34924a94e691c5fea2c42f0fc7f144", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.6", + "repo": "cabal", + "type": "github" + } + }, + "cardano-shell": { + "flake": false, + "locked": { + "lastModified": 1608537748, + "narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=", + "owner": "input-output-hk", + "repo": "cardano-shell", + "rev": "9392c75087cb9a3d453998f4230930dea3a95725", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "cardano-shell", + "type": "github" + } + }, + "deploy-rs": { + "inputs": { + "flake-compat": "flake-compat_2", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + }, + "locked": { + "lastModified": 1648475189, + "narHash": "sha256-gAGAS6IagwoUr1B0ohE3iR6sZ8hP4LSqzYLC8Mq3WGU=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "83e0c78291cd08cb827ba0d553ad9158ae5a95c3", + "type": "github" + }, + "original": { + "id": "deploy-rs", + "type": "indirect" + } + }, + "devshell": { + "inputs": { + "flake-utils": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "flake-utils" + ], + "nixpkgs": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1663445644, + "narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=", + "owner": "numtide", + "repo": "devshell", + "rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "dmerge": { + "inputs": { + "nixlib": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "nixpkgs" + ], + "yants": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1659548052, + "narHash": "sha256-fzI2gp1skGA8mQo/FBFrUAtY0GQkAIAaV/V127TJPyY=", + "owner": "divnix", + "repo": "data-merge", + "rev": "d160d18ce7b1a45b88344aa3f13ed1163954b497", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "data-merge", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1648199409, + "narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "64a525ee38886ab9028e6f61790de0832aa3ef03", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1627913399, + "narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2", + "type": "github" + }, + "original": { + "id": "flake-compat", + "type": "indirect" + } + }, + "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1672831974, + "narHash": "sha256-z9k3MfslLjWQfnjBtEtJZdq3H7kyi2kQtUThfTgdRk0=", + "owner": "input-output-hk", + "repo": "flake-compat", + "rev": "45f2638735f8cdc40fe302742b79f248d23eb368", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "hkm/gitlab-fix", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_5": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1631561581, + "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_5": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "get-tested-src": { + "flake": false, + "locked": { + "lastModified": 1687355864, + "narHash": "sha256-yQ4coxfnp2Jsw1kvwf2/Zn72Kltze2WrfHN54eLR070=", + "owner": "Sereja313", + "repo": "get-tested", + "rev": "455bbd047374ed907900b49641a4ea7f0a905709", + "type": "github" + }, + "original": { + "owner": "Sereja313", + "ref": "issue-8-emit-ghc-versions", + "repo": "get-tested", + "type": "github" + } + }, + "ghc-8.6.5-iohk": { + "flake": false, + "locked": { + "lastModified": 1600920045, + "narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=", + "owner": "input-output-hk", + "repo": "ghc", + "rev": "95713a6ecce4551240da7c96b6176f980af75cae", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "release/8.6.5-iohk", + "repo": "ghc", + "type": "github" + } + }, + "gitignore-nix": { + "flake": false, + "locked": { + "lastModified": 1611672876, + "narHash": "sha256-qHu3uZ/o9jBHiA3MEKHJ06k7w4heOhA+4HCSIvflRxo=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "211907489e9f198594c0eb0ca9256a1949c9d412", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gomod2nix": { + "inputs": { + "nixpkgs": "nixpkgs_4", + "utils": "utils_2" + }, + "locked": { + "lastModified": 1655245309, + "narHash": "sha256-d/YPoQ/vFn1+GTmSdvbSBSTOai61FONxB4+Lt6w/IVI=", + "owner": "tweag", + "repo": "gomod2nix", + "rev": "40d32f82fc60d66402eb0972e6e368aeab3faf58", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "gomod2nix", + "type": "github" + } + }, + "hackage": { + "flake": false, + "locked": { + "lastModified": 1678926579, + "narHash": "sha256-5t1QRBTsEM2wREtDf3xrHp9Kphs+AdQZKAEltaylIJQ=", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "fb58b0ba5773c5f0211f284b0fae061426cf8267", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "hackage.nix", + "type": "github" + } + }, + "haskell-nix": { + "inputs": { + "HTTP": "HTTP", + "cabal-32": "cabal-32", + "cabal-34": "cabal-34", + "cabal-36": "cabal-36", + "cardano-shell": "cardano-shell", + "flake-compat": "flake-compat_4", + "flake-utils": "flake-utils_3", + "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", + "hackage": "hackage", + "hpc-coveralls": "hpc-coveralls", + "hydra": "hydra", + "iserv-proxy": "iserv-proxy", + "nixpkgs": [ + "serokell-nix", + "haskell-nix", + "nixpkgs-unstable" + ], + "nixpkgs-2003": "nixpkgs-2003", + "nixpkgs-2105": "nixpkgs-2105", + "nixpkgs-2111": "nixpkgs-2111", + "nixpkgs-2205": "nixpkgs-2205", + "nixpkgs-2211": "nixpkgs-2211", + "nixpkgs-unstable": "nixpkgs-unstable", + "old-ghc-nix": "old-ghc-nix", + "stackage": "stackage", + "tullia": "tullia" + }, + "locked": { + "lastModified": 1678950661, + "narHash": "sha256-lvL54W90BTvwLVnFjPYmFVmgHyaGcFrt5FBy1F0rro8=", + "owner": "input-output-hk", + "repo": "haskell.nix", + "rev": "fce554bc6a41d12f7a18a0e8290bf43f925d7a29", + "type": "github" + }, + "original": { + "id": "haskell-nix", + "type": "indirect" + } + }, + "hpc-coveralls": { + "flake": false, + "locked": { + "lastModified": 1607498076, + "narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=", + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430", + "type": "github" + }, + "original": { + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "type": "github" + } + }, + "hydra": { + "inputs": { + "nix": "nix", + "nixpkgs": [ + "serokell-nix", + "haskell-nix", + "hydra", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671755331, + "narHash": "sha256-hXsgJj0Cy0ZiCiYdW2OdBz5WmFyOMKuw4zyxKpgUKm4=", + "owner": "NixOS", + "repo": "hydra", + "rev": "f48f00ee6d5727ae3e488cbf9ce157460853fea8", + "type": "github" + }, + "original": { + "id": "hydra", + "type": "indirect" + } + }, + "incl": { + "inputs": { + "nixlib": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1669263024, + "narHash": "sha256-E/+23NKtxAqYG/0ydYgxlgarKnxmDbg6rCMWnOBqn9Q=", + "owner": "divnix", + "repo": "incl", + "rev": "ce7bebaee048e4cd7ebdb4cee7885e00c4e2abca", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "incl", + "type": "github" + } + }, + "iserv-proxy": { + "flake": false, + "locked": { + "lastModified": 1670983692, + "narHash": "sha256-avLo34JnI9HNyOuauK5R69usJm+GfW3MlyGlYxZhTgY=", + "ref": "hkm/remote-iserv", + "rev": "50d0abb3317ac439a4e7495b185a64af9b7b9300", + "revCount": 10, + "type": "git", + "url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git" + }, + "original": { + "ref": "hkm/remote-iserv", + "type": "git", + "url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git" + } + }, + "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" + } + }, + "lowdown-src_2": { + "flake": false, + "locked": { + "lastModified": 1632468475, + "narHash": "sha256-NNOm9CbdA8cuwbvaBHslGbPTiU6bh1Ao+MpEPx4rSGo=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "6bd668af3fd098bdd07a1bedd399564141e275da", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "repo": "lowdown", + "type": "github" + } + }, + "n2c": { + "inputs": { + "flake-utils": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "flake-utils" + ], + "nixpkgs": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1665039323, + "narHash": "sha256-SAh3ZjFGsaCI8FRzXQyp56qcGdAqgKEfJWPCQ0Sr7tQ=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "b008fe329ffb59b67bf9e7b08ede6ee792f2741a", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": "nixpkgs_3", + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1661606874, + "narHash": "sha256-9+rpYzI+SmxJn+EbYxjGv68Ucp22bdFUSy/4LkHkkDQ=", + "owner": "NixOS", + "repo": "nix", + "rev": "11e45768b34fdafdcf019ddbd337afa16127ff0f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "2.11.0", + "repo": "nix", + "type": "github" + } + }, + "nix-nomad": { + "inputs": { + "flake-compat": "flake-compat_5", + "flake-utils": [ + "serokell-nix", + "haskell-nix", + "tullia", + "nix2container", + "flake-utils" + ], + "gomod2nix": "gomod2nix", + "nixpkgs": [ + "serokell-nix", + "haskell-nix", + "tullia", + "nixpkgs" + ], + "nixpkgs-lib": [ + "serokell-nix", + "haskell-nix", + "tullia", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658277770, + "narHash": "sha256-T/PgG3wUn8Z2rnzfxf2VqlR1CBjInPE0l1yVzXxPnt0=", + "owner": "tristanpemble", + "repo": "nix-nomad", + "rev": "054adcbdd0a836ae1c20951b67ed549131fd2d70", + "type": "github" + }, + "original": { + "owner": "tristanpemble", + "repo": "nix-nomad", + "type": "github" + } + }, + "nix2container": { + "inputs": { + "flake-utils": "flake-utils_4", + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1658567952, + "narHash": "sha256-XZ4ETYAMU7XcpEeAFP3NOl9yDXNuZAen/aIJ84G+VgA=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "60bb43d405991c1378baf15a40b5811a53e32ffa", "type": "github" }, "original": { - "owner": "edolstra", - "repo": "flake-compat", + "owner": "nlewo", + "repo": "nix2container", "type": "github" } }, - "flake-utils": { + "nix_2": { + "inputs": { + "lowdown-src": "lowdown-src_2", + "nixpkgs": "nixpkgs_7" + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "lastModified": 1633098935, + "narHash": "sha256-UtuBczommNLwUNEnfRI7822z4vPA7OoRKsgAZ8zsHQI=", + "owner": "nixos", + "repo": "nix", + "rev": "4f496150eb4e0012914c11f0a3ff4df2412b1d09", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "id": "nix", + "type": "indirect" + } + }, + "nixago": { + "inputs": { + "flake-utils": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "flake-utils" + ], + "nixago-exts": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "blank" + ], + "nixpkgs": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1661824785, + "narHash": "sha256-/PnwdWoO/JugJZHtDUioQp3uRiWeXHUdgvoyNbXesz8=", + "owner": "nix-community", + "repo": "nixago", + "rev": "8c1f9e5f1578d4b2ea989f618588d62a335083c3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixago", "type": "github" } }, @@ -47,6 +754,102 @@ "type": "github" } }, + "nixpkgs-2003": { + "locked": { + "lastModified": 1620055814, + "narHash": "sha256-8LEHoYSJiL901bTMVatq+rf8y7QtWuZhwwpKE2fyaRY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-20.03-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2105": { + "locked": { + "lastModified": 1659914493, + "narHash": "sha256-lkA5X3VNMKirvA+SUzvEhfA7XquWLci+CGi505YFAIs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2111": { + "locked": { + "lastModified": 1659446231, + "narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eabc38219184cc3e04a974fe31857d8e0eac098d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2205": { + "locked": { + "lastModified": 1672580127, + "narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0874168639713f547c05947c76124f78441ea46c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-22.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2211": { + "locked": { + "lastModified": 1675730325, + "narHash": "sha256-uNvD7fzO5hNlltNQUAFBPlcEjNG5Gkbhl/ROiX+GZU4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b7ce17b1ebf600a72178f6302c77b6382d09323f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-22.11-darwin", + "repo": "nixpkgs", + "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": 1672580127, @@ -63,12 +866,325 @@ "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1675758091, + "narHash": "sha256-7gFSQbSVAFUHtGCNHPF7mPc5CcqDk9M2+inlVPZSneg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "747927516efcb5e31ba03b7ff32f61f6d47e7d87", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1648219316, + "narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1657693803, + "narHash": "sha256-G++2CJ9u0E7NNTAi9n5G8TdDmGJXcIjkJ3NF8cetQB8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "365e1b3a859281cf11b94f87231adeabbdd878a2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.05-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1653581809, + "narHash": "sha256-Uvka0V5MTGbeOfWte25+tfRL3moECDh1VwokWSZUdoY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "83658b28fe638a170a19b8933aa008b30640fbd1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1654807842, + "narHash": "sha256-ADymZpr6LuTEBXcy6RtFHcUZdjKTBRTMYwu19WOx17E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fc909087cc3386955f21b4665731dbdaceefb1d8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { + "locked": { + "lastModified": 1665087388, + "narHash": "sha256-FZFPuW9NWHJteATOf79rZfwfRn5fE0wi9kRzvGfDHPA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "95fda953f6db2e9496d2682c4fc7b82f959878f7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_7": { + "locked": { + "lastModified": 1632864508, + "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "82891b5e2c2359d7e58d08849e4c89511ab94234", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-21.05-small", + "type": "indirect" + } + }, + "nosys": { + "locked": { + "lastModified": 1667881534, + "narHash": "sha256-FhwJ15uPLRsvaxtt/bNuqE/ykMpNAPF0upozFKhTtXM=", + "owner": "divnix", + "repo": "nosys", + "rev": "2d0d5207f6a230e9d0f660903f8db9807b54814f", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "nosys", + "type": "github" + } + }, + "old-ghc-nix": { + "flake": false, + "locked": { + "lastModified": 1631092763, + "narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=", + "owner": "angerman", + "repo": "old-ghc-nix", + "rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8", + "type": "github" + }, + "original": { + "owner": "angerman", + "ref": "master", + "repo": "old-ghc-nix", + "type": "github" + } + }, "root": { "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "nixpkgs-stable": "nixpkgs-stable" + "nixpkgs-stable": "nixpkgs-stable", + "serokell-nix": "serokell-nix" + } + }, + "serokell-nix": { + "inputs": { + "deploy-rs": "deploy-rs", + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_2", + "get-tested-src": "get-tested-src", + "gitignore-nix": "gitignore-nix", + "haskell-nix": "haskell-nix", + "nix": "nix_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1695391091, + "narHash": "sha256-vYBB7s9bJxgmMQXFg4XWSd3VW4CYjnBRy7mkv1QXsiE=", + "owner": "serokell", + "repo": "serokell.nix", + "rev": "567820afeec19e53b134038a3f307171eaa6668f", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "serokell.nix", + "type": "github" + } + }, + "stackage": { + "flake": false, + "locked": { + "lastModified": 1678925630, + "narHash": "sha256-rl8qnpAUJl4tRZpaZ5DpgSueNfreArW09t4zTnOaoYA=", + "owner": "input-output-hk", + "repo": "stackage.nix", + "rev": "bf29b23fb77017e78c6e7b199b2c7bfb5079c4cd", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "stackage.nix", + "type": "github" + } + }, + "std": { + "inputs": { + "arion": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "blank" + ], + "blank": "blank", + "devshell": "devshell", + "dmerge": "dmerge", + "flake-utils": "flake-utils_5", + "incl": "incl", + "makes": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "blank" + ], + "microvm": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "blank" + ], + "n2c": "n2c", + "nixago": "nixago", + "nixpkgs": "nixpkgs_6", + "nosys": "nosys", + "yants": "yants" + }, + "locked": { + "lastModified": 1674526466, + "narHash": "sha256-tMTaS0bqLx6VJ+K+ZT6xqsXNpzvSXJTmogkraBGzymg=", + "owner": "divnix", + "repo": "std", + "rev": "516387e3d8d059b50e742a2ff1909ed3c8f82826", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "std", + "type": "github" + } + }, + "tullia": { + "inputs": { + "nix-nomad": "nix-nomad", + "nix2container": "nix2container", + "nixpkgs": [ + "serokell-nix", + "haskell-nix", + "nixpkgs" + ], + "std": "std" + }, + "locked": { + "lastModified": 1675695930, + "narHash": "sha256-B7rEZ/DBUMlK1AcJ9ajnAPPxqXY6zW2SBX+51bZV0Ac=", + "owner": "input-output-hk", + "repo": "tullia", + "rev": "621365f2c725608f381b3ad5b57afef389fd4c31", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "tullia", + "type": "github" + } + }, + "utils": { + "locked": { + "lastModified": 1648297722, + "narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "utils_2": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "yants": { + "inputs": { + "nixpkgs": [ + "serokell-nix", + "haskell-nix", + "tullia", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1667096281, + "narHash": "sha256-wRRec6ze0gJHmGn6m57/zhz/Kdvp9HS4Nl5fkQ+uIuA=", + "owner": "divnix", + "repo": "yants", + "rev": "d18f356ec25cb94dc9c275870c3a7927a10f8c3c", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "yants", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 0f68db7d..2f7352ac 100644 --- a/flake.nix +++ b/flake.nix @@ -16,9 +16,13 @@ url = "github:edolstra/flake-compat"; flake = false; }; + serokell-nix = { + url = "github:serokell/serokell.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, nixpkgs-stable, flake-utils, ... }: + outputs = { self, nixpkgs, nixpkgs-stable, flake-utils, serokell-nix, ... }: flake-utils.lib.eachDefaultSystem (system: let overlay = self: super: { @@ -31,7 +35,7 @@ pkgs = import nixpkgs { inherit system; - overlays = [ overlay ]; + overlays = [ overlay serokell-nix.overlay ]; }; pkgs-stable = import nixpkgs-stable { @@ -96,5 +100,10 @@ }; devShells.default = self.packages.${system}.nixfmt-shell; + + checks = { + hlint = pkgs.build.haskell.hlint ./.; + stylish-haskell = pkgs.build.haskell.stylish-haskell ./.; + }; }); } From ca9c8975ed671112fdfce94f2e9e2ad3de480c9a Mon Sep 17 00:00:00 2001 From: piegames Date: Mon, 25 Sep 2023 17:32:43 +0200 Subject: [PATCH 02/16] Don't touch files if they don't need changing Fixes #88 --- CHANGELOG.md | 1 + main/Main.hs | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b1f3b6a..a04cd703 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * Fix escaping of interpolations after dollar signs. * Fix nixfmt trying to allocate temp files that aren't used. +* Don't write if files didn't change, fixing treefmt compatibility * Nixfmt now accepts the '-' argument to read from stdin. * `nixfmt [dir]` now recursively formats nix files in that directory. * Float and int literal parsing now matches nix. diff --git a/main/Main.hs b/main/Main.hs index 5b1a3cef..018ff5d1 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -64,7 +64,8 @@ options = data Target = Target { tDoRead :: IO Text , tPath :: FilePath - , tDoWrite :: Text -> IO () + -- The bool is true when the formatted file differs from the input + , tDoWrite :: Bool -> Text -> IO () } -- | Recursively collect nix files in a directory @@ -84,8 +85,8 @@ collectAllNixFiles paths = concat <$> mapM collectNixFiles paths formatTarget :: Formatter -> Target -> IO Result formatTarget format Target{tDoRead, tPath, tDoWrite} = do contents <- tDoRead - let formatted = format tPath contents - mapM tDoWrite formatted + let formatResult = format tPath contents + mapM (\formatted -> tDoWrite (formatted /= contents) formatted) formatResult -- | Return an error if target could not be parsed or was not formatted -- correctly. @@ -99,17 +100,19 @@ checkTarget format Target{tDoRead, tPath} = do | otherwise -> Left $ tPath ++ ": not formatted" stdioTarget :: Target -stdioTarget = Target TextIO.getContents "" TextIO.putStr +stdioTarget = Target TextIO.getContents "" (const $ TextIO.putStr) fileTarget :: FilePath -> Target fileTarget path = Target (readFileUtf8 path) path atomicWriteFile where - atomicWriteFile t = withOutputFile path $ \h -> do + atomicWriteFile True t = withOutputFile path $ \h -> do hSetEncoding h utf8 TextIO.hPutStr h t + -- Don't do anything if the file is already formatted + atomicWriteFile False _ = mempty checkFileTarget :: FilePath -> Target -checkFileTarget path = Target (readFileUtf8 path) path (const $ pure ()) +checkFileTarget path = Target (readFileUtf8 path) path (const $ const $ pure ()) toTargets :: Nixfmt -> IO [Target] toTargets Nixfmt{ files = [] } = pure [stdioTarget] From edf47573087ef43401d237ff6517e4c4986e98a1 Mon Sep 17 00:00:00 2001 From: Roman Melnikov Date: Wed, 25 Oct 2023 11:09:31 +0200 Subject: [PATCH 03/16] [Chore] Remove cachix cache mentions Problem: README mentions cachix cache that doesn't seem to be up-to-date. Additionally, there is no much sense in keeping it since all deps are taken directly from 'nixpkgs' and thus they're supposed to be cached by 'cache.nixos.org' already. Solution: Remove cachinx mentions from the README. --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 47ea37fd..24069715 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ You are encouraged to test this out on your code and submit any undesirable formatting you find as an issue [![Build Status](https://badge.buildkite.com/b37f73adea391439e63288e8fd3b47f4b98fb9640bb864ccfa.svg)](https://buildkite.com/serokell/nixfmt) -[![Cachix](https://img.shields.io/badge/cachix-nixfmt-blue.svg)](https://nixfmt.cachix.org) ## Installation @@ -21,8 +20,6 @@ You are encouraged to test this out on your code and submit any undesirable form - To get the most recent version, install from master: - # Optional: use cachix to get cached builds even for master - cachix use nixfmt nix-env -f https://github.com/serokell/nixfmt/archive/master.tar.gz -i - Nix with flakes From 71936d4721a1cff8b4e58a1ed0549a805a7d274d Mon Sep 17 00:00:00 2001 From: Roman Melnikov Date: Wed, 25 Oct 2023 11:13:13 +0200 Subject: [PATCH 04/16] [Chore] Update build status badge in README Problem: Build status badge in README points to Buildkite pipeline which doesn't exist anymore. Solution: Use GitHub Actions badge instead. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 24069715..3fa20fe5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ You are encouraged to test this out on your code and submit any undesirable formatting you find as an issue -[![Build Status](https://badge.buildkite.com/b37f73adea391439e63288e8fd3b47f4b98fb9640bb864ccfa.svg)](https://buildkite.com/serokell/nixfmt) +![Build Status](https://github.com/serokell/nixfmt/actions/workflows/main.yml/badge.svg?branch=master) ## Installation From f283c2662806d0b0fe4446dd2f519cb57465d73a Mon Sep 17 00:00:00 2001 From: piegames Date: Sat, 23 Sep 2023 10:01:18 +0200 Subject: [PATCH 05/16] Document release process --- MAINTENANCE.md | 14 ++++++++++++++ README.md | 5 ----- 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 MAINTENANCE.md diff --git a/MAINTENANCE.md b/MAINTENANCE.md new file mode 100644 index 00000000..a50a8a35 --- /dev/null +++ b/MAINTENANCE.md @@ -0,0 +1,14 @@ + + +# Maintainer documentation + +## Making a new release + +- Check the commit log if anything is missing from the change log. +- Check dependency versions in `nixfmt.cabal`, bump upper bounds if possible. +- Bump the version. +- Give it a git tag. +- Upload to hackage using `cabal sdist`. See https://hackage.haskell.org/upload for details. diff --git a/README.md b/README.md index 3fa20fe5..f17c0c7e 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,6 @@ Haskell dependencies will be built by Cabal. * `nixfmt file.nix` – format the file in place -## For Contributors - -We welcome issues and pull requests on GitHub. - - ## About Serokell `nixfmt` is maintained and funded with :heart: by From 981b1d768c444310bf626e5ae7ff24a25fcefb5d Mon Sep 17 00:00:00 2001 From: piegames Date: Sat, 23 Sep 2023 11:37:25 +0200 Subject: [PATCH 06/16] Relax dependency version bounds Closes #130 --- nixfmt.cabal | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nixfmt.cabal b/nixfmt.cabal index 704461c9..6f4b9356 100644 --- a/nixfmt.cabal +++ b/nixfmt.cabal @@ -41,11 +41,11 @@ executable nixfmt else buildable: True build-depends: - base >= 4.12.0 && < 4.17 + base >= 4.12.0 && < 4.19 , cmdargs >= 0.10.20 && < 0.11 , nixfmt - , unix >= 2.7.2 && < 2.8 - , text >= 1.2.3 && < 1.3 + , unix >= 2.7.2 && < 2.9 + , text >= 1.2.3 && < 2.2 -- for System.IO.Atomic , directory >= 1.3.3 && < 1.4 @@ -86,11 +86,11 @@ library hs-source-dirs: src build-depends: - base >= 4.12.0 && < 4.17 - , megaparsec >= 9.0.1 && < 9.3 + base >= 4.12.0 && < 4.19 + , megaparsec >= 9.0.1 && < 9.6 , parser-combinators >= 1.0.3 && < 1.4 , scientific >= 0.3.0 && < 0.4.0 - , text >= 1.2.3 && < 1.3 + , text >= 1.2.3 && < 2.2 default-language: Haskell2010 ghc-options: -Wall @@ -113,7 +113,7 @@ executable js-interface -Wredundant-constraints -Wno-orphans build-depends: - base >= 4.12.0 && < 4.17 + base >= 4.12.0 && < 4.19 , ghcjs-base >= 0.2.0 && < 0.3 , nixfmt hs-source-dirs: js/ From 79495e6b2c31be7989709205e59d64ecde2212a1 Mon Sep 17 00:00:00 2001 From: piegames Date: Mon, 2 Oct 2023 12:04:46 +0200 Subject: [PATCH 07/16] Update Nix dependencies --- flake.lock | 44 +++++++++++++++++++++++++++++++------------- flake.nix | 2 +- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/flake.lock b/flake.lock index 9215bbd2..9b948906 100644 --- a/flake.lock +++ b/flake.lock @@ -182,11 +182,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "owner": "edolstra", "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "type": "github" }, "original": { @@ -260,12 +260,15 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -740,11 +743,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1667292599, - "narHash": "sha256-7ISOUI1aj6UKMPIL+wwthENL22L3+A9V+jS8Is3QsRo=", + "lastModified": 1696165369, + "narHash": "sha256-pd1cjFHCoEf9q5f9B0HhlOwwpBI9RP3HbUE6xjI7wAI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ef2f213d9659a274985778bff4ca322f3ef3ac68", + "rev": "d7186d62bb68fac3c90f1d95515e613ef299e992", "type": "github" }, "original": { @@ -852,16 +855,16 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1672580127, - "narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=", + "lastModified": 1696039360, + "narHash": "sha256-g7nIUV4uq1TOVeVIDEZLb005suTWCUjSY0zYOlSBsyE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0874168639713f547c05947c76124f78441ea46c", + "rev": "32dcb45f66c0487e92db8303a798ebc548cadedc", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.05", + "ref": "nixos-23.05", "repo": "nixpkgs", "type": "github" } @@ -1186,6 +1189,21 @@ "repo": "yants", "type": "github" } + }, + "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", diff --git a/flake.nix b/flake.nix index 2f7352ac..8e4dca6b 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-22.05"; + nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.05"; flake-utils.url = "github:numtide/flake-utils"; From f6e7e80105d9689e022f6ca1687401f2cc1c4721 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Tue, 31 Oct 2023 22:07:12 +0100 Subject: [PATCH 08/16] Fix TypeOperators warning --- src/Nixfmt/Parser/Float.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nixfmt/Parser/Float.hs b/src/Nixfmt/Parser/Float.hs index c5360b55..660ac839 100644 --- a/src/Nixfmt/Parser/Float.hs +++ b/src/Nixfmt/Parser/Float.hs @@ -4,7 +4,7 @@ - SPDX-License-Identifier: MPL-2.0 -} -{-# LANGUAGE TypeFamilies, TypeApplications, ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies, TypeApplications, ScopedTypeVariables, TypeOperators #-} module Nixfmt.Parser.Float (floatParse) where From 6d0f1438efff048843ff493ec1d42988ba42f49e Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Tue, 31 Oct 2023 22:13:04 +0100 Subject: [PATCH 09/16] Export missing symbols --- src/Nixfmt.hs | 1 + src/Nixfmt/Predoc.hs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Nixfmt.hs b/src/Nixfmt.hs index ff0fcff1..a8af7c4d 100644 --- a/src/Nixfmt.hs +++ b/src/Nixfmt.hs @@ -7,6 +7,7 @@ module Nixfmt ( errorBundlePretty , ParseErrorBundle + , Width , format , formatVerify ) where diff --git a/src/Nixfmt/Predoc.hs b/src/Nixfmt/Predoc.hs index 4e1b41c6..d128ffee 100644 --- a/src/Nixfmt/Predoc.hs +++ b/src/Nixfmt/Predoc.hs @@ -24,6 +24,7 @@ module Nixfmt.Predoc , hardline , emptyline , newline + , DocE , Doc , Pretty , pretty From 8b6ccc6b423fcee7cedc766f173c685498926290 Mon Sep 17 00:00:00 2001 From: piegames Date: Wed, 6 Sep 2023 23:10:17 +0200 Subject: [PATCH 10/16] Bump version to 0.6.0 --- CHANGELOG.md | 2 ++ nixfmt.cabal | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a04cd703..162b3a8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ ## Unreleased +## 0.6.0 -- 2023-10-31 + * Fix escaping of interpolations after dollar signs. * Fix nixfmt trying to allocate temp files that aren't used. * Don't write if files didn't change, fixing treefmt compatibility diff --git a/nixfmt.cabal b/nixfmt.cabal index 6f4b9356..832b28e3 100644 --- a/nixfmt.cabal +++ b/nixfmt.cabal @@ -6,7 +6,7 @@ cabal-version: 2.0 -- SPDX-License-Identifier: MPL-2.0 name: nixfmt -version: 0.5.0 +version: 0.6.0 synopsis: An opinionated formatter for Nix description: A formatter for Nix that ensures consistent and clear formatting by forgetting From df9bda061dedba261193b5c9f5cd9d61b537b77b Mon Sep 17 00:00:00 2001 From: piegames Date: Fri, 10 Nov 2023 15:48:29 +0100 Subject: [PATCH 11/16] Parse inherit names with quotes --- CHANGELOG.md | 3 ++ src/Nixfmt/Parser.hs | 44 ++++++++++++++++----- src/Nixfmt/Pretty.hs | 20 +++++----- src/Nixfmt/Types.hs | 7 ++-- test/correct/quotes-in-inherit-2.nix | 7 ++++ test/correct/quotes-in-inherit.nix | 1 + test/invalid/interpolation-in-inherit-1.nix | 4 ++ test/invalid/interpolation-in-inherit-2.nix | 1 + 8 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 test/correct/quotes-in-inherit-2.nix create mode 100644 test/correct/quotes-in-inherit.nix create mode 100644 test/invalid/interpolation-in-inherit-1.nix create mode 100644 test/invalid/interpolation-in-inherit-2.nix diff --git a/CHANGELOG.md b/CHANGELOG.md index 162b3a8e..0322c7a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ ## Unreleased +* Parsing fixes + * Quotes in inherit statements (like `inherit "or";`) are now supported. + ## 0.6.0 -- 2023-10-31 * Fix escaping of interpolations after dollar signs. diff --git a/src/Nixfmt/Parser.hs b/src/Nixfmt/Parser.hs index 0c11cfc3..bb32f1bf 100644 --- a/src/Nixfmt/Parser.hs +++ b/src/Nixfmt/Parser.hs @@ -26,7 +26,7 @@ import qualified Text.Megaparsec.Char.Lexer as L (decimal) import Nixfmt.Lexer (lexeme) import Nixfmt.Types - (Ann, Binder(..), Expression(..), File(..), Fixity(..), Leaf, Operator(..), + (Ann(..), Binder(..), Expression(..), File(..), Fixity(..), Leaf, Operator(..), ParamAttr(..), Parameter(..), Parser, Path, Selector(..), SimpleSelector(..), String, StringPart(..), Term(..), Token(..), operators, tokenText) import Nixfmt.Parser.Float (floatParse) @@ -103,6 +103,21 @@ interpolation :: Parser StringPart interpolation = Interpolation <$> symbol TInterOpen <*> expression <*> rawSymbol TInterClose +-- Interpolation, but only allowing identifiers and simple strings inside +interpolationRestricted :: Parser StringPart +interpolationRestricted = Interpolation <$> + symbol TInterOpen <*> + -- simple string without dynamic interpolations + (Term <$> String <$> do + str <- string + guard $ not $ containsInterpolation str + return str + ) <*> + rawSymbol TInterClose + where + containsInterpolation (Ann str _ _) = + any (\part -> case part of { Interpolation _ _ _ -> True; _ -> False }) $ concat str + simpleStringPart :: Parser StringPart simpleStringPart = TextPart <$> someText ( chunk "\\n" *> pure "\n" <|> @@ -214,18 +229,25 @@ parens :: Parser Term parens = Parenthesized <$> symbol TParenOpen <*> expression <*> symbol TParenClose +simpleSelector :: Parser StringPart -> Parser SimpleSelector +simpleSelector parseInterpolation = + ((IDSelector <$> identifier) <|> + (InterpolSelector <$> lexeme parseInterpolation) <|> + (StringSelector <$> lexeme simpleString)) + selector :: Maybe (Parser Leaf) -> Parser Selector selector parseDot = Selector <$> - sequence parseDot <* notFollowedBy path <*> - ((IDSelector <$> identifier) <|> - (InterpolSelector <$> lexeme interpolation) <|> - (StringSelector <$> lexeme simpleString)) <*> - optional (liftM2 (,) (reserved KOr) term) + sequence parseDot <* notFollowedBy path <*> simpleSelector interpolation selectorPath :: Parser [Selector] selectorPath = (pure <$> selector Nothing) <> many (selector $ Just $ symbol TDot) +-- Path with a leading dot +selectorPath' :: Parser [Selector] +selectorPath' = many $ try $ selector $ Just $ symbol TDot + +-- Everything but selection simpleTerm :: Parser Term simpleTerm = (String <$> string) <|> (Path <$> path) <|> (Token <$> (envPath <|> float <|> integer <|> identifier)) <|> @@ -234,9 +256,11 @@ simpleTerm = (String <$> string) <|> (Path <$> path) <|> term :: Parser Term term = label "term" $ do t <- simpleTerm - s <- many $ try $ selector $ Just $ symbol TDot - return $ case s of [] -> t - _ -> Selection t s + sel <- selectorPath' + def <- optional (liftM2 (,) (reserved KOr) term) + return $ case sel of + [] -> t + _ -> Selection t sel def -- ABSTRACTIONS @@ -271,7 +295,7 @@ abstraction = try (Abstraction <$> inherit :: Parser Binder inherit = Inherit <$> reserved KInherit <*> optional parens <*> - many identifier <*> symbol TSemicolon + many (simpleSelector interpolationRestricted) <*> symbol TSemicolon assignment :: Parser Binder assignment = Assignment <$> diff --git a/src/Nixfmt/Pretty.hs b/src/Nixfmt/Pretty.hs index eb4d7200..51a77de3 100644 --- a/src/Nixfmt/Pretty.hs +++ b/src/Nixfmt/Pretty.hs @@ -11,7 +11,7 @@ module Nixfmt.Pretty where import Prelude hiding (String) import Data.Char (isSpace) -import Data.Maybe (fromMaybe) +import Data.Maybe (fromMaybe, isNothing) import Data.Text (Text, isPrefixOf, isSuffixOf, stripPrefix) import qualified Data.Text as Text (dropEnd, empty, init, isInfixOf, last, null, strip, takeWhile) @@ -62,13 +62,9 @@ instance Pretty SimpleSelector where = prettySimpleString s <> pretty trailing <> pretty leading instance Pretty Selector where - pretty (Selector dot sel Nothing) + pretty (Selector dot sel) = pretty dot <> pretty sel - pretty (Selector dot sel (Just (kw, def))) - = pretty dot <> pretty sel - <> hardspace <> pretty kw <> hardspace <> pretty def - instance Pretty Binder where pretty (Inherit inherit Nothing ids semicolon) = base $ group (pretty inherit <> softline @@ -89,7 +85,9 @@ prettyTerm :: Term -> Doc prettyTerm (Token t) = pretty t prettyTerm (String s) = pretty s prettyTerm (Path p) = pretty p -prettyTerm (Selection term selectors) = pretty term <> hcat selectors +prettyTerm (Selection term selectors Nothing) = pretty term <> hcat selectors +prettyTerm (Selection term selectors (Just (kw, def))) = + pretty term <> hcat selectors <> hardspace <> pretty kw <> hardspace <> pretty def prettyTerm (List (Ann paropen Nothing []) [] parclose) = pretty paropen <> hardspace <> pretty parclose @@ -264,13 +262,13 @@ instance Pretty [Token] where -- STRINGS isSimpleSelector :: Selector -> Bool -isSimpleSelector (Selector _ (IDSelector _) Nothing) = True -isSimpleSelector _ = False +isSimpleSelector (Selector _ (IDSelector _)) = True +isSimpleSelector _ = False isSimple :: Expression -> Bool isSimple (Term (Token (Ann (Identifier _) Nothing []))) = True -isSimple (Term (Selection t selectors)) - = isSimple (Term t) && all isSimpleSelector selectors +isSimple (Term (Selection t selectors def)) + = isSimple (Term t) && all isSimpleSelector selectors && isNothing def isSimple _ = False hasQuotes :: [StringPart] -> Bool diff --git a/src/Nixfmt/Types.hs b/src/Nixfmt/Types.hs index 042b76c0..fd09cd21 100644 --- a/src/Nixfmt/Types.hs +++ b/src/Nixfmt/Types.hs @@ -57,11 +57,12 @@ data SimpleSelector deriving (Eq, Show) data Selector - = Selector (Maybe Leaf) SimpleSelector (Maybe (Leaf, Term)) + -- `.selector` + = Selector (Maybe Leaf) SimpleSelector deriving (Eq, Show) data Binder - = Inherit Leaf (Maybe Term) [Leaf] Leaf + = Inherit Leaf (Maybe Term) [SimpleSelector] Leaf | Assignment [Selector] Leaf Expression Leaf deriving (Eq, Show) @@ -71,7 +72,7 @@ data Term | Path Path | List Leaf [Term] Leaf | Set (Maybe Leaf) Leaf [Binder] Leaf - | Selection Term [Selector] + | Selection Term [Selector] (Maybe (Leaf, Term)) | Parenthesized Leaf Expression Leaf deriving (Eq, Show) diff --git a/test/correct/quotes-in-inherit-2.nix b/test/correct/quotes-in-inherit-2.nix new file mode 100644 index 00000000..c25efa8c --- /dev/null +++ b/test/correct/quotes-in-inherit-2.nix @@ -0,0 +1,7 @@ +let + foo = 1; + "bar" = 2; + ${"baz"} = 3; + ${"in"} = 4; + +in { inherit ${"foo"} bar "baz" "in"; } diff --git a/test/correct/quotes-in-inherit.nix b/test/correct/quotes-in-inherit.nix new file mode 100644 index 00000000..a36f90d9 --- /dev/null +++ b/test/correct/quotes-in-inherit.nix @@ -0,0 +1 @@ +{ inherit ({ "in" = 1; }) "in"; } diff --git a/test/invalid/interpolation-in-inherit-1.nix b/test/invalid/interpolation-in-inherit-1.nix new file mode 100644 index 00000000..bf47290a --- /dev/null +++ b/test/invalid/interpolation-in-inherit-1.nix @@ -0,0 +1,4 @@ +let + bar = "bar"; + +in { inherit ${bar}; } diff --git a/test/invalid/interpolation-in-inherit-2.nix b/test/invalid/interpolation-in-inherit-2.nix new file mode 100644 index 00000000..431b1d1a --- /dev/null +++ b/test/invalid/interpolation-in-inherit-2.nix @@ -0,0 +1 @@ +{ inherit ${"foo" + "bar"}; } From f29b7be36f62cfa37883d9da6b290018ea0b324c Mon Sep 17 00:00:00 2001 From: Roman Melnikov Date: Tue, 12 Dec 2023 12:41:41 +0100 Subject: [PATCH 12/16] [Chore] Update "actions/checkout" Problem: node16 is now deprecated and github-runner provided by nixpkgs no longer supports this runtime. However, "actions/checkout@v3" uses this runtime. Solution: Update CI pipeline to use "actions/checkout@v4". --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fbf87809..3406e519 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: check: runs-on: [self-hosted, nix] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: reuse lint run: nix shell .#packages.x86_64-linux.reuse -c reuse lint @@ -47,7 +47,7 @@ jobs: runs-on: [self-hosted, nix] if: ${{ github.ref == 'refs/heads/master' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: deploy webdemo run: | From c477950137d8fe7ec9e8fee481d0141fd8317b22 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 13 Mar 2024 00:53:02 +0100 Subject: [PATCH 13/16] readme: Add status note --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index f17c0c7e..2979ccd4 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,14 @@ You are encouraged to test this out on your code and submit any undesirable form ![Build Status](https://github.com/serokell/nixfmt/actions/workflows/main.yml/badge.svg?branch=master) +## State + +`nixfmt` will form the basis for the initial official standard Nix formatter, as established by [RFC 166](https://github.com/NixOS/rfcs/pull/166). + +The established standard Nix formatting differs considerably from the original one. Be aware of this if you track the main branch. Until the first new release the main branch should be considered **very unstable**. + +For more details, see the [RFC implementation tracking issue](https://github.com/serokell/nixfmt/issues/153). + ## Installation - `nixfmt` is in nixpkgs master as of 2019-09-04: From 5ee28fc22bd1c5f79549a6c5ec930c56541a22a9 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 13 Mar 2024 01:50:13 +0100 Subject: [PATCH 14/16] Create team document --- team/README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 team/README.md diff --git a/team/README.md b/team/README.md new file mode 100644 index 00000000..c9447a55 --- /dev/null +++ b/team/README.md @@ -0,0 +1,40 @@ + + +# Nix formatting team + +This page collects information and processes for the Nix formatting team. + +## Links + +- GitHub team: [@NixOS/nix-formatting](https://github.com/orgs/NixOS/teams/nix-formatting/members) +- Matrix room: [#nix-formatting:nixos.org](https://matrix.to/#/#nix-formatting:nixos.org) +- Meeting calendar: [Search for "Nix formatting"](https://calendar.google.com/calendar/u/0/embed?src=b9o52fobqjak8oq8lfkhg3t0qg@group.calendar.google.com) +- Meeting link: [Jitsi](https://meet.zrh.init7.net/nix-formatting) +- Live meeting notes: [HedgeDoc](https://pad.lassul.us/nix-formatting) + +## Responsibilities + +The responsibilities of team members are: +- Responding to personal pings in the Matrix room and GitHub issues/PRs for this repository +- Reviewing PRs of this repository when requested + +The team lead has additional responsibilities: +- Keeping track of tasks +- Posting meeting notes +- Managing permissions +- Keeping team information up-to-date + +## Processes + +After every meeting, the notes must be posted to [Discourse](https://discourse.nixos.org/) + +For all non-trivial decisions: +- At least 2 members must reach consensus + - This can be on Matrix, GitHub or in meetings +- The decision must be publicly documented, in any of: + - GitHub issues/PRs + - Design documents in the repository + - Meeting notes From d5e91da10c89211c777a6ca5cbb8632c0d5d1831 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 13 Mar 2024 22:16:09 +0100 Subject: [PATCH 15/16] ci: remove deploy and fix after repo transfer The web demo will be retired from this repo soon anyways, see https://github.com/NixOS/nixfmt/issues/157 I believe it also relied on using Serokell's self-hosted action runners, which we can't use anymore now that the repo has been transferred, so we use the default ubuntu-latest instead. --- .github/workflows/main.yml | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3406e519..f42f9e24 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,49 +10,17 @@ on: branches: - master -env: - CDN_DISTRIBUTION_ID: E13UN1J1JFIWUZ - CDN_BUCKET: s3://nixfmt.serokell.io - jobs: check: - runs-on: [self-hosted, nix] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v26 + - name: reuse lint run: nix shell .#packages.x86_64-linux.reuse -c reuse lint - # - name: hlint - # run: nix build -L .#checks.x86_64-linux.hlint - # if: success() || failure() - - # - name: stylish-haskell - # run: nix build -L .#checks.x86_64-linux.stylish-haskell - # if: success() || failure() - - name: build nixfmt run: nix build -L .#nixfmt-static if: success() || failure() - - - name: build webdemo - run: nix build -L .#nixfmt-webdemo - if: success() || failure() - - - name: build awscli - run: nix shell .#awscli - if: success() || failure() - - deploy: - runs-on: [self-hosted, nix] - if: ${{ github.ref == 'refs/heads/master' }} - steps: - - uses: actions/checkout@v4 - - - name: deploy webdemo - run: | - nix build .#nixfmt-webdemo - nix shell .#awscli -c aws s3 cp --recursive result/ "$CDN_BUCKET" - # delete files that don't exist anymore, use `--size-only` so behavior won't depend on local file timestamps - nix shell .#awscli -c aws s3 sync --delete --size-only result/ "$CDN_BUCKET" - nix shell .#awscli -c aws cloudfront create-invalidation --distribution-id "$CDN_DISTRIBUTION_ID" --paths '/*' From 52295a3891888c45c147ea85856da95c415930df Mon Sep 17 00:00:00 2001 From: Sergey Gulin Date: Thu, 14 Mar 2024 01:26:13 +0300 Subject: [PATCH 16/16] Remove webdemo The nixfmt-webdemo is moving to https://github.com/serokell/nixfmt-website. Remove all code associated with the webdemo, including the nixfmt-js distribution. --- flake.lock | 47 +++------- flake.nix | 31 +----- js/404.html | 7 -- js/JSInterface.hs | 37 -------- js/index.html | 234 ---------------------------------------------- nixfmt.cabal | 26 ------ 6 files changed, 17 insertions(+), 365 deletions(-) delete mode 100644 js/404.html delete mode 100644 js/JSInterface.hs delete mode 100644 js/index.html diff --git a/flake.lock b/flake.lock index 9b948906..a207da7d 100644 --- a/flake.lock +++ b/flake.lock @@ -853,22 +853,6 @@ "type": "github" } }, - "nixpkgs-stable": { - "locked": { - "lastModified": 1696039360, - "narHash": "sha256-g7nIUV4uq1TOVeVIDEZLb005suTWCUjSY0zYOlSBsyE=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "32dcb45f66c0487e92db8303a798ebc548cadedc", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs-unstable": { "locked": { "lastModified": 1675758091, @@ -1016,7 +1000,6 @@ "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "nixpkgs-stable": "nixpkgs-stable", "serokell-nix": "serokell-nix" } }, @@ -1111,6 +1094,21 @@ "type": "github" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "tullia": { "inputs": { "nix-nomad": "nix-nomad", @@ -1189,21 +1187,6 @@ "repo": "yants", "type": "github" } - }, - "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", diff --git a/flake.nix b/flake.nix index 8e4dca6b..11fe0661 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,6 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.05"; flake-utils.url = "github:numtide/flake-utils"; @@ -22,7 +21,7 @@ }; }; - outputs = { self, nixpkgs, nixpkgs-stable, flake-utils, serokell-nix, ... }: + outputs = { self, nixpkgs, flake-utils, serokell-nix, ... }: flake-utils.lib.eachDefaultSystem (system: let overlay = self: super: { @@ -38,26 +37,8 @@ overlays = [ overlay serokell-nix.overlay ]; }; - pkgs-stable = import nixpkgs-stable { - inherit system; - overlays = [ overlay ]; - }; - inherit (pkgs) haskell lib; - ghcjsPackages = pkgs-stable.haskell.packages.ghcjs810.override (old: { - overrides = (self: super: { - QuickCheck = haskell.lib.dontCheck super.QuickCheck; - tasty-quickcheck = haskell.lib.dontCheck super.tasty-quickcheck; - scientific = haskell.lib.dontCheck super.scientific; - temporary = haskell.lib.dontCheck super.temporary; - time-compat = haskell.lib.dontCheck super.time-compat; - text-short = haskell.lib.dontCheck super.text-short; - vector = haskell.lib.dontCheck super.vector; - aeson = super.aeson_1_5_6_0; - }); - }); - regexes = [ ".*.cabal$" "^src.*" "^main.*" "^Setup.hs$" "^js.*" "LICENSE" ]; src = builtins.path { @@ -74,14 +55,6 @@ nixfmt = pkgs.haskellPackages.nixfmt; nixfmt-static = haskell.lib.justStaticExecutables nixfmt; nixfmt-deriver = nixfmt-static.cabal2nixDeriver; - nixfmt-js = ghcjsPackages.callCabal2nix "nixfmt" src { }; - nixfmt-webdemo = pkgs.runCommandNoCC "nixfmt-webdemo" { } '' - mkdir $out - cp ${./js/index.html} $out/index.html - cp ${./js/404.html} $out/404.html - cp ${nixfmt-js}/bin/js-interface.jsexe/{rts,lib,out,runmain}.js $out - substituteInPlace $out/index.html --replace ../dist/build/js-interface/js-interface.jsexe/ ./ - ''; nixfmt-shell = nixfmt.env.overrideAttrs (oldAttrs: { buildInputs = oldAttrs.buildInputs ++ (with pkgs; [ @@ -91,7 +64,7 @@ ]); }); - inherit (pkgs) awscli reuse; + inherit (pkgs) reuse; }; apps.default = { diff --git a/js/404.html b/js/404.html deleted file mode 100644 index 31fab38e..00000000 --- a/js/404.html +++ /dev/null @@ -1,7 +0,0 @@ - - -404 Page Not Found diff --git a/js/JSInterface.hs b/js/JSInterface.hs deleted file mode 100644 index dc1bb895..00000000 --- a/js/JSInterface.hs +++ /dev/null @@ -1,37 +0,0 @@ -{- © 2019 Serokell - - - - SPDX-License-Identifier: MPL-2.0 - -} - -{-# LANGUAGE OverloadedStrings #-} -import GHCJS.Marshal -import GHCJS.Foreign -import GHCJS.Foreign.Callback -import GHCJS.Types -import JavaScript.Object -import qualified JavaScript.Object.Internal as O -import Data.JSString.Text -import qualified Data.JSString as S - -import Nixfmt - -foreign import javascript unsafe "window.nixfmt_ = $1" - js_set_logic :: JSVal -> IO () - -main :: IO () -main = do - callback <- syncCallback2 ThrowWouldBlock $ \text_ o -> do - let obj = O.Object o - Just width <- getProp (textToJSString "width") obj >>= fromJSVal - Just filename_ <- getProp (textToJSString "filename") obj >>= fromJSVal - let filename = S.unpack filename_ - let text = textFromJSVal text_ - out <- case format width filename text of - Left err -> do - setProp "err" (toJSBool True) obj - toJSVal $ S.pack err - Right out_ -> do - setProp "err" (toJSBool False) obj - toJSVal out_ - setProp "ret" out obj - js_set_logic $ jsval callback diff --git a/js/index.html b/js/index.html deleted file mode 100644 index 4bcbf42c..00000000 --- a/js/index.html +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - - - nixfmt online demo - - - - - - - - - - - - - - -
# nixfmt loading
-
xxx
- - Fork me on GitHub - - - diff --git a/nixfmt.cabal b/nixfmt.cabal index 832b28e3..61016937 100644 --- a/nixfmt.cabal +++ b/nixfmt.cabal @@ -36,10 +36,6 @@ executable nixfmt Paths_nixfmt other-extensions: DeriveDataTypeable hs-source-dirs: main - if impl(ghcjs) - buildable: False - else - buildable: True build-depends: base >= 4.12.0 && < 4.19 , cmdargs >= 0.10.20 && < 0.11 @@ -99,25 +95,3 @@ library -Wincomplete-uni-patterns -Wredundant-constraints -Wno-orphans - -executable js-interface - main-is: JSInterface.hs - - if impl(ghcjs) - buildable: True - ghc-options: - -Wall - -Wcompat - -Wincomplete-record-updates - -Wincomplete-uni-patterns - -Wredundant-constraints - -Wno-orphans - build-depends: - base >= 4.12.0 && < 4.19 - , ghcjs-base >= 0.2.0 && < 0.3 - , nixfmt - hs-source-dirs: js/ - else - buildable: False - - default-language: Haskell2010