From bf460fb581eba1bdce487c9adf791d03b2351487 Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Thu, 28 Mar 2024 17:30:35 +1100 Subject: [PATCH 1/8] Add nix flake --- .gitignore | 3 ++ cabal.project | 3 +- flake.lock | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 57 ++++++++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index a4ee41a..bc08c14 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ cabal.sandbox.config *.eventlog .stack-work/ cabal.project.local + +# Nix build output +result diff --git a/cabal.project b/cabal.project index e6fdbad..1671440 100644 --- a/cabal.project +++ b/cabal.project @@ -1 +1,2 @@ -packages: . +packages: + . diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ed232b5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,80 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1711568381, + "narHash": "sha256-IvVqTNcbSNh6XgyS4ikBkQio1eMmLvKTl3vAvkVPn+0=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "5dcb739e9cc4e0edf5267de665fa7a905a543baa", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1711562861, + "narHash": "sha256-ETfttWNpw5HSfC8QeGYPXkJZWnj8MPVxIVuCE3nFqKA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "feb8fc72187e5beae47d81fc38541fae89e7eaf8", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1709237383, + "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "haskell-flake": "haskell-flake", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2632afa --- /dev/null +++ b/flake.nix @@ -0,0 +1,57 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + haskell-flake.url = "github:srid/haskell-flake"; + }; + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ inputs.haskell-flake.flakeModule ]; + + perSystem = { self', pkgs, ... }: { + + # Typically, you just want a single project named "default". But + # multiple projects are also possible, each using different GHC version. + haskellProjects.default = { + # The base package set representing a specific GHC version. + # By default, this is pkgs.haskellPackages. + # You may also create your own. See https://zero-to-flakes.com/haskell-flake/package-set + # basePackages = pkgs.haskellPackages; + + # Extra package information. See https://zero-to-flakes.com/haskell-flake/dependency + # + # Note that local packages are automatically included in `packages` + # (defined by `defaults.packages` option). + # + # packages = { + # aeson.source = "1.5.0.0"; # Hackage version override + # shower.source = inputs.shower; + # }; + # settings = { + # aeson = { + # check = false; + # }; + # relude = { + # haddock = false; + # broken = false; + # }; + # }; + + devShell = { + # Enabled by default + enable = true; + + # Programs you want to make available in the shell. + # Default programs can be disabled by setting to 'null' + tools = hp: { fourmolu = hp.fourmolu; ghcid = null; }; + + hlsCheck.enable = true; + }; + }; + + # haskell-flake doesn't set the default package, but you can do it here. + packages.default = self'.packages.amazonka-s3-streaming; + }; + }; +} From c3c03426af6f24948ad9981ccce8388f6626b00a Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Thu, 28 Mar 2024 17:42:54 +1100 Subject: [PATCH 2/8] Remove formolu --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 2632afa..fd05d14 100644 --- a/flake.nix +++ b/flake.nix @@ -44,7 +44,7 @@ # Programs you want to make available in the shell. # Default programs can be disabled by setting to 'null' - tools = hp: { fourmolu = hp.fourmolu; ghcid = null; }; + # tools = hp: { fourmolu = hp.fourmolu; ghcid = null; }; hlsCheck.enable = true; }; From 5765411dd876f36a60aed264745f62fb70e2b998 Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Tue, 2 Apr 2024 15:01:19 +1100 Subject: [PATCH 3/8] Add pre-commit hooks, clean up --- flake.lock | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 17 +++++-- 2 files changed, 139 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index ed232b5..8d013d4 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -18,6 +34,45 @@ "type": "github" } }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "haskell-flake": { "locked": { "lastModified": 1711568381, @@ -67,11 +122,81 @@ "type": "github" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1710695816, + "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "614b4613980a522ba49f0d194531beddbb7220d3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1710765496, + "narHash": "sha256-p7ryWEeQfMwTB6E0wIUd5V2cFTgq+DRRBz2hYGnJZyA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e367f7a1fb93137af22a3908f00b9a35e2d286a7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1711981679, + "narHash": "sha256-pnbHEXJOdGkPrHBdkZLv/a2V09On+V3J4aPE/BfAJC8=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "f3bb95498eaaa49a93bacaf196cdb6cf8e872cdf", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "flake-parts": "flake-parts", "haskell-flake": "haskell-flake", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index fd05d14..50ee9c9 100644 --- a/flake.nix +++ b/flake.nix @@ -3,16 +3,17 @@ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; haskell-flake.url = "github:srid/haskell-flake"; + pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; }; outputs = inputs@{ self, nixpkgs, flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { systems = nixpkgs.lib.systems.flakeExposed; - imports = [ inputs.haskell-flake.flakeModule ]; + imports = [ + inputs.haskell-flake.flakeModule + inputs.pre-commit-hooks.flakeModule + ]; perSystem = { self', pkgs, ... }: { - - # Typically, you just want a single project named "default". But - # multiple projects are also possible, each using different GHC version. haskellProjects.default = { # The base package set representing a specific GHC version. # By default, this is pkgs.haskellPackages. @@ -47,7 +48,15 @@ # tools = hp: { fourmolu = hp.fourmolu; ghcid = null; }; hlsCheck.enable = true; + pre-commit.settings.hooks = { + cabal-fmt.enable = true; + hlint.enable = true; + nixpkgs-fmt.enable = true; + ormolu.enable = true; + }; }; + + }; # haskell-flake doesn't set the default package, but you can do it here. From ee6f36567a49efe56c03b9bde77c9d524f6e4639 Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Tue, 2 Apr 2024 16:08:36 +1100 Subject: [PATCH 4/8] Remove ormolu --- flake.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/flake.nix b/flake.nix index 50ee9c9..f06f480 100644 --- a/flake.nix +++ b/flake.nix @@ -52,7 +52,6 @@ cabal-fmt.enable = true; hlint.enable = true; nixpkgs-fmt.enable = true; - ormolu.enable = true; }; }; From bf9bd5c999bfc469ff1db590ce5541eedb6b8c51 Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Wed, 3 Apr 2024 10:15:04 +1100 Subject: [PATCH 5/8] Fix pre-commit hooks? --- flake.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index f06f480..44de182 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,7 @@ haskell-flake.url = "github:srid/haskell-flake"; pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; }; + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { systems = nixpkgs.lib.systems.flakeExposed; @@ -13,7 +14,7 @@ inputs.pre-commit-hooks.flakeModule ]; - perSystem = { self', pkgs, ... }: { + perSystem = { self', pkgs, config, ... }: { haskellProjects.default = { # The base package set representing a specific GHC version. # By default, this is pkgs.haskellPackages. @@ -40,22 +41,21 @@ # }; devShell = { - # Enabled by default enable = true; + mkShellArgs.shellHook = config.pre-commit.installationScript; # Programs you want to make available in the shell. # Default programs can be disabled by setting to 'null' # tools = hp: { fourmolu = hp.fourmolu; ghcid = null; }; hlsCheck.enable = true; - pre-commit.settings.hooks = { - cabal-fmt.enable = true; - hlint.enable = true; - nixpkgs-fmt.enable = true; - }; }; + }; - + pre-commit.settings.hooks = { + cabal-fmt.enable = true; + hlint.enable = true; + nixpkgs-fmt.enable = true; }; # haskell-flake doesn't set the default package, but you can do it here. From a679845b0d0ce47c12aff386ac717dd3b2c677a2 Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Wed, 3 Apr 2024 10:30:02 +1100 Subject: [PATCH 6/8] Reformat cabal file --- amazonka-s3-streaming.cabal | 122 ++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 55 deletions(-) diff --git a/amazonka-s3-streaming.cabal b/amazonka-s3-streaming.cabal index 86310e1..89c2c4f 100644 --- a/amazonka-s3-streaming.cabal +++ b/amazonka-s3-streaming.cabal @@ -1,71 +1,83 @@ -name: amazonka-s3-streaming -version: 2.0.0.0 -synopsis: Provides conduits to upload data to S3 using the Multipart API -description: Provides a conduit based streaming interface and a concurrent interface to - uploading data to S3 using the Multipart API. Also provides method to upload - files or bytestrings of known size in parallel. Please see README.md. -homepage: https://github.com/Axman6/amazonka-s3-streaming#readme -license: BSD3 -license-file: LICENSE -author: Alex Mason -maintainer: amazonka-s3-streaming@me.axman6.com -copyright: Copyright © 2023 Alex Mason, Copyright © 2016 Commonwealth Scientific and Industrial Research Organisation (CSIRO) -category: Network, AWS, Cloud, Distributed Computing -build-type: Simple -extra-source-files: README.md, Changelog.md -cabal-version: >=1.10 -tested-with: GHC ==9.6.2 || ==9.4.5 || ==9.2.8 || ==9.0.2 || ==8.10.7 +name: amazonka-s3-streaming +version: 2.0.0.0 +synopsis: + Provides conduits to upload data to S3 using the Multipart API +description: + Provides a conduit based streaming interface and a concurrent interface to + uploading data to S3 using the Multipart API. Also provides method to upload + files or bytestrings of known size in parallel. Please see README.md. + +homepage: https://github.com/Axman6/amazonka-s3-streaming#readme +license: BSD3 +license-file: LICENSE +author: Alex Mason +maintainer: amazonka-s3-streaming@me.axman6.com +copyright: + Copyright © 2023 Alex Mason, Copyright © 2016 Commonwealth Scientific and Industrial Research Organisation (CSIRO) + +category: Network, AWS, Cloud, Distributed Computing +build-type: Simple +extra-source-files: + Changelog.md + README.md + +cabal-version: >=1.10 +tested-with: + GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.5 || ==9.6.2 library - hs-source-dirs: src - exposed-modules: Amazonka.S3.StreamingUpload - default-language: Haskell2010 - ghc-options: -Wall - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wcompat - -Widentities - -Wredundant-constraints - -Wpartial-fields - -Wno-unrecognised-pragmas - -Wunused-packages - build-depends: base >= 4.14 && < 5 - , amazonka >= 2.0 && < 2.1 - , amazonka-s3 >= 2.0 && < 2.1 - , conduit >= 1.3 && < 1.4 - , async >= 2 && < 2.3 - , bytestring >= 0.10.8.0 && < 0.13 - , deepseq >= 1.4.4 && < 1.6 - , exceptions >= 0.8.2.1 && < 0.11 - , http-client >= 0.4 && < 0.8 - , http-client-tls >= 0.3 && < 0.4 - , transformers >= 0.5 && < 0.7 - , text >= 1.2.4 && < 1.3 || >= 2.0 && < 2.2 - , resourcet >= 1.2.0 && < 1.4 + hs-source-dirs: src + exposed-modules: Amazonka.S3.StreamingUpload + default-language: Haskell2010 + ghc-options: + -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates + -Wcompat -Widentities -Wredundant-constraints -Wpartial-fields + -Wno-unrecognised-pragmas -Wunused-packages + + build-depends: + amazonka >=2.0 && <2.1 + , amazonka-s3 >=2.0 && <2.1 + , async >=2 && <2.3 + , base >=4.14 && <5 + , bytestring >=0.10.8.0 && <0.13 + , deepseq >=1.4.4 && <1.6 + , conduit >=1.3 && <1.4 + , exceptions >=0.8.2.1 && <0.11 + , http-client >=0.4 && <0.8 + , http-client-tls >=0.3 && <0.4 + , resourcet >=1.2.0 && <1.4 + , text >=1.2.4 && <1.3 || >=2.0 && <2.2 + , transformers >=0.5 && <0.7 flag s3upload-exe - Description: Whether to build the s3upload executable for uploading files using this library. - default: False - manual: True + description: + Whether to build the s3upload executable for uploading files using this library. + + default: False + manual: True source-repository head type: git location: https://github.com/Axman6/amazonka-s3-streaming executable s3upload - main-is: Main.hs - ghc-options: -threaded -rtsopts "-with-rtsopts=-N -qg" + main-is: Main.hs + ghc-options: -threaded -rtsopts "-with-rtsopts=-N -qg" default-language: Haskell2010 + if flag(s3upload-exe) buildable: True + else buildable: False - build-depends: base - , amazonka - , amazonka-s3 - , amazonka-s3-streaming - , conduit-extra - , conduit - , text - , resourcet + + build-depends: + amazonka + , amazonka-s3 + , amazonka-s3-streaming + , base + , conduit + , conduit-extra + , resourcet + , text From 44eb6895cffec6e41ba2aaa1bad8e1fd66f3e611 Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Wed, 3 Apr 2024 10:30:44 +1100 Subject: [PATCH 7/8] Rearrange flake.nix --- flake.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 44de182..00d3b96 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ haskellProjects.default = { # The base package set representing a specific GHC version. # By default, this is pkgs.haskellPackages. - # You may also create your own. See https://zero-to-flakes.com/haskell-flake/package-set + # See https://zero-to-flakes.com/haskell-flake/package-set # basePackages = pkgs.haskellPackages; # Extra package information. See https://zero-to-flakes.com/haskell-flake/dependency @@ -41,14 +41,14 @@ # }; devShell = { - enable = true; - mkShellArgs.shellHook = config.pre-commit.installationScript; + enable = true; - # Programs you want to make available in the shell. - # Default programs can be disabled by setting to 'null' - # tools = hp: { fourmolu = hp.fourmolu; ghcid = null; }; + # Programs you want to make available in the shell. + # Default programs can be disabled by setting to 'null' + # tools = hp: { fourmolu = hp.fourmolu; ghcid = null; }; - hlsCheck.enable = true; + hlsCheck.enable = true; + mkShellArgs.shellHook = config.pre-commit.installationScript; }; }; From 827a9f4962e2a868e07335f85539aea4d190653c Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Wed, 3 Apr 2024 11:10:04 +1100 Subject: [PATCH 8/8] Trivial edit to test cabal hooks --- amazonka-s3-streaming.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amazonka-s3-streaming.cabal b/amazonka-s3-streaming.cabal index 89c2c4f..a0c5693 100644 --- a/amazonka-s3-streaming.cabal +++ b/amazonka-s3-streaming.cabal @@ -41,8 +41,8 @@ library , async >=2 && <2.3 , base >=4.14 && <5 , bytestring >=0.10.8.0 && <0.13 - , deepseq >=1.4.4 && <1.6 , conduit >=1.3 && <1.4 + , deepseq >=1.4.4 && <1.6 , exceptions >=0.8.2.1 && <0.11 , http-client >=0.4 && <0.8 , http-client-tls >=0.3 && <0.4