From baa88003bffd23f17279d9b72291a2ce42899883 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 2 May 2022 16:53:40 -0700 Subject: [PATCH 01/26] Replace current CI implementation with Nix-flake based CI --- .buildkite/pipeline.yml | 64 ----- ci.nix | 71 ------ coffer.nix | 33 --- flake.lock | 537 ++++++++++++++++++++++++++++++++++++++- flake.nix | 101 +++++--- nix/sources.json | 99 -------- nix/sources.json.license | 3 - nix/sources.nix | 174 ------------- nix/sources.nix.license | 3 - 9 files changed, 601 insertions(+), 484 deletions(-) delete mode 100644 .buildkite/pipeline.yml delete mode 100644 ci.nix delete mode 100644 coffer.nix delete mode 100644 nix/sources.json delete mode 100644 nix/sources.json.license delete mode 100644 nix/sources.nix delete mode 100644 nix/sources.nix.license diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml deleted file mode 100644 index 208aafcc..00000000 --- a/.buildkite/pipeline.yml +++ /dev/null @@ -1,64 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Serokell -# -# SPDX-License-Identifier: MPL-2.0 - -steps: - - label: check trailing whitespaces - command: nix-build ci.nix -A trailing-whitespace-check - - - label: shellcheck - command: nix run -f ci.nix pkgs.shellcheck -c find . -name '*.sh' -exec shellcheck {} + - - - label: validate cabal files - command: nix run -f ci.nix stack2cabal pkgs.diffutils -c ./scripts/validate-cabal-files.sh - - - label: stylish - command: nix run -f ci.nix pkgs.gnumake pkgs-stylish.stylish-haskell -c ./scripts/validate-stylish.sh - - - label: lint - command: nix run -f ci.nix pkgs.haskellPackages.hlint -c hlint . - - - label: build - key: build - command: nix-build ci.nix -A lib -A cli -A server - - - label: server integration - depends_on: build - commands: - - nix-build ci.nix -A server-integration - - ./result/bin/server-integration - - - label: tests - depends_on: build - commands: - - nix-build ci.nix -A tests - - ./result/bin/test - - - label: golden tests - depends_on: build - commands: - - export PATH=$(nix-build ci.nix -A project.coffer.components.exes.coffer --no-out-link)/bin:$PATH - - nix run - -f ci.nix pkgs.vault pkgs.bats - -c ./scripts/run-bats-tests.sh - - - label: haddock - depends_on: build - command: nix-build ci.nix -A haddock - - - label: linux static executable - command: nix-build ci.nix -A coffer-static - artifact_paths: - - "result/bin/coffer" - - - label: xrefcheck - command: nix run -f ci.nix xrefcheck -c xrefcheck --no-progress -m full --ignored tests/golden/helpers - - - label: REUSE lint - command: nix run -f ci.nix pkgs.reuse -c reuse lint - - - label: weeder - depends_on: build - commands: - - nix-build ci.nix -A weeder-script - - ./result diff --git a/ci.nix b/ci.nix deleted file mode 100644 index 5e289a84..00000000 --- a/ci.nix +++ /dev/null @@ -1,71 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Serokell -# -# SPDX-License-Identifier: MPL-2.0 - -rec { - sources = import ./nix/sources.nix; - xrefcheck = import sources.xrefcheck; - haskell-nix = import sources."haskell.nix" { - sourcesOverride = { hackage = sources."hackage.nix"; stackage = sources."stackage.nix"; }; - }; - serokell-nix = import sources."serokell.nix"; - pkgs = import sources.nixpkgs ( - haskell-nix.nixpkgsArgs // { - overlays = - haskell-nix.nixpkgsArgs.overlays - ++ [ serokell-nix.overlay ]; # contains trailing whitespace check - } - ); - - local-packages = [{ - name = "coffer"; - subdirectory = "."; - }]; - - project-src = pkgs.haskell-nix.haskellLib.cleanGit { - name = "coffer"; - src = pkgs.haskell-nix.haskellLib.cleanSourceWith { - filter = path: type: !(pkgs.lib.hasInfix "tests/golden/helpers" path); - src = ./.; - }; - }; - - # TODO: drop this when `serokell/nixpkgs` acquires stylish-haskell >= 0.13.0.0. - pkgs-stylish = import sources.nixpkgs-stylish {}; - - project = (import ./coffer.nix { linux = true; }); - - lib = project.coffer.components.library; - cli = project.coffer.components.exes.coffer; - server = project.coffer.components.exes.coffer-server; - tests = project.coffer.components.tests.test; - server-integration = project.coffer.components.tests.server-integration; - doctests = project.coffer.components.tests.doctests; - haddock = project.coffer.components.library.haddock; - - coffer-static = (import ./coffer.nix { linux-static = true; }).coffer.components.exes.coffer; - coffer-windows = (import ./coffer.nix { windows = true; }).coffer.components.exes.coffer; - - trailing-whitespace-check = pkgs.build.checkTrailingWhitespace project-src; - - weeder-hacks = import sources.haskell-nix-weeder { inherit pkgs; }; - - # nixpkgs has weeder 2, but we use weeder 1 - weeder-legacy = pkgs.haskellPackages.callHackageDirect { - pkg = "weeder"; - ver = "1.0.9"; - sha256 = "0gfvhw7n8g2274k74g8gnv1y19alr1yig618capiyaix6i9wnmpa"; - } {}; - - weeder-script = weeder-hacks.weeder-script { - weeder = weeder-legacy; - hs-pkgs = project; - local-packages = local-packages; - }; - - # stack2cabal is broken because of strict constraints, set 'jailbreak' to ignore them - stack2cabal = pkgs.haskell.lib.overrideCabal pkgs.haskellPackages.stack2cabal (drv: { - jailbreak = true; - broken = false; - }); -} diff --git a/coffer.nix b/coffer.nix deleted file mode 100644 index 3ac5228d..00000000 --- a/coffer.nix +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-FileCopyrightText: 2020 Serokell -# -# SPDX-License-Identifier: MPL-2.0 - -{ linux ? false, linux-static ? false, windows ? false }: -let - sources = import ./nix/sources.nix; - weeder-hacks = import sources.haskell-nix-weeder { inherit pkgs; }; - nixpkgs = (import ./ci.nix).pkgs; - src = (import ./ci.nix).project-src; - pkgs = if linux-static then nixpkgs.pkgsCross.musl64 else if windows then nixpkgs.pkgsCross.mingwW64 else nixpkgs; - project = pkgs.haskell-nix.stackProject { - src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; }; - modules = [{ - packages.coffer = { - ghcOptions = [ - "-Werror" - # produce *.dump-hi files, required for weeder - "-ddump-to-file" "-ddump-hi" - ]; - - # collect all *.dump-hi files (required for weeder) - postInstall = weeder-hacks.collect-dump-hi-files; - - # enable haddock for local packages - doHaddock = true; - }; - - # disable haddock for dependencies - doHaddock = false; - }]; - }; -in project diff --git a/flake.lock b/flake.lock index a90d3673..8228fa5e 100644 --- a/flake.lock +++ b/flake.lock @@ -1,24 +1,551 @@ { "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" + } + }, + "cabal-32": { + "flake": false, + "locked": { + "lastModified": 1603716527, + "narHash": "sha256-sDbrmur9Zfp4mPKohCD8IDZfXJ0Tjxpmr2R+kg5PpSY=", + "owner": "haskell", + "repo": "cabal", + "rev": "94aaa8e4720081f9c75497e2735b90f6a819b08e", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.2", + "repo": "cabal", + "type": "github" + } + }, + "cabal-34": { + "flake": false, + "locked": { + "lastModified": 1622475795, + "narHash": "sha256-chwTL304Cav+7p38d9mcb+egABWmxo2Aq+xgVBgEb/U=", + "owner": "haskell", + "repo": "cabal", + "rev": "b086c1995cdd616fc8d91f46a21e905cc50a1049", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.4", + "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" + } + }, + "common-infra": { + "inputs": { + "deploy": "deploy", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1633243752, + "narHash": "sha256-MRC5gTnVL6WEXNxpfBQCf/TZYdlrlu6qlxKBTsmbzEo=", + "owner": "serokell", + "repo": "common-infra", + "rev": "9f5e90cdc97a5e37e7c9b07a4970aa114abef071", + "type": "github" + }, + "original": { + "id": "common-infra", + "type": "indirect" + } + }, + "deploy": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "common-infra", + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1632822684, + "narHash": "sha256-lt7eayYmgsD5OQwpb1XYfHpxttn43bWo7G7hIJs+zJw=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "9a02de4373e0ec272d08a417b269a28ac8b961b4", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1627913399, + "narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "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-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-utils": { + "locked": { + "lastModified": 1649676176, + "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1623875721, + "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1631561581, + "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "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" + } + }, + "hackage": { + "flake": false, + "locked": { + "lastModified": 1636766065, + "narHash": "sha256-g3/EFO0QNrbU8U9DDd/qByTshrxE30FAMMppfb/uIXI=", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "cebdce72a115476f3ea681812b449fba35cfe40f", + "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", + "cardano-shell": "cardano-shell", + "flake-utils": "flake-utils_2", + "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", + "hackage": "hackage", + "hpc-coveralls": "hpc-coveralls", + "nix-tools": "nix-tools", + "nixpkgs": [ + "haskell-nix", + "nixpkgs-2105" + ], + "nixpkgs-2003": "nixpkgs-2003", + "nixpkgs-2009": "nixpkgs-2009", + "nixpkgs-2105": "nixpkgs-2105", + "nixpkgs-unstable": "nixpkgs-unstable", + "old-ghc-nix": "old-ghc-nix", + "stackage": "stackage" + }, + "locked": { + "lastModified": 1636798039, + "narHash": "sha256-zUqHTquXysBMYsa7Ne7u9Wo1oLRl8ByQI6eJel7ZV5o=", + "owner": "input-output-hk", + "repo": "haskell.nix", + "rev": "91ec10c0321b75a79a4b6af69fdb30fa748ec0f7", + "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" + } + }, + "lowdown-src": { + "flake": false, + "locked": { + "lastModified": 1632468475, + "narHash": "sha256-NNOm9CbdA8cuwbvaBHslGbPTiU6bh1Ao+MpEPx4rSGo=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "6bd668af3fd098bdd07a1bedd399564141e275da", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "repo": "lowdown", + "type": "github" + } + }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1633098935, + "narHash": "sha256-UtuBczommNLwUNEnfRI7822z4vPA7OoRKsgAZ8zsHQI=", + "owner": "nixos", + "repo": "nix", + "rev": "4f496150eb4e0012914c11f0a3ff4df2412b1d09", + "type": "github" + }, + "original": { + "id": "nix", + "type": "indirect" + } + }, + "nix-tools": { + "flake": false, + "locked": { + "lastModified": 1636018067, + "narHash": "sha256-ng306fkuwr6V/malWtt3979iAC4yMVDDH2ViwYB6sQE=", + "owner": "input-output-hk", + "repo": "nix-tools", + "rev": "ed5bd7215292deba55d6ab7a4e8c21f8b1564dda", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "nix-tools", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1640443850, - "narHash": "sha256-s3EhD+iNjyIE/gZkV5vES6d0eI4dJ2WBlaXyUsEmaek=", + "lastModified": 1633218386, + "narHash": "sha256-vvhkyCczeApnYjSe6wuDhNERN4w/ryAdFeLgMVr95Ik=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bd8b494cab0722440ab48e22d3fe7a3acda1ee76", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "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-2009": { + "locked": { + "lastModified": 1624271064, + "narHash": "sha256-qns/uRW7MR2EfVf6VEeLgCsCp7pIOjDeR44JzTF09MA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "46d1c3f28ca991601a53e9a14fdd53fcd3dd8416", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-20.09-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2105": { + "locked": { + "lastModified": 1630481079, + "narHash": "sha256-leWXLchbAbqOlLT6tju631G40SzQWPqaAXQG3zH1Imw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "110a2c9ebbf5d4a94486854f18a37a938cfacbbb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1635295995, + "narHash": "sha256-sGYiXjFlxTTMNb4NSkgvX+knOOTipE6gqwPUQpxNF+c=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6979c0e49bb491e18dd4870abb104cc7375aa7e8", + "rev": "22a500a3f87bbce73bd8d777ef920b43a636f018", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1651144877, + "narHash": "sha256-GX9VhRym/XDoI78Eqvq9wCPB7li/xqxLEzQpkdhBFbA=", + "owner": "serokell", + "repo": "nixpkgs", + "rev": "cf0afe951da00abdcac2dfbf9fcb26ac9ba8c85e", "type": "github" }, "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1632864508, + "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", "owner": "NixOS", - "ref": "nixos-21.11", "repo": "nixpkgs", + "rev": "82891b5e2c2359d7e58d08849e4c89511ab94234", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-21.05-small", + "type": "indirect" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1632495107, + "narHash": "sha256-4NGE56r+FJGBaCYu3CTH4O83Ys4TrtnEPXrvdwg1TDs=", + "owner": "serokell", + "repo": "nixpkgs", + "rev": "be220b2dc47092c1e739bf6aaf630f29e71fe1c4", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "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": { - "nixpkgs": "nixpkgs" + "common-infra": "common-infra", + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils", + "haskell-nix": "haskell-nix", + "nixpkgs": "nixpkgs_2", + "serokell-nix": "serokell-nix" + } + }, + "serokell-nix": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_3", + "gitignore-nix": "gitignore-nix", + "nix": "nix", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1651500391, + "narHash": "sha256-3MpLm+4hDffPuKZG9y0eSXnogSlyxbpKNg0PbuhOgGE=", + "owner": "serokell", + "repo": "serokell.nix", + "rev": "704c973ea31084ecdf76154928eda3c730458fc2", + "type": "github" + }, + "original": { + "id": "serokell-nix", + "type": "indirect" + } + }, + "stackage": { + "flake": false, + "locked": { + "lastModified": 1636766230, + "narHash": "sha256-4CPN69Cb76oBtu2ZrZ0Tkxbif++f3w2OyUqIo2NaMQk=", + "owner": "input-output-hk", + "repo": "stackage.nix", + "rev": "81f02976025f90b0755044372512655203b4d56e", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "stackage.nix", + "type": "github" + } + }, + "utils": { + "locked": { + "lastModified": 1631561581, + "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 478ff0f1..8becfb2e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,37 +1,74 @@ { - inputs = - { nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-21.11"; + description = "Multi-backend password store with multiple frontends"; + + nixConfig = { + flake-registry = "https://github.com/serokell/flake-registry/raw/master/flake-registry.json"; + }; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; }; + }; + + outputs = { self, nixpkgs, haskell-nix, flake-utils, common-infra, serokell-nix, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + src = pkgs.haskell-nix.haskellLib.cleanGit { + name = "coffer"; + src = ./.; + }; + + pkgs = import nixpkgs { + inherit system; + overlays = [ haskell-nix.overlay serokell-nix.overlay ]; + }; + + project = pkgs.haskell-nix.stackProject { + inherit src; - outputs = { self, nixpkgs }: - with nixpkgs.lib; - let - supportedSystems = [ "x86_64-linux" ]; - forAllSystems' = genAttrs; - forAllSystems = forAllSystems' supportedSystems; - pkgsForSystem = system: - import nixpkgs { inherit system; overlays = singleton self.overlay; }; - in + modules = [{ + packages.coffer = { + # strip executable to reduce closure size + dontStrip = false; + }; + }]; + }; + + inherit (project) coffer; + in { - overlay = final: prev: - {}; - - devShell = forAllSystems - (system: - let - pkgs = pkgsForSystem system; - in - pkgs.mkShell { - nativeBuildInputs = with pkgs; - [ ghc - cabal-install - haskell-language-server - haskellPackages.implicit-hie - ]; - buildInputs = with pkgs; - [ zlib - ]; - } - ); - }; + packages = { + coffer = coffer.components.exes.coffer; + }; + + checks = { + reuse = pkgs.build.reuseLint src; + trailingWhitespace = pkgs.build.checkTrailingWhitespace src; + + hlint = pkgs.build.hlint src; + + tests = coffer.components.tests.test; + doctests = coffer.components.tests.doctests; + lib = coffer.components.library; + haddock = coffer.components.haddock; + }; + + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + ghc + cabal-install + haskell-language-server + haskellPackages.implicit-hie + ]; + buildInputs = with pkgs; [ + zlib + ]; + }; + + pipelineFile = common-infra.mkPipelineFile self; + }); } diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index 691dca36..00000000 --- a/nix/sources.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "hackage.nix": { - "branch": "master", - "description": "Automatically generated Nix expressions for Hackage", - "homepage": "", - "owner": "input-output-hk", - "repo": "hackage.nix", - "rev": "aee511167e363943d6d28e0d45244abca38cbd47", - "sha256": "11c4vrxcvxxz82kvjir4253fif4iv17439v3y4ijblnxvwi4znhw", - "type": "tarball", - "url": "https://github.com/input-output-hk/hackage.nix/archive/aee511167e363943d6d28e0d45244abca38cbd47.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "haskell-nix-weeder": { - "branch": "master", - "description": "haskell.nix + weeder", - "homepage": null, - "owner": "serokell", - "repo": "haskell-nix-weeder", - "rev": "a959fce7499df473e13336959cba77fbc87f3b7f", - "sha256": "1pmlndvbhzxj1k5f87d9dxfa00zbvmkmvnbd1davzwg77bd639l0", - "type": "tarball", - "url": "https://github.com/serokell/haskell-nix-weeder/archive/a959fce7499df473e13336959cba77fbc87f3b7f.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "haskell.nix": { - "branch": "master", - "description": "Alternative Haskell Infrastructure for Nixpkgs", - "homepage": "https://input-output-hk.github.io/haskell.nix", - "owner": "input-output-hk", - "repo": "haskell.nix", - "rev": "29433c04fa097b50be67c5b799eb7a87982cd900", - "sha256": "0hrwl6x51gxw80nmqbd8gds289i073zjs6mxzicgsj7lxjn47gmc", - "type": "tarball", - "url": "https://github.com/input-output-hk/haskell.nix/archive/29433c04fa097b50be67c5b799eb7a87982cd900.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "master", - "description": "Pinned Nixpkgs tree (master follows nixos-unstable-small, only tags have stable history)", - "homepage": "", - "owner": "serokell", - "repo": "nixpkgs", - "rev": "1714a2ead1a18678afa3cbf75dff3f024c579061", - "sha256": "12lypkc60p1w4v4j6gr097hdp1kj7fwhhi5yhb3j73z2l99zrq1d", - "type": "tarball", - "url": "https://github.com/serokell/nixpkgs/archive/1714a2ead1a18678afa3cbf75dff3f024c579061.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "serokell.nix": { - "branch": "master", - "description": "Serokell Nix infrastructure library", - "homepage": null, - "owner": "serokell", - "repo": "serokell.nix", - "rev": "652105c5fc5564f5d8e682d61bdc0d51bbc1f939", - "sha256": "19zkjhyjbksf2fw32h7m3x0v8nvgdy2qkjkxg2qzzb25as245vmj", - "type": "tarball", - "url": "https://github.com/serokell/serokell.nix/archive/652105c5fc5564f5d8e682d61bdc0d51bbc1f939.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs-stylish": { - "branch": "master", - "description": "Nix Packages collection", - "homepage": "", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "19574af0af3ffaf7c9e359744ed32556f34536bd", - "sha256": "0v3c4r8v40jimicdxqvxnzmdypnafm2baam7z131zk6ljhb8jpg9", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/19574af0af3ffaf7c9e359744ed32556f34536bd.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "stackage.nix": { - "branch": "master", - "description": "Automatically generated Nix expressions of Stackage snapshots", - "homepage": "", - "owner": "input-output-hk", - "repo": "stackage.nix", - "rev": "04c16cfb469aba767d0669edf5ea409c784c5bb3", - "sha256": "1km2a0llii2g9wlqza7w3ra1hwp4p4gs3w3z6wsyxx37cp2l5iyk", - "type": "tarball", - "url": "https://github.com/input-output-hk/stackage.nix/archive/04c16cfb469aba767d0669edf5ea409c784c5bb3.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "xrefcheck": { - "branch": "v0.2", - "description": "Check cross-references in repository documents", - "homepage": "", - "owner": "serokell", - "repo": "xrefcheck", - "rev": "dd0ad17f9cfed378be796fbd974aae7efb26d6b4", - "sha256": "1jn6vz2ii8j24jszg9iqw0z292910g8420kp419n2wcywhiswwah", - "type": "tarball", - "url": "https://github.com/serokell/xrefcheck/archive/dd0ad17f9cfed378be796fbd974aae7efb26d6b4.tar.gz", - "url_template": "https://github.com///archive/.tar.gz", - "version": "0.1.3" - } -} diff --git a/nix/sources.json.license b/nix/sources.json.license deleted file mode 100644 index 838dd5c2..00000000 --- a/nix/sources.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2022 Serokell - -SPDX-License-Identifier: MPL-2.0 diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index 1938409d..00000000 --- a/nix/sources.nix +++ /dev/null @@ -1,174 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of type . - # - - fetch_file = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } - else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; - - fetch_tarball = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } - else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; - - fetch_git = name: spec: - let - ref = - if spec ? ref then spec.ref else - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; - in - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; - - fetch_local = spec: spec.path; - - fetch_builtin-tarball = name: throw - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=tarball -a builtin=true''; - - fetch_builtin-url = name: throw - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=file -a builtin=true''; - - # - # Various helpers - # - - # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git name spec - else if spec.type == "local" then fetch_local spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # If the environment variable NIV_OVERRIDE_${name} is set, then use - # the path directly as opposed to the fetched source. - replace = name: drv: - let - saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; - ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; - in - if ersatz == "" then drv else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); - concatStrings = builtins.concatStringsSep ""; - - # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 - optionalAttrs = cond: as: if cond then as else {}; - - # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchTarball; - in - if lessThan nixVersion "1.12" then - fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchTarball attrs; - - # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchurl; - in - if lessThan nixVersion "1.12" then - fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchurl attrs; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs ( - name: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; - -in -mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/nix/sources.nix.license b/nix/sources.nix.license deleted file mode 100644 index 838dd5c2..00000000 --- a/nix/sources.nix.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2022 Serokell - -SPDX-License-Identifier: MPL-2.0 From 25cfaa39339c17e1904d44363d4f2c542d6179af Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 2 May 2022 17:01:37 -0700 Subject: [PATCH 02/26] Add flake-compat default.nix --- default.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..873ece49 --- /dev/null +++ b/default.nix @@ -0,0 +1,13 @@ +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { + src = ./.; + }).defaultNix From 5bb8b994cd2d4c50076598480b2886d9d4369219 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 2 May 2022 17:19:53 -0700 Subject: [PATCH 03/26] Fix checks, work around mkPipeline issue, repin haskell-nix, define pipelineFile without system --- flake.lock | 208 ++++++++++++++++++++++++++++++++++++++++------------- flake.nix | 16 +++-- 2 files changed, 170 insertions(+), 54 deletions(-) diff --git a/flake.lock b/flake.lock index 8228fa5e..f436b430 100644 --- a/flake.lock +++ b/flake.lock @@ -20,10 +20,10 @@ "flake": false, "locked": { "lastModified": 1603716527, - "narHash": "sha256-sDbrmur9Zfp4mPKohCD8IDZfXJ0Tjxpmr2R+kg5PpSY=", + "narHash": "sha256-X0TFfdD4KZpwl0Zr6x+PLxUt/VyKQfX7ylXHdmZIL+w=", "owner": "haskell", "repo": "cabal", - "rev": "94aaa8e4720081f9c75497e2735b90f6a819b08e", + "rev": "48bf10787e27364730dd37a42b603cee8d6af7ee", "type": "github" }, "original": { @@ -36,11 +36,11 @@ "cabal-34": { "flake": false, "locked": { - "lastModified": 1622475795, - "narHash": "sha256-chwTL304Cav+7p38d9mcb+egABWmxo2Aq+xgVBgEb/U=", + "lastModified": 1640353650, + "narHash": "sha256-N1t6M3/wqj90AEdRkeC8i923gQYUpzSr8b40qVOZ1Rk=", "owner": "haskell", "repo": "cabal", - "rev": "b086c1995cdd616fc8d91f46a21e905cc50a1049", + "rev": "942639c18c0cd8ec53e0a6f8d120091af35312cd", "type": "github" }, "original": { @@ -50,6 +50,23 @@ "type": "github" } }, + "cabal-36": { + "flake": false, + "locked": { + "lastModified": 1641652457, + "narHash": "sha256-BlFPKP4C4HRUJeAbdembX1Rms1LD380q9s0qVDeoAak=", + "owner": "haskell", + "repo": "cabal", + "rev": "f27667f8ec360c475027dcaee0138c937477b070", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.6", + "repo": "cabal", + "type": "github" + } + }, "cardano-shell": { "flake": false, "locked": { @@ -171,11 +188,11 @@ }, "flake-utils_2": { "locked": { - "lastModified": 1623875721, - "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", "owner": "numtide", "repo": "flake-utils", - "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", "type": "github" }, "original": { @@ -234,11 +251,11 @@ "hackage": { "flake": false, "locked": { - "lastModified": 1636766065, - "narHash": "sha256-g3/EFO0QNrbU8U9DDd/qByTshrxE30FAMMppfb/uIXI=", + "lastModified": 1651454026, + "narHash": "sha256-rZ3kXs58+StsqwwnQqnZYLMTzDBhgHlANnGtHLEozOQ=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "cebdce72a115476f3ea681812b449fba35cfe40f", + "rev": "11d019f2b818eb92bbdf61bad95609f118b9594c", "type": "github" }, "original": { @@ -252,34 +269,37 @@ "HTTP": "HTTP", "cabal-32": "cabal-32", "cabal-34": "cabal-34", + "cabal-36": "cabal-36", "cardano-shell": "cardano-shell", "flake-utils": "flake-utils_2", "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", "hackage": "hackage", "hpc-coveralls": "hpc-coveralls", + "hydra": "hydra", "nix-tools": "nix-tools", "nixpkgs": [ "haskell-nix", - "nixpkgs-2105" + "nixpkgs-unstable" ], "nixpkgs-2003": "nixpkgs-2003", - "nixpkgs-2009": "nixpkgs-2009", "nixpkgs-2105": "nixpkgs-2105", + "nixpkgs-2111": "nixpkgs-2111", "nixpkgs-unstable": "nixpkgs-unstable", "old-ghc-nix": "old-ghc-nix", "stackage": "stackage" }, "locked": { - "lastModified": 1636798039, - "narHash": "sha256-zUqHTquXysBMYsa7Ne7u9Wo1oLRl8ByQI6eJel7ZV5o=", + "lastModified": 1651454127, + "narHash": "sha256-FE6Nk414M0Or5/bQtVUg/KTntGDDPiz8kK3kygV4XQg=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "91ec10c0321b75a79a4b6af69fdb30fa748ec0f7", + "rev": "4ee7270856a6ba4617c7e51a6c619f365faad894", "type": "github" }, "original": { - "id": "haskell-nix", - "type": "indirect" + "owner": "input-output-hk", + "repo": "haskell.nix", + "type": "github" } }, "hpc-coveralls": { @@ -298,7 +318,46 @@ "type": "github" } }, + "hydra": { + "inputs": { + "nix": "nix", + "nixpkgs": [ + "haskell-nix", + "hydra", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1646878427, + "narHash": "sha256-KtbrofMtN8GlM7D+n90kixr7QpSlVmdN+vK5CA/aRzc=", + "owner": "NixOS", + "repo": "hydra", + "rev": "28b682b85b7efc5cf7974065792a1f22203a5927", + "type": "github" + }, + "original": { + "id": "hydra", + "type": "indirect" + } + }, "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, @@ -317,29 +376,32 @@ "nix": { "inputs": { "lowdown-src": "lowdown-src", - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_2", + "nixpkgs-regression": "nixpkgs-regression" }, "locked": { - "lastModified": 1633098935, - "narHash": "sha256-UtuBczommNLwUNEnfRI7822z4vPA7OoRKsgAZ8zsHQI=", - "owner": "nixos", + "lastModified": 1643066034, + "narHash": "sha256-xEPeMcNJVOeZtoN+d+aRwolpW8mFSEQx76HTRdlhPhg=", + "owner": "NixOS", "repo": "nix", - "rev": "4f496150eb4e0012914c11f0a3ff4df2412b1d09", + "rev": "a1cd7e58606a41fcf62bf8637804cf8306f17f62", "type": "github" }, "original": { - "id": "nix", - "type": "indirect" + "owner": "NixOS", + "ref": "2.6.0", + "repo": "nix", + "type": "github" } }, "nix-tools": { "flake": false, "locked": { - "lastModified": 1636018067, - "narHash": "sha256-ng306fkuwr6V/malWtt3979iAC4yMVDDH2ViwYB6sQE=", + "lastModified": 1649424170, + "narHash": "sha256-XgKXWispvv5RCvZzPb+p7e6Hy3LMuRjafKMl7kXzxGw=", "owner": "input-output-hk", "repo": "nix-tools", - "rev": "ed5bd7215292deba55d6ab7a4e8c21f8b1564dda", + "rev": "e109c94016e3b6e0db7ed413c793e2d4bdb24aa7", "type": "github" }, "original": { @@ -348,6 +410,24 @@ "type": "github" } }, + "nix_2": { + "inputs": { + "lowdown-src": "lowdown-src_2", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1633098935, + "narHash": "sha256-UtuBczommNLwUNEnfRI7822z4vPA7OoRKsgAZ8zsHQI=", + "owner": "nixos", + "repo": "nix", + "rev": "4f496150eb4e0012914c11f0a3ff4df2412b1d09", + "type": "github" + }, + "original": { + "id": "nix", + "type": "indirect" + } + }, "nixpkgs": { "locked": { "lastModified": 1633218386, @@ -378,45 +458,60 @@ "type": "github" } }, - "nixpkgs-2009": { + "nixpkgs-2105": { "locked": { - "lastModified": 1624271064, - "narHash": "sha256-qns/uRW7MR2EfVf6VEeLgCsCp7pIOjDeR44JzTF09MA=", + "lastModified": 1645296114, + "narHash": "sha256-y53N7TyIkXsjMpOG7RhvqJFGDacLs9HlyHeSTBioqYU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "46d1c3f28ca991601a53e9a14fdd53fcd3dd8416", + "rev": "530a53dcbc9437363471167a5e4762c5fcfa34a1", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-20.09-darwin", + "ref": "nixpkgs-21.05-darwin", "repo": "nixpkgs", "type": "github" } }, - "nixpkgs-2105": { + "nixpkgs-2111": { "locked": { - "lastModified": 1630481079, - "narHash": "sha256-leWXLchbAbqOlLT6tju631G40SzQWPqaAXQG3zH1Imw=", + "lastModified": 1648744337, + "narHash": "sha256-bYe1dFJAXovjqiaPKrmAbSBEK5KUkgwVaZcTbSoJ7hg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "110a2c9ebbf5d4a94486854f18a37a938cfacbbb", + "rev": "0a58eebd8ec65ffdef2ce9562784123a73922052", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-21.05-darwin", + "ref": "nixpkgs-21.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "indirect" } }, "nixpkgs-unstable": { "locked": { - "lastModified": 1635295995, - "narHash": "sha256-sGYiXjFlxTTMNb4NSkgvX+knOOTipE6gqwPUQpxNF+c=", + "lastModified": 1648219316, + "narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "22a500a3f87bbce73bd8d777ef920b43a636f018", + "rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634", "type": "github" }, "original": { @@ -427,6 +522,21 @@ } }, "nixpkgs_2": { + "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" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1651144877, "narHash": "sha256-GX9VhRym/XDoI78Eqvq9wCPB7li/xqxLEzQpkdhBFbA=", @@ -440,7 +550,7 @@ "type": "indirect" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1632864508, "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", @@ -455,7 +565,7 @@ "type": "indirect" } }, - "nixpkgs_4": { + "nixpkgs_5": { "locked": { "lastModified": 1632495107, "narHash": "sha256-4NGE56r+FJGBaCYu3CTH4O83Ys4TrtnEPXrvdwg1TDs=", @@ -492,7 +602,7 @@ "flake-compat": "flake-compat_2", "flake-utils": "flake-utils", "haskell-nix": "haskell-nix", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "serokell-nix": "serokell-nix" } }, @@ -501,8 +611,8 @@ "flake-compat": "flake-compat_3", "flake-utils": "flake-utils_3", "gitignore-nix": "gitignore-nix", - "nix": "nix", - "nixpkgs": "nixpkgs_4" + "nix": "nix_2", + "nixpkgs": "nixpkgs_5" }, "locked": { "lastModified": 1651500391, @@ -520,11 +630,11 @@ "stackage": { "flake": false, "locked": { - "lastModified": 1636766230, - "narHash": "sha256-4CPN69Cb76oBtu2ZrZ0Tkxbif++f3w2OyUqIo2NaMQk=", + "lastModified": 1651194938, + "narHash": "sha256-2pDyInnRI7JLZ4QYpx02o0eqE/lR+nouPD/uVCI+yZw=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "81f02976025f90b0755044372512655203b4d56e", + "rev": "893d8518231919df7e894d350508e930d24fd401", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 8becfb2e..7169a69a 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,9 @@ inputs = { flake-utils.url = "github:numtide/flake-utils"; + # Remove once registry-pinned haskell.nix is repinned + haskell-nix.url = "github:input-output-hk/haskell.nix"; + flake-compat = { url = "github:edolstra/flake-compat"; flake = false; @@ -49,12 +52,12 @@ reuse = pkgs.build.reuseLint src; trailingWhitespace = pkgs.build.checkTrailingWhitespace src; - hlint = pkgs.build.hlint src; + hlint = pkgs.build.haskell.hlint src; tests = coffer.components.tests.test; doctests = coffer.components.tests.doctests; lib = coffer.components.library; - haddock = coffer.components.haddock; + haddock = coffer.components.library.haddock; }; devShell = pkgs.mkShell { @@ -68,7 +71,10 @@ zlib ]; }; - - pipelineFile = common-infra.mkPipelineFile self; - }); + }) // { + pipelineFile = common-infra.mkPipelineFile (self // { + # Remove once https://github.com/serokell/common-infra/issues/4 is fixed + deployFromPipeline = []; + }); + }; } From 7848c4621c3ab714355d15036a1d49ab8eec5e43 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 2 May 2022 20:38:43 -0700 Subject: [PATCH 04/26] Add weeder and experimental flake-native pipeline generator --- flake.lock | 16 ++++++++ flake.nix | 27 ++++++++++++- pipe.nix | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 pipe.nix diff --git a/flake.lock b/flake.lock index f436b430..a938f817 100644 --- a/flake.lock +++ b/flake.lock @@ -302,6 +302,21 @@ "type": "github" } }, + "haskell-nix-weeder": { + "flake": false, + "locked": { + "lastModified": 1592887493, + "narHash": "sha256-gKZh2jrn8b9VC23ZXWfd6wOgXG+pHeTKDLJ/uHaztN4=", + "owner": "serokell", + "repo": "haskell-nix-weeder", + "rev": "a959fce7499df473e13336959cba77fbc87f3b7f", + "type": "github" + }, + "original": { + "id": "haskell-nix-weeder", + "type": "indirect" + } + }, "hpc-coveralls": { "flake": false, "locked": { @@ -602,6 +617,7 @@ "flake-compat": "flake-compat_2", "flake-utils": "flake-utils", "haskell-nix": "haskell-nix", + "haskell-nix-weeder": "haskell-nix-weeder", "nixpkgs": "nixpkgs_3", "serokell-nix": "serokell-nix" } diff --git a/flake.nix b/flake.nix index 7169a69a..f3eda731 100644 --- a/flake.nix +++ b/flake.nix @@ -11,13 +11,15 @@ # Remove once registry-pinned haskell.nix is repinned haskell-nix.url = "github:input-output-hk/haskell.nix"; + haskell-nix-weeder.flake = false; + flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; }; - outputs = { self, nixpkgs, haskell-nix, flake-utils, common-infra, serokell-nix, ... }: + outputs = { self, nixpkgs, haskell-nix, flake-utils, common-infra, serokell-nix, haskell-nix-weeder, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: let src = pkgs.haskell-nix.haskellLib.cleanGit { @@ -30,6 +32,13 @@ overlays = [ haskell-nix.overlay serokell-nix.overlay ]; }; + weeder-hacks = import haskell-nix-weeder { inherit pkgs; }; + weeder-legacy = pkgs.haskellPackages.callHackageDirect { + pkg = "weeder"; + ver = "1.0.9"; + sha256 = "0gfvhw7n8g2274k74g8gnv1y19alr1yig618capiyaix6i9wnmpa"; + } {}; + project = pkgs.haskell-nix.stackProject { inherit src; @@ -37,6 +46,8 @@ packages.coffer = { # strip executable to reduce closure size dontStrip = false; + package.ghcOptions = "-ddump-to-file -ddump-hi"; + postInstall = weeder-hacks.collect-dump-hi-files; }; }]; }; @@ -46,6 +57,7 @@ { packages = { coffer = coffer.components.exes.coffer; + nix = pkgs.nixUnstable; }; checks = { @@ -54,6 +66,17 @@ hlint = pkgs.build.haskell.hlint src; + weeder = let + script = weeder-hacks.weeder-script { + weeder = weeder-legacy; + hs-pkgs = project; + local-packages = [{ + name = "coffer"; + subdirectory = "."; + }]; + }; + in pkgs.build.runCheck script; + tests = coffer.components.tests.test; doctests = coffer.components.tests.doctests; lib = coffer.components.library; @@ -72,7 +95,7 @@ ]; }; }) // { - pipelineFile = common-infra.mkPipelineFile (self // { + pipelineFile = (import ./pipe.nix inputs).mkPipelineFile (self // { # Remove once https://github.com/serokell/common-infra/issues/4 is fixed deployFromPipeline = []; }); diff --git a/pipe.nix b/pipe.nix new file mode 100644 index 00000000..09b9b0e9 --- /dev/null +++ b/pipe.nix @@ -0,0 +1,113 @@ +inputs: +rec { + mkPipeline = { deploy ? { nodes = { }; }, packages ? { }, checks ? { }, deployFromPipeline ? { }, agents ? [ ] + , systems ? [ "x86_64-linux" ], ciSystem ? "x86_64-linux", ... }@args: + let + pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; + inherit (pkgs) lib; + inherit (lib) + getAttrFromPath collect concatStringsSep mapAttrsRecursiveCond + optionalAttrs optionalString concatMapStringsSep splitString last head + optional optionals escapeShellArg; + inherit (builtins) + concatMap length filter elemAt listToAttrs unsafeDiscardStringContext; + + escapeAttrPath = path: escapeShellArg ''"${concatStringsSep ''"."'' path}"''; + + nixBinPath = optionalString (packages ? ${ciSystem}.nix) "${packages.${ciSystem}.nix}/bin/"; + + namesTree = + mapAttrsRecursiveCond (x: !(lib.isDerivation x)) (path: _: path); + names = attrs: collect lib.isList (namesTree attrs); + + filterNative = what: + listToAttrs (concatMap (system: + optional (args.${what} ? ${system}) { + name = system; + value = args.${what}.${system}; + }) systems); + + buildable = { + inherit deploy; + packages = filterNative "packages"; + }; + + packageNames = filter (x: last x == "path" || head x == "packages") + (names buildable); + + pathByValue = listToAttrs (map (path: { + name = + unsafeDiscardStringContext (getAttrFromPath path buildable).drvPath; + value = path; + }) packageNames); + + drvFromPath = path: getAttrFromPath path buildable; + + build = comp: + let + drv = drvFromPath comp; + hasArtifacts = drv ? meta && drv.meta ? artifacts; + displayName = if head comp == "packages" then + elemAt comp 2 + else + "${elemAt comp 2}.${elemAt comp 4}"; + in { + label = "Build ${displayName}"; + command = "${nixBinPath}nix build .#${escapeAttrPath comp}"; + inherit agents; + } // optionalAttrs hasArtifacts { + artifact_paths = map (art: "result${art}") drv.meta.artifacts; + }; + + buildSteps = map build (builtins.attrValues pathByValue); + + checkNames = names { checks = filterNative "checks"; }; + + check = name: { + label = elemAt name 2; + command = "${nixBinPath}nix build --no-link .#${escapeAttrPath name}"; + inherit agents; + }; + + checkSteps = map check checkNames; + + doDeploy = { branch, node ? branch, profile, user ? "deploy", ... }: { + label = "Deploy ${branch} ${profile}"; + branches = [ branch ]; + command = + "${ + inputs.deploy.defaultApp.${head systems}.program + } ${lib.escapeShellArg ''.#"${node}"."${profile}"''} --ssh-user ${lib.escapeShellArg user} --fast-connection true"; + inherit agents; + }; + + deploySteps = [ "wait" ] ++ map doDeploy deployFromPipeline; + + doRelease = { + label = "Release"; + branches = args.releaseBranches or [ "master" ]; + command = pkgs.writeShellScript "release" '' + set -euo pipefail + export PATH='${inputs.nixpkgs.legacyPackages.${ciSystem}.github-cli}/bin':"$PATH" + nix build .#'release.${ciSystem}' + timestamp=$(git show -s --format=%ci) + date=$(cut -d\ -f1 <<< $timestamp) + time=$(cut -d\ -f2 <<< $timestamp | sed s/:/-/g) + gh release create "$date"T"$time" -d -t "Automatic release on $date" -F result/notes.md ./result/* + sleep 1 + # Clean up old draft releases + for draft_tag in $(gh release list -L 1000 | grep Draft | tail +${toString ((args.keepReleaseDrafts or 1) + 1)} | cut -f3); do + gh release delete -y "$draft_tag" + done + ''; + }; + + releaseSteps = optionals (args ? release) [ "wait" doRelease ]; + + steps = buildSteps ++ checkSteps ++ releaseSteps ++ deploySteps; + in { inherit steps; }; + + mkPipelineFile = { systems ? [ "x86_64-linux" ], ... }@flake: + inputs.nixpkgs.legacyPackages.${builtins.head systems}.writeText "pipeline.yml" + (builtins.toJSON (mkPipeline flake)); +} From 37dfd39007ff08e8aa339edac3557b573df2a456 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 2 May 2022 20:41:58 -0700 Subject: [PATCH 05/26] add reuse license headers --- default.nix | 4 ++++ flake.nix | 1 + pipe.nix | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/default.nix b/default.nix index 873ece49..410c13b3 100644 --- a/default.nix +++ b/default.nix @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2022 Serokell +# +# SPDX-License-Identifier: MPL-2.0 + (import ( let diff --git a/flake.nix b/flake.nix index f3eda731..81b0adf3 100644 --- a/flake.nix +++ b/flake.nix @@ -92,6 +92,7 @@ ]; buildInputs = with pkgs; [ zlib + reuse ]; }; }) // { diff --git a/pipe.nix b/pipe.nix index 09b9b0e9..9c30e878 100644 --- a/pipe.nix +++ b/pipe.nix @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2022 Serokell +# +# SPDX-License-Identifier: MPL-2.0 + inputs: rec { mkPipeline = { deploy ? { nodes = { }; }, packages ? { }, checks ? { }, deployFromPipeline ? { }, agents ? [ ] From f2df9409043bec51d7fa765e533c3782069f1506 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 2 May 2022 20:44:12 -0700 Subject: [PATCH 06/26] fix ghcOptions --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 81b0adf3..65f19578 100644 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,7 @@ packages.coffer = { # strip executable to reduce closure size dontStrip = false; - package.ghcOptions = "-ddump-to-file -ddump-hi"; + ghcOptions = "-ddump-to-file -ddump-hi"; postInstall = weeder-hacks.collect-dump-hi-files; }; }]; From 00a5f125c99c26cc14bfbc8a064d7abbe3bd0c4f Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 2 May 2022 20:45:07 -0700 Subject: [PATCH 07/26] fix ghcOptions --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 65f19578..bd07f540 100644 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,7 @@ packages.coffer = { # strip executable to reduce closure size dontStrip = false; - ghcOptions = "-ddump-to-file -ddump-hi"; + ghcOptions = ["-ddump-to-file" "-ddump-hi"]; postInstall = weeder-hacks.collect-dump-hi-files; }; }]; From 1ee99e17eec5048073ff37b9e547a5d499a4c829 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 2 May 2022 20:52:53 -0700 Subject: [PATCH 08/26] instantiate haskell.nix project differently in tests and package --- flake.nix | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/flake.nix b/flake.nix index bd07f540..eec6880d 100644 --- a/flake.nix +++ b/flake.nix @@ -32,6 +32,8 @@ overlays = [ haskell-nix.overlay serokell-nix.overlay ]; }; + inherit (pkgs) lib; + weeder-hacks = import haskell-nix-weeder { inherit pkgs; }; weeder-legacy = pkgs.haskellPackages.callHackageDirect { pkg = "weeder"; @@ -39,28 +41,29 @@ sha256 = "0gfvhw7n8g2274k74g8gnv1y19alr1yig618capiyaix6i9wnmpa"; } {}; - project = pkgs.haskell-nix.stackProject { + mkProject = release: pkgs.haskell-nix.stackProject { inherit src; modules = [{ packages.coffer = { # strip executable to reduce closure size - dontStrip = false; - ghcOptions = ["-ddump-to-file" "-ddump-hi"]; - postInstall = weeder-hacks.collect-dump-hi-files; + dontStrip = !release; + doHaddock = !release; + ghcOptions = lib.optionals (!release) ["-ddump-to-file" "-ddump-hi"]; + postInstall = if release then null else weeder-hacks.collect-dump-hi-files; }; }]; }; - - inherit (project) coffer; in { packages = { - coffer = coffer.components.exes.coffer; + coffer = (mkProject true).coffer.components.exes.coffer; nix = pkgs.nixUnstable; }; - checks = { + checks = let + project = mkProject false; + in { reuse = pkgs.build.reuseLint src; trailingWhitespace = pkgs.build.checkTrailingWhitespace src; @@ -77,10 +80,10 @@ }; in pkgs.build.runCheck script; - tests = coffer.components.tests.test; - doctests = coffer.components.tests.doctests; - lib = coffer.components.library; - haddock = coffer.components.library.haddock; + tests = project.coffer.components.tests.test; + doctests = project.coffer.components.tests.doctests; + lib = project.coffer.components.library; + haddock = project.coffer.components.library.haddock; }; devShell = pkgs.mkShell { From fddc10fb1f3ab5617d618a9dc82cb9e0d40c5f48 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 2 May 2022 21:07:03 -0700 Subject: [PATCH 09/26] add app and set defaultPackage and defaultApp --- flake.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flake.nix b/flake.nix index eec6880d..7e048ac4 100644 --- a/flake.nix +++ b/flake.nix @@ -56,11 +56,18 @@ }; in { + defaultPackage = self.packages."${system}".coffer; packages = { coffer = (mkProject true).coffer.components.exes.coffer; nix = pkgs.nixUnstable; }; + defaultApp = self.apps."${system}".coffer; + apps.coffer = { + type = "app"; + program = "${self.defaultPackage."${system}"}/bin/coffer"; + }; + checks = let project = mkProject false; in { From 375f532f03ef12c66c1a3622e30524f9729d2960 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 3 May 2022 15:00:26 -0700 Subject: [PATCH 10/26] fix hlint, test, and doctests, add shellcheck --- flake.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 7e048ac4..887cc02d 100644 --- a/flake.nix +++ b/flake.nix @@ -74,7 +74,8 @@ reuse = pkgs.build.reuseLint src; trailingWhitespace = pkgs.build.checkTrailingWhitespace src; - hlint = pkgs.build.haskell.hlint src; + hlint = pkgs.build.runCheck "${pkgs.haskellPackages.hlint}/bin/hlint"; + shellcheck = pkgs.build.runCheck "find . -name '*.sh' -exec ${pkgs.shellcheck}/bin/shellcheck {} +"; weeder = let script = weeder-hacks.weeder-script { @@ -87,8 +88,8 @@ }; in pkgs.build.runCheck script; - tests = project.coffer.components.tests.test; - doctests = project.coffer.components.tests.doctests; + test = pkgs.build.runCheck "${project.coffer.components.tests.test}/bin/test"; + doctests = pkgs.build.runCheck "${project.coffer.components.tests.doctests}/bin/doctests"; lib = project.coffer.components.library; haddock = project.coffer.components.library.haddock; }; @@ -103,6 +104,8 @@ buildInputs = with pkgs; [ zlib reuse + haskellPackages.hlint + shellcheck ]; }; }) // { From 3df9cf39676a3273e381e9d86d8d17fc35b498a5 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 3 May 2022 15:08:40 -0700 Subject: [PATCH 11/26] use src in checks that need it --- flake.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 887cc02d..2790a891 100644 --- a/flake.nix +++ b/flake.nix @@ -74,8 +74,8 @@ reuse = pkgs.build.reuseLint src; trailingWhitespace = pkgs.build.checkTrailingWhitespace src; - hlint = pkgs.build.runCheck "${pkgs.haskellPackages.hlint}/bin/hlint"; - shellcheck = pkgs.build.runCheck "find . -name '*.sh' -exec ${pkgs.shellcheck}/bin/shellcheck {} +"; + hlint = pkgs.build.runCheck "cd ${src} && ${pkgs.haskellPackages.hlint}/bin/hlint"; + shellcheck = pkgs.build.runCheck "find ${src} -name '*.sh' -exec ${pkgs.shellcheck}/bin/shellcheck {} +"; weeder = let script = weeder-hacks.weeder-script { @@ -88,8 +88,8 @@ }; in pkgs.build.runCheck script; - test = pkgs.build.runCheck "${project.coffer.components.tests.test}/bin/test"; - doctests = pkgs.build.runCheck "${project.coffer.components.tests.doctests}/bin/doctests"; + test = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.test}/bin/test"; + doctests = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.doctests}/bin/doctests"; lib = project.coffer.components.library; haddock = project.coffer.components.library.haddock; }; From dc5bfcb85289022cfeb256418c29d6b4b0f4a589 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Fri, 6 May 2022 17:46:16 -0700 Subject: [PATCH 12/26] use mkPipelineFile from serokell-nix --- flake.lock | 81 +++++++++++++++++++++++++++++++++---- flake.nix | 5 +-- pipe.nix | 117 ----------------------------------------------------- 3 files changed, 75 insertions(+), 128 deletions(-) delete mode 100644 pipe.nix diff --git a/flake.lock b/flake.lock index a938f817..7b407aac 100644 --- a/flake.lock +++ b/flake.lock @@ -124,6 +124,25 @@ "type": "github" } }, + "deploy-rs": { + "inputs": { + "flake-compat": "flake-compat_3", + "nixpkgs": "nixpkgs_4", + "utils": "utils_2" + }, + "locked": { + "lastModified": 1648475189, + "narHash": "sha256-gAGAS6IagwoUr1B0ohE3iR6sZ8hP4LSqzYLC8Mq3WGU=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "83e0c78291cd08cb827ba0d553ad9158ae5a95c3", + "type": "github" + }, + "original": { + "id": "deploy-rs", + "type": "indirect" + } + }, "flake-compat": { "flake": false, "locked": { @@ -157,6 +176,22 @@ } }, "flake-compat_3": { + "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_4": { "flake": false, "locked": { "lastModified": 1627913399, @@ -428,7 +463,7 @@ "nix_2": { "inputs": { "lowdown-src": "lowdown-src_2", - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_5" }, "locked": { "lastModified": 1633098935, @@ -566,6 +601,22 @@ } }, "nixpkgs_4": { + "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_5": { "locked": { "lastModified": 1632864508, "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", @@ -580,7 +631,7 @@ "type": "indirect" } }, - "nixpkgs_5": { + "nixpkgs_6": { "locked": { "lastModified": 1632495107, "narHash": "sha256-4NGE56r+FJGBaCYu3CTH4O83Ys4TrtnEPXrvdwg1TDs=", @@ -624,18 +675,19 @@ }, "serokell-nix": { "inputs": { - "flake-compat": "flake-compat_3", + "deploy-rs": "deploy-rs", + "flake-compat": "flake-compat_4", "flake-utils": "flake-utils_3", "gitignore-nix": "gitignore-nix", "nix": "nix_2", - "nixpkgs": "nixpkgs_5" + "nixpkgs": "nixpkgs_6" }, "locked": { - "lastModified": 1651500391, - "narHash": "sha256-3MpLm+4hDffPuKZG9y0eSXnogSlyxbpKNg0PbuhOgGE=", + "lastModified": 1651884062, + "narHash": "sha256-gr3BGy0yJL4Qx2NdbzEUAI3+Hi558AAVUAczaz6423w=", "owner": "serokell", "repo": "serokell.nix", - "rev": "704c973ea31084ecdf76154928eda3c730458fc2", + "rev": "3d533eb5b37142d6a3a8dea5ea3c159ad6595eb7", "type": "github" }, "original": { @@ -673,6 +725,21 @@ "repo": "flake-utils", "type": "github" } + }, + "utils_2": { + "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" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 2790a891..1a318255 100644 --- a/flake.nix +++ b/flake.nix @@ -109,9 +109,6 @@ ]; }; }) // { - pipelineFile = (import ./pipe.nix inputs).mkPipelineFile (self // { - # Remove once https://github.com/serokell/common-infra/issues/4 is fixed - deployFromPipeline = []; - }); + pipelineFile = serokell-nix.lib.pipeline.mkPipelineFile self; }; } diff --git a/pipe.nix b/pipe.nix deleted file mode 100644 index 9c30e878..00000000 --- a/pipe.nix +++ /dev/null @@ -1,117 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Serokell -# -# SPDX-License-Identifier: MPL-2.0 - -inputs: -rec { - mkPipeline = { deploy ? { nodes = { }; }, packages ? { }, checks ? { }, deployFromPipeline ? { }, agents ? [ ] - , systems ? [ "x86_64-linux" ], ciSystem ? "x86_64-linux", ... }@args: - let - pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; - inherit (pkgs) lib; - inherit (lib) - getAttrFromPath collect concatStringsSep mapAttrsRecursiveCond - optionalAttrs optionalString concatMapStringsSep splitString last head - optional optionals escapeShellArg; - inherit (builtins) - concatMap length filter elemAt listToAttrs unsafeDiscardStringContext; - - escapeAttrPath = path: escapeShellArg ''"${concatStringsSep ''"."'' path}"''; - - nixBinPath = optionalString (packages ? ${ciSystem}.nix) "${packages.${ciSystem}.nix}/bin/"; - - namesTree = - mapAttrsRecursiveCond (x: !(lib.isDerivation x)) (path: _: path); - names = attrs: collect lib.isList (namesTree attrs); - - filterNative = what: - listToAttrs (concatMap (system: - optional (args.${what} ? ${system}) { - name = system; - value = args.${what}.${system}; - }) systems); - - buildable = { - inherit deploy; - packages = filterNative "packages"; - }; - - packageNames = filter (x: last x == "path" || head x == "packages") - (names buildable); - - pathByValue = listToAttrs (map (path: { - name = - unsafeDiscardStringContext (getAttrFromPath path buildable).drvPath; - value = path; - }) packageNames); - - drvFromPath = path: getAttrFromPath path buildable; - - build = comp: - let - drv = drvFromPath comp; - hasArtifacts = drv ? meta && drv.meta ? artifacts; - displayName = if head comp == "packages" then - elemAt comp 2 - else - "${elemAt comp 2}.${elemAt comp 4}"; - in { - label = "Build ${displayName}"; - command = "${nixBinPath}nix build .#${escapeAttrPath comp}"; - inherit agents; - } // optionalAttrs hasArtifacts { - artifact_paths = map (art: "result${art}") drv.meta.artifacts; - }; - - buildSteps = map build (builtins.attrValues pathByValue); - - checkNames = names { checks = filterNative "checks"; }; - - check = name: { - label = elemAt name 2; - command = "${nixBinPath}nix build --no-link .#${escapeAttrPath name}"; - inherit agents; - }; - - checkSteps = map check checkNames; - - doDeploy = { branch, node ? branch, profile, user ? "deploy", ... }: { - label = "Deploy ${branch} ${profile}"; - branches = [ branch ]; - command = - "${ - inputs.deploy.defaultApp.${head systems}.program - } ${lib.escapeShellArg ''.#"${node}"."${profile}"''} --ssh-user ${lib.escapeShellArg user} --fast-connection true"; - inherit agents; - }; - - deploySteps = [ "wait" ] ++ map doDeploy deployFromPipeline; - - doRelease = { - label = "Release"; - branches = args.releaseBranches or [ "master" ]; - command = pkgs.writeShellScript "release" '' - set -euo pipefail - export PATH='${inputs.nixpkgs.legacyPackages.${ciSystem}.github-cli}/bin':"$PATH" - nix build .#'release.${ciSystem}' - timestamp=$(git show -s --format=%ci) - date=$(cut -d\ -f1 <<< $timestamp) - time=$(cut -d\ -f2 <<< $timestamp | sed s/:/-/g) - gh release create "$date"T"$time" -d -t "Automatic release on $date" -F result/notes.md ./result/* - sleep 1 - # Clean up old draft releases - for draft_tag in $(gh release list -L 1000 | grep Draft | tail +${toString ((args.keepReleaseDrafts or 1) + 1)} | cut -f3); do - gh release delete -y "$draft_tag" - done - ''; - }; - - releaseSteps = optionals (args ? release) [ "wait" doRelease ]; - - steps = buildSteps ++ checkSteps ++ releaseSteps ++ deploySteps; - in { inherit steps; }; - - mkPipelineFile = { systems ? [ "x86_64-linux" ], ... }@flake: - inputs.nixpkgs.legacyPackages.${builtins.head systems}.writeText "pipeline.yml" - (builtins.toJSON (mkPipeline flake)); -} From 0a4667215820fe710f5075bf101da344f78f0163 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Fri, 6 May 2022 19:53:37 -0700 Subject: [PATCH 13/26] add stylish check, add coffer-static build --- flake.nix | 44 ++++++++++++++++++++++++++++++------- scripts/validate-stylish.sh | 30 ------------------------- 2 files changed, 36 insertions(+), 38 deletions(-) delete mode 100755 scripts/validate-stylish.sh diff --git a/flake.nix b/flake.nix index 1a318255..34011671 100644 --- a/flake.nix +++ b/flake.nix @@ -22,17 +22,18 @@ outputs = { self, nixpkgs, haskell-nix, flake-utils, common-infra, serokell-nix, haskell-nix-weeder, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: let - src = pkgs.haskell-nix.haskellLib.cleanGit { - name = "coffer"; - src = ./.; - }; + inherit (nixpkgs) lib; + pkgs' = pkgs; pkgs = import nixpkgs { inherit system; overlays = [ haskell-nix.overlay serokell-nix.overlay ]; }; - inherit (pkgs) lib; + src = pkgs.haskell-nix.haskellLib.cleanGit { + name = "coffer"; + src = ./.; + }; weeder-hacks = import haskell-nix-weeder { inherit pkgs; }; weeder-legacy = pkgs.haskellPackages.callHackageDirect { @@ -41,7 +42,7 @@ sha256 = "0gfvhw7n8g2274k74g8gnv1y19alr1yig618capiyaix6i9wnmpa"; } {}; - mkProject = release: pkgs.haskell-nix.stackProject { + mkProject = { release ? false, pkgs ? pkgs' }: pkgs'.haskell-nix.stackProject { inherit src; modules = [{ @@ -58,7 +59,10 @@ { defaultPackage = self.packages."${system}".coffer; packages = { - coffer = (mkProject true).coffer.components.exes.coffer; + coffer = (mkProject { release = true; }).coffer.components.exes.coffer; + coffer-static = (mkProject { release = true; pkgs = pkgs.pkgsCross.musl64; }).coffer.components.exes.coffer // { + meta.artifacts = [ "/bin/coffer" ]; + }; nix = pkgs.nixUnstable; }; @@ -69,11 +73,35 @@ }; checks = let - project = mkProject false; + project = mkProject { release = false; }; in { reuse = pkgs.build.reuseLint src; trailingWhitespace = pkgs.build.checkTrailingWhitespace src; + stylish = pkgs.runCommand "stylish-check" { + buildInputs = with pkgs; [ git gnumake stylish-haskell ]; + } '' + mkdir src && cd src + cp -a --no-preserve=mode,ownership ${src}/. . + + make stylish + + set +e + diff=$(diff -q ${src} .) + exitCode=$? + set -e + + if [ "$exitCode" != 0 ]; then + echo "Found files that do not adhere to stylish-haskell." + echo "Run 'make stylish' on the repository to fix this." + echo "" + echo "Offending files:" + echo "$diff" + exit 1 + fi + + touch $out + ''; hlint = pkgs.build.runCheck "cd ${src} && ${pkgs.haskellPackages.hlint}/bin/hlint"; shellcheck = pkgs.build.runCheck "find ${src} -name '*.sh' -exec ${pkgs.shellcheck}/bin/shellcheck {} +"; diff --git a/scripts/validate-stylish.sh b/scripts/validate-stylish.sh deleted file mode 100755 index b2e85f59..00000000 --- a/scripts/validate-stylish.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -# SPDX-FileCopyrightText: 2022 Serokell -# -# SPDX-License-Identifier: MPL-2.0 - -# This script verifies that the repo adheres to the stylish-haskell rules. -# -# It does this by running `make stylish` on the repo and checking -# that no files were affected. - -set -euo pipefail - -make stylish - -# Note: we temporarily disable `-e`; -# otherwise the script would exit when `git diff` returns 1. -set +e -diff=$(git diff --exit-code --name-only) -exitCode=$? -set -e - -if [ "$exitCode" != 0 ]; then - echo "Found files that do not adhere to stylish-haskell." - echo "Run 'make stylish' on the repository to fix this." - echo "" - echo "Offending files:" - echo "$diff" - exit 1 -fi From 36b44cdf2943ff3de834c72f0bc24a1b2030edc4 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Fri, 6 May 2022 20:04:10 -0700 Subject: [PATCH 14/26] fix typo in pkgs selection for allowing static builds --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 34011671..503504c9 100644 --- a/flake.nix +++ b/flake.nix @@ -42,7 +42,7 @@ sha256 = "0gfvhw7n8g2274k74g8gnv1y19alr1yig618capiyaix6i9wnmpa"; } {}; - mkProject = { release ? false, pkgs ? pkgs' }: pkgs'.haskell-nix.stackProject { + mkProject = { release ? false, pkgs ? pkgs' }: pkgs.haskell-nix.stackProject { inherit src; modules = [{ From 9c6e97011430e1d3753d5f8bae1996335891f03e Mon Sep 17 00:00:00 2001 From: notgne2 Date: Fri, 6 May 2022 20:17:05 -0700 Subject: [PATCH 15/26] only build musl64 package for 64bit linux --- flake.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 503504c9..0bff3087 100644 --- a/flake.nix +++ b/flake.nix @@ -58,13 +58,12 @@ in { defaultPackage = self.packages."${system}".coffer; - packages = { + packages = ({ coffer = (mkProject { release = true; }).coffer.components.exes.coffer; - coffer-static = (mkProject { release = true; pkgs = pkgs.pkgsCross.musl64; }).coffer.components.exes.coffer // { - meta.artifacts = [ "/bin/coffer" ]; - }; nix = pkgs.nixUnstable; - }; + } // (if system == "x86_64-linux" then { + coffer-static = (mkProject { release = true; pkgs = pkgs.pkgsCross.musl64; }).coffer.components.exes.coffer // { meta.artifacts = [ "/bin/coffer" ]; }; + } else {})); defaultApp = self.apps."${system}".coffer; apps.coffer = { From a181ffb7f523c96ba9905b958d7e5fc517cbaab6 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Fri, 6 May 2022 20:41:11 -0700 Subject: [PATCH 16/26] add golden tests --- flake.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 0bff3087..2c6d6e3c 100644 --- a/flake.nix +++ b/flake.nix @@ -32,7 +32,10 @@ src = pkgs.haskell-nix.haskellLib.cleanGit { name = "coffer"; - src = ./.; + src = pkgs.haskell-nix.haskellLib.cleanSourceWith { + filter = path: type: !(pkgs.lib.hasInfix "tests/golden/helpers" path); + src = ./.; + }; }; weeder-hacks = import haskell-nix-weeder { inherit pkgs; }; @@ -77,6 +80,15 @@ reuse = pkgs.build.reuseLint src; trailingWhitespace = pkgs.build.checkTrailingWhitespace src; + + golden-tests = pkgs.runCommand "golden-tests" { + buildInputs = with pkgs; [ vault bats ]; + } '' + cd ${./.} + bash ./scripts/run-bats-tests.sh + touch $out + ''; + stylish = pkgs.runCommand "stylish-check" { buildInputs = with pkgs; [ git gnumake stylish-haskell ]; } '' From 8e71a2b4e1904b933cc89c80b28d911065019161 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Fri, 3 Jun 2022 16:06:28 -0700 Subject: [PATCH 17/26] Fix weeder script --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 2c6d6e3c..a5ef860e 100644 --- a/flake.nix +++ b/flake.nix @@ -53,7 +53,7 @@ # strip executable to reduce closure size dontStrip = !release; doHaddock = !release; - ghcOptions = lib.optionals (!release) ["-ddump-to-file" "-ddump-hi"]; + ghcOptions = lib.optionals (!release) [ "-O0" "-ddump-to-file" "-ddump-hi" ]; postInstall = if release then null else weeder-hacks.collect-dump-hi-files; }; }]; @@ -125,7 +125,7 @@ subdirectory = "."; }]; }; - in pkgs.build.runCheck script; + in pkgs.build.runCheck "cp -a --no-preserve=mode,ownership ${src}/. . && ${script}"; test = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.test}/bin/test"; doctests = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.doctests}/bin/doctests"; From beb22f4ec5c382ea9a516f8d6b88b4d2f2f98ae5 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Fri, 3 Jun 2022 16:15:21 -0700 Subject: [PATCH 18/26] Temporarily remove doctests --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index a5ef860e..348c6274 100644 --- a/flake.nix +++ b/flake.nix @@ -128,7 +128,7 @@ in pkgs.build.runCheck "cp -a --no-preserve=mode,ownership ${src}/. . && ${script}"; test = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.test}/bin/test"; - doctests = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.doctests}/bin/doctests"; + # doctests = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.doctests}/bin/doctests"; lib = project.coffer.components.library; haddock = project.coffer.components.library.haddock; }; From 5d25fe5014c8b6043fe7047db58f6ccc7c40bf2b Mon Sep 17 00:00:00 2001 From: notgne2 Date: Sun, 5 Jun 2022 22:14:04 -0700 Subject: [PATCH 19/26] Add validate-cabal impure check, use newer `devShells` flake output, specify `validatesWithoutBuild` to avoid flake validation running without builds in updated mkPipeline --- flake.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 348c6274..0bbbb232 100644 --- a/flake.nix +++ b/flake.nix @@ -133,7 +133,21 @@ haddock = project.coffer.components.library.haddock; }; - devShell = pkgs.mkShell { + impureChecks = { + validate-cabal = { + packages = with pkgs; [ + (haskell.lib.overrideCabal haskellPackages.stack2cabal (drv: { + jailbreak = true; + broken = false; + })) + diffutils + ]; + command = "./scripts/validate-cabal-files.sh"; + }; + }; + + devShell = self.devShells.${system}.default; + devShells.default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ ghc cabal-install @@ -149,5 +163,6 @@ }; }) // { pipelineFile = serokell-nix.lib.pipeline.mkPipelineFile self; + validatesWithoutBuild = false; }; } From bf842884b51b4c8e4c71ac8999d25907a54719bd Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 7 Jun 2022 06:45:50 -0700 Subject: [PATCH 20/26] change impure check implementation, add xrefcheck check --- flake.lock | 19 ++++++++++++++++++- flake.nix | 20 +++++++++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 7b407aac..faa111c0 100644 --- a/flake.lock +++ b/flake.lock @@ -670,7 +670,8 @@ "haskell-nix": "haskell-nix", "haskell-nix-weeder": "haskell-nix-weeder", "nixpkgs": "nixpkgs_3", - "serokell-nix": "serokell-nix" + "serokell-nix": "serokell-nix", + "xrefcheck": "xrefcheck" } }, "serokell-nix": { @@ -740,6 +741,22 @@ "repo": "flake-utils", "type": "github" } + }, + "xrefcheck": { + "flake": false, + "locked": { + "lastModified": 1636470756, + "narHash": "sha256-GVONa7vl96ML1bdDGlEM7VeHwkc6xY8Ni24+q80cE7o=", + "owner": "serokell", + "repo": "xrefcheck", + "rev": "f69d74e13dc0b4123dfde520f274d13adf0ed423", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "xrefcheck", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 0bbbb232..873aa52c 100644 --- a/flake.nix +++ b/flake.nix @@ -13,13 +13,16 @@ haskell-nix-weeder.flake = false; + xrefcheck.url = "github:serokell/xrefcheck"; + xrefcheck.flake = false; + flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; }; - outputs = { self, nixpkgs, haskell-nix, flake-utils, common-infra, serokell-nix, haskell-nix-weeder, ... }@inputs: + outputs = { self, nixpkgs, haskell-nix, flake-utils, common-infra, serokell-nix, haskell-nix-weeder, xrefcheck, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: let inherit (nixpkgs) lib; @@ -134,16 +137,23 @@ }; impureChecks = { - validate-cabal = { - packages = with pkgs; [ + validate-cabal = let + runtimeInputs = with pkgs; [ (haskell.lib.overrideCabal haskellPackages.stack2cabal (drv: { jailbreak = true; broken = false; })) diffutils ]; - command = "./scripts/validate-cabal-files.sh"; - }; + in pkgs.writeShellScript "validate-cabal" '' + export PATH="${lib.makeBinPath runtimeInputs}:$PATH" + ./scripts/validate-cabal-files.sh + ''; + + xrefcheck = pkgs.writeShellScript "xrefcheck-check" '' + export PATH="${import xrefcheck {}}:$PATH" + xrefcheck --no-progress -m full --ignored tests/golden/helpers + ''; }; devShell = self.devShells.${system}.default; From 9c0bdfa665b552684d2c41dc8bc9fdb8225aeeec Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 7 Jun 2022 06:49:12 -0700 Subject: [PATCH 21/26] Repin serokell-nix against PR to make CI jobs run --- flake.lock | 12 +++++++----- flake.nix | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index faa111c0..92feed69 100644 --- a/flake.lock +++ b/flake.lock @@ -684,16 +684,18 @@ "nixpkgs": "nixpkgs_6" }, "locked": { - "lastModified": 1651884062, - "narHash": "sha256-gr3BGy0yJL4Qx2NdbzEUAI3+Hi558AAVUAczaz6423w=", + "lastModified": 1654609383, + "narHash": "sha256-mwjRQJGXysyNejUdiuPdqOu2D8f+IVfP6WvV/iHn/lc=", "owner": "serokell", "repo": "serokell.nix", - "rev": "3d533eb5b37142d6a3a8dea5ea3c159ad6595eb7", + "rev": "772b156e5bd5cafe7ee54d953cc411014df66655", "type": "github" }, "original": { - "id": "serokell-nix", - "type": "indirect" + "owner": "serokell", + "ref": "notgne2/impure-checks", + "repo": "serokell.nix", + "type": "github" } }, "stackage": { diff --git a/flake.nix b/flake.nix index 873aa52c..ad2a1536 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,8 @@ }; inputs = { + serokell-nix.url = "github:serokell/serokell.nix/notgne2/impure-checks"; + flake-utils.url = "github:numtide/flake-utils"; # Remove once registry-pinned haskell.nix is repinned From 311601559ba91fa5d136f4082c25ca4aadaa5570 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 7 Jun 2022 06:53:38 -0700 Subject: [PATCH 22/26] fix path in xrefcheck check --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ad2a1536..8f6b8b4f 100644 --- a/flake.nix +++ b/flake.nix @@ -153,7 +153,7 @@ ''; xrefcheck = pkgs.writeShellScript "xrefcheck-check" '' - export PATH="${import xrefcheck {}}:$PATH" + export PATH="${import xrefcheck {}}/bin:$PATH" xrefcheck --no-progress -m full --ignored tests/golden/helpers ''; }; From ac3bc48dd499f6d120c6656151de7aadaeea7684 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 7 Jun 2022 07:06:17 -0700 Subject: [PATCH 23/26] add impure Nix flag (due to xrefcheck), bump serokell-nix, edit coffer.cabal to attempt to fix validate-cabal check --- coffer.cabal | 2 +- flake.lock | 6 +++--- flake.nix | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/coffer.cabal b/coffer.cabal index 2cdfa4e3..6a6ecc9c 100644 --- a/coffer.cabal +++ b/coffer.cabal @@ -1,6 +1,6 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4. +-- This file has been generated from package.yaml by hpack version 0.34.6. -- -- see: https://github.com/sol/hpack diff --git a/flake.lock b/flake.lock index 92feed69..b6fa1339 100644 --- a/flake.lock +++ b/flake.lock @@ -684,11 +684,11 @@ "nixpkgs": "nixpkgs_6" }, "locked": { - "lastModified": 1654609383, - "narHash": "sha256-mwjRQJGXysyNejUdiuPdqOu2D8f+IVfP6WvV/iHn/lc=", + "lastModified": 1654610527, + "narHash": "sha256-Hq8ozNIvUQu3RfK/wL8IGryl7r6AhWWSUV4x/UUvnmE=", "owner": "serokell", "repo": "serokell.nix", - "rev": "772b156e5bd5cafe7ee54d953cc411014df66655", + "rev": "0fb92d3bb1d6fe645e84aa3a430ddf675f1eb59e", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 8f6b8b4f..c1d943ae 100644 --- a/flake.nix +++ b/flake.nix @@ -176,5 +176,6 @@ }) // { pipelineFile = serokell-nix.lib.pipeline.mkPipelineFile self; validatesWithoutBuild = false; + nixArgs = [ "--impure" ]; }; } From 4bb258ea40026580bf5047a1f0ae952430e2402d Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 7 Jun 2022 07:16:17 -0700 Subject: [PATCH 24/26] add coffer-server and server-integration to flake --- flake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index c1d943ae..7bb8b899 100644 --- a/flake.nix +++ b/flake.nix @@ -68,6 +68,7 @@ defaultPackage = self.packages."${system}".coffer; packages = ({ coffer = (mkProject { release = true; }).coffer.components.exes.coffer; + coffer-server = (mkProject { release = true; }).coffer.components.exes.coffer-server; nix = pkgs.nixUnstable; } // (if system == "x86_64-linux" then { coffer-static = (mkProject { release = true; pkgs = pkgs.pkgsCross.musl64; }).coffer.components.exes.coffer // { meta.artifacts = [ "/bin/coffer" ]; }; @@ -85,7 +86,6 @@ reuse = pkgs.build.reuseLint src; trailingWhitespace = pkgs.build.checkTrailingWhitespace src; - golden-tests = pkgs.runCommand "golden-tests" { buildInputs = with pkgs; [ vault bats ]; } '' @@ -136,6 +136,8 @@ # doctests = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.doctests}/bin/doctests"; lib = project.coffer.components.library; haddock = project.coffer.components.library.haddock; + + server-integration = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.server-integration}/bin/server-integration"; }; impureChecks = { From f5e7977807134318caa8757ea0e2e67a1bc8b492 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 7 Jun 2022 07:21:09 -0700 Subject: [PATCH 25/26] add vault to PATH of server-integration test --- flake.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 7bb8b899..3ea28799 100644 --- a/flake.nix +++ b/flake.nix @@ -137,7 +137,13 @@ lib = project.coffer.components.library; haddock = project.coffer.components.library.haddock; - server-integration = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.server-integration}/bin/server-integration"; + server-integration = pkgs.runCommand "server-integration" { + buildInputs = with pkgs; [ vault ]; + } '' + cd ${./.} + ${project.coffer.components.tests.server-integration}/bin/server-integration + touch $out + ''; }; impureChecks = { From b67a0affbcb9bcef170f14033a2b9ebbe1640464 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 7 Jun 2022 08:04:08 -0700 Subject: [PATCH 26/26] turn server-integration into impure check --- flake.nix | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/flake.nix b/flake.nix index 3ea28799..cc848adb 100644 --- a/flake.nix +++ b/flake.nix @@ -63,15 +63,19 @@ }; }]; }; + + checkProject = mkProject { release = false; }; + releaseProject = mkProject { release = true; }; + staticProject = mkProject { release = true; pkgs = pkgs.pkgsCross.musl64; }; in { defaultPackage = self.packages."${system}".coffer; packages = ({ - coffer = (mkProject { release = true; }).coffer.components.exes.coffer; - coffer-server = (mkProject { release = true; }).coffer.components.exes.coffer-server; + coffer = releaseProject.coffer.components.exes.coffer; + coffer-server = releaseProject.coffer.components.exes.coffer-server; nix = pkgs.nixUnstable; } // (if system == "x86_64-linux" then { - coffer-static = (mkProject { release = true; pkgs = pkgs.pkgsCross.musl64; }).coffer.components.exes.coffer // { meta.artifacts = [ "/bin/coffer" ]; }; + coffer-static = staticProject.coffer.components.exes.coffer // { meta.artifacts = [ "/bin/coffer" ]; }; } else {})); defaultApp = self.apps."${system}".coffer; @@ -80,9 +84,7 @@ program = "${self.defaultPackage."${system}"}/bin/coffer"; }; - checks = let - project = mkProject { release = false; }; - in { + checks = { reuse = pkgs.build.reuseLint src; trailingWhitespace = pkgs.build.checkTrailingWhitespace src; @@ -124,7 +126,7 @@ weeder = let script = weeder-hacks.weeder-script { weeder = weeder-legacy; - hs-pkgs = project; + hs-pkgs = checkProject; local-packages = [{ name = "coffer"; subdirectory = "."; @@ -132,18 +134,10 @@ }; in pkgs.build.runCheck "cp -a --no-preserve=mode,ownership ${src}/. . && ${script}"; - test = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.test}/bin/test"; - # doctests = pkgs.build.runCheck "cd ${src} && ${project.coffer.components.tests.doctests}/bin/doctests"; - lib = project.coffer.components.library; - haddock = project.coffer.components.library.haddock; - - server-integration = pkgs.runCommand "server-integration" { - buildInputs = with pkgs; [ vault ]; - } '' - cd ${./.} - ${project.coffer.components.tests.server-integration}/bin/server-integration - touch $out - ''; + test = pkgs.build.runCheck "cd ${src} && ${checkProject.coffer.components.tests.test}/bin/test"; + # doctests = pkgs.build.runCheck "cd ${src} && ${checkProject.coffer.components.tests.doctests}/bin/doctests"; + lib = checkProject.coffer.components.library; + haddock = checkProject.coffer.components.library.haddock; }; impureChecks = { @@ -164,6 +158,11 @@ export PATH="${import xrefcheck {}}/bin:$PATH" xrefcheck --no-progress -m full --ignored tests/golden/helpers ''; + + server-integration = pkgs.writeShellScript "server-integration" '' + export PATH="${pkgs.vault}/bin:$PATH" + ${checkProject.coffer.components.tests.server-integration}/bin/server-integration + ''; }; devShell = self.devShells.${system}.default;