From ca7bf79c7dd499b75b93ea9c583385adc3745908 Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Sun, 12 Feb 2023 14:19:45 +0200 Subject: [PATCH] Initial commit --- .gitignore | 3 + CHANGELOG.md | 5 ++ LICENSE | 30 +++++++++ app/Main.hs | 8 +++ default.nix | 19 ++++++ flake.lock | 41 ++++++++++++ flake.nix | 46 ++++++++++++++ image-backup.cabal | 141 ++++++++++++++++++++++++++++++++++++++++++ nix/amazonka-core.nix | 34 ++++++++++ nix/amazonka-s3.nix | 23 +++++++ nix/amazonka-sso.nix | 23 +++++++ nix/amazonka-sts.nix | 23 +++++++ nix/amazonka-test.nix | 26 ++++++++ nix/amazonka.nix | 25 ++++++++ src/MyLib.hs | 4 ++ test/Main.hs | 4 ++ update_amazonka.sh | 10 +++ 17 files changed, 465 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 app/Main.hs create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 image-backup.cabal create mode 100644 nix/amazonka-core.nix create mode 100644 nix/amazonka-s3.nix create mode 100644 nix/amazonka-sso.nix create mode 100644 nix/amazonka-sts.nix create mode 100644 nix/amazonka-test.nix create mode 100644 nix/amazonka.nix create mode 100644 src/MyLib.hs create mode 100644 test/Main.hs create mode 100755 update_amazonka.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2cc8a4f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.direnv +.envrc +dist-newstyle diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..aef68d5 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for image_backup + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..df03a16 --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) 2023, Mats Rauhala + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Mats Rauhala nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..60d904e --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,8 @@ +module Main where + +import qualified MyLib (someFunc) + +main :: IO () +main = do + putStrLn "Hello, Haskell!" + MyLib.someFunc diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..24bcefb --- /dev/null +++ b/default.nix @@ -0,0 +1,19 @@ +{ mkDerivation, amazonka, amazonka-s3, base, bytestring, conduit +, cryptonite, directory, ekg-core, filepath, lib, mtl, servant +, servant-server, sqlite-simple, text +}: +mkDerivation { + pname = "image-backup"; + version = "0.1.0.0"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + amazonka amazonka-s3 base bytestring conduit cryptonite directory + ekg-core filepath mtl servant servant-server sqlite-simple text + ]; + executableHaskellDepends = [ base ]; + testHaskellDepends = [ base ]; + license = lib.licenses.bsd3; + mainProgram = "image-backup"; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0efe5ac --- /dev/null +++ b/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1675940568, + "narHash": "sha256-epG6pOT9V0kS+FUqd7R6/CWkgnZx2DMT5Veqo+y6G3c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6ccc4a59c3f1b56d039d93da52696633e641bc71", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..399152d --- /dev/null +++ b/flake.nix @@ -0,0 +1,46 @@ +{ + description = "A very basic flake"; + + inputs = { + flake-utils = { + url = "github:numtide/flake-utils"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachSystem ["x86_64-linux" "x86_64-darwin"] (system: + let pkgs = nixpkgs.legacyPackages.${system}; + hp = nixpkgs.legacyPackages.${system}.haskellPackages.override (old: { + overrides = pkgs.lib.composeExtensions (old.overrides or (_: _: {})) (f: p: rec { + image-backup = f.callPackage ./. {}; + + # Need to update amazonka... + amazonka-core = f.callPackage nix/amazonka-core.nix {}; + amazonka-s3 = f.callPackage nix/amazonka-s3.nix {}; + amazonka-test = f.callPackage nix/amazonka-test.nix {}; + amazonka = f.callPackage nix/amazonka.nix {}; + amazonka-sso = f.callPackage nix/amazonka-sso.nix {}; + amazonka-sts = f.callPackage nix/amazonka-sts.nix {}; + }); + }); + in { + devShell = hp.shellFor { + packages = h: [h.image-backup]; + withHoogle = false; + buildInputs = with pkgs; [ + cabal-install + hp.hlint + stylish-haskell + ghcid + + sqlite-interactive + + hp.graphmod + + hp.haskell-language-server + ]; + }; + } + ); +} diff --git a/image-backup.cabal b/image-backup.cabal new file mode 100644 index 0000000..9ac10ee --- /dev/null +++ b/image-backup.cabal @@ -0,0 +1,141 @@ +cabal-version: 3.0 +-- The cabal-version field refers to the version of the .cabal specification, +-- and can be different from the cabal-install (the tool) version and the +-- Cabal (the library) version you are using. As such, the Cabal (the library) +-- version used must be equal or greater than the version stated in this field. +-- Starting from the specification version 2.2, the cabal-version field must be +-- the first thing in the cabal file. + +-- Initial package description 'image-backup' generated by +-- 'cabal init'. For further documentation, see: +-- http://haskell.org/cabal/users-guide/ +-- +-- The name of the package. +name: image-backup + +-- The package version. +-- See the Haskell package versioning policy (PVP) for standards +-- guiding when and how versions should be incremented. +-- https://pvp.haskell.org +-- PVP summary: +-+------- breaking API changes +-- | | +----- non-breaking API additions +-- | | | +--- code changes with no API change +version: 0.1.0.0 + +-- A short (one-line) description of the package. +-- synopsis: + +-- A longer description of the package. +-- description: + +-- The license under which the package is released. +license: BSD-3-Clause + +-- The file containing the license text. +license-file: LICENSE + +-- The package author(s). +author: Mats Rauhala + +-- An email address to which users can send suggestions, bug reports, and patches. +maintainer: mats.rauhala@iki.fi + +-- A copyright notice. +-- copyright: +category: Web +build-type: Simple + +-- Extra doc files to be distributed with the package, such as a CHANGELOG or a README. +extra-doc-files: CHANGELOG.md + +-- Extra source files to be distributed with the package, such as examples, or a tutorial module. +-- extra-source-files: + +common warnings + ghc-options: -Wall + +library + -- Import common warning flags. + import: warnings + + -- Modules exported by the library. + exposed-modules: MyLib + + -- Modules included in this library but not exported. + -- other-modules: + + -- LANGUAGE extensions used by modules in this package. + -- other-extensions: + + -- Other library packages from which modules are imported. + build-depends: base ^>=4.16.3.0 + , sqlite-simple + , amazonka + , amazonka-s3 + , ekg-core + , servant + , servant-server + , cryptonite + , conduit + , filepath + , directory + , bytestring + , text + , mtl + + -- Directories containing source files. + hs-source-dirs: src + + -- Base language which the package is written in. + default-language: Haskell2010 + +executable image-backup + -- Import common warning flags. + import: warnings + + -- .hs or .lhs file containing the Main module. + main-is: Main.hs + + -- Modules included in this executable, other than Main. + -- other-modules: + + -- LANGUAGE extensions used by modules in this package. + -- other-extensions: + + -- Other library packages from which modules are imported. + build-depends: + base ^>=4.16.3.0, + image-backup + + -- Directories containing source files. + hs-source-dirs: app + + -- Base language which the package is written in. + default-language: Haskell2010 + +test-suite image-backup-test + -- Import common warning flags. + import: warnings + + -- Base language which the package is written in. + default-language: Haskell2010 + + -- Modules included in this executable, other than Main. + -- other-modules: + + -- LANGUAGE extensions used by modules in this package. + -- other-extensions: + + -- The interface type and version of the test suite. + type: exitcode-stdio-1.0 + + -- Directories containing source files. + hs-source-dirs: test + + -- The entrypoint to the test suite. + main-is: Main.hs + + -- Test dependencies. + build-depends: + base ^>=4.16.3.0, + image-backup diff --git a/nix/amazonka-core.nix b/nix/amazonka-core.nix new file mode 100644 index 0000000..e8b3171 --- /dev/null +++ b/nix/amazonka-core.nix @@ -0,0 +1,34 @@ +{ mkDerivation, aeson, attoparsec, base, bytestring +, case-insensitive, conduit, conduit-extra, containers, cryptonite +, data-ordlist, deepseq, fetchgit, hashable, http-client +, http-conduit, http-types, lens, lib, memory, QuickCheck +, quickcheck-unicode, regex-posix, resourcet, scientific, tasty +, tasty-hunit, tasty-quickcheck, template-haskell, text, time +, transformers, unordered-containers, xml-conduit, xml-types +}: +mkDerivation { + pname = "amazonka-core"; + version = "2.0"; + src = fetchgit { + url = "https://github.com/brendanhay/amazonka.git"; + sha256 = "1wq0wyk6mgrcx3jr6js7s1y80bz8d8sv81p1b4k5wjwf17yv6rk6"; + rev = "f610f8c95e190edf86606c5f86485d198671beb0"; + fetchSubmodules = true; + }; + postUnpack = "sourceRoot+=/lib/amazonka-core; echo source root reset to $sourceRoot"; + libraryHaskellDepends = [ + aeson attoparsec base bytestring case-insensitive conduit + conduit-extra containers cryptonite deepseq hashable http-client + http-conduit http-types lens memory regex-posix resourcet + scientific text time transformers unordered-containers xml-conduit + xml-types + ]; + testHaskellDepends = [ + aeson base bytestring case-insensitive conduit data-ordlist + http-conduit http-types QuickCheck quickcheck-unicode tasty + tasty-hunit tasty-quickcheck template-haskell text time + ]; + homepage = "https://github.com/brendanhay/amazonka"; + description = "Core data types and functionality for Amazonka libraries"; + license = lib.licenses.mpl20; +} diff --git a/nix/amazonka-s3.nix b/nix/amazonka-s3.nix new file mode 100644 index 0000000..aa7139f --- /dev/null +++ b/nix/amazonka-s3.nix @@ -0,0 +1,23 @@ +{ mkDerivation, amazonka-core, amazonka-test, base, bytestring +, case-insensitive, fetchgit, lens, lib, tasty, tasty-hunit, text +, time, unordered-containers +}: +mkDerivation { + pname = "amazonka-s3"; + version = "2.0"; + src = fetchgit { + url = "https://github.com/brendanhay/amazonka.git"; + sha256 = "1wq0wyk6mgrcx3jr6js7s1y80bz8d8sv81p1b4k5wjwf17yv6rk6"; + rev = "f610f8c95e190edf86606c5f86485d198671beb0"; + fetchSubmodules = true; + }; + postUnpack = "sourceRoot+=/lib/services/amazonka-s3; echo source root reset to $sourceRoot"; + libraryHaskellDepends = [ amazonka-core base lens text ]; + testHaskellDepends = [ + amazonka-core amazonka-test base bytestring case-insensitive tasty + tasty-hunit text time unordered-containers + ]; + homepage = "https://github.com/brendanhay/amazonka"; + description = "Amazon Simple Storage Service SDK"; + license = lib.licenses.mpl20; +} diff --git a/nix/amazonka-sso.nix b/nix/amazonka-sso.nix new file mode 100644 index 0000000..80764d7 --- /dev/null +++ b/nix/amazonka-sso.nix @@ -0,0 +1,23 @@ +{ mkDerivation, amazonka-core, amazonka-test, base, bytestring +, case-insensitive, fetchgit, lib, tasty, tasty-hunit, text, time +, unordered-containers +}: +mkDerivation { + pname = "amazonka-sso"; + version = "2.0"; + src = fetchgit { + url = "https://github.com/brendanhay/amazonka.git"; + sha256 = "1wq0wyk6mgrcx3jr6js7s1y80bz8d8sv81p1b4k5wjwf17yv6rk6"; + rev = "f610f8c95e190edf86606c5f86485d198671beb0"; + fetchSubmodules = true; + }; + postUnpack = "sourceRoot+=/lib/services/amazonka-sso; echo source root reset to $sourceRoot"; + libraryHaskellDepends = [ amazonka-core base ]; + testHaskellDepends = [ + amazonka-core amazonka-test base bytestring case-insensitive tasty + tasty-hunit text time unordered-containers + ]; + homepage = "https://github.com/brendanhay/amazonka"; + description = "Amazon Single Sign-On SDK"; + license = lib.licenses.mpl20; +} diff --git a/nix/amazonka-sts.nix b/nix/amazonka-sts.nix new file mode 100644 index 0000000..c45fcfa --- /dev/null +++ b/nix/amazonka-sts.nix @@ -0,0 +1,23 @@ +{ mkDerivation, amazonka-core, amazonka-test, base, bytestring +, case-insensitive, fetchgit, lib, tasty, tasty-hunit, text, time +, unordered-containers +}: +mkDerivation { + pname = "amazonka-sts"; + version = "2.0"; + src = fetchgit { + url = "https://github.com/brendanhay/amazonka.git"; + sha256 = "1wq0wyk6mgrcx3jr6js7s1y80bz8d8sv81p1b4k5wjwf17yv6rk6"; + rev = "f610f8c95e190edf86606c5f86485d198671beb0"; + fetchSubmodules = true; + }; + postUnpack = "sourceRoot+=/lib/services/amazonka-sts; echo source root reset to $sourceRoot"; + libraryHaskellDepends = [ amazonka-core base ]; + testHaskellDepends = [ + amazonka-core amazonka-test base bytestring case-insensitive tasty + tasty-hunit text time unordered-containers + ]; + homepage = "https://github.com/brendanhay/amazonka"; + description = "Amazon Security Token Service SDK"; + license = lib.licenses.mpl20; +} diff --git a/nix/amazonka-test.nix b/nix/amazonka-test.nix new file mode 100644 index 0000000..3581492 --- /dev/null +++ b/nix/amazonka-test.nix @@ -0,0 +1,26 @@ +{ mkDerivation, aeson, amazonka-core, base, bifunctors, bytestring +, case-insensitive, conduit, conduit-extra, fetchgit, groom +, http-client, http-types, lib, process, resourcet, tasty +, tasty-hunit, template-haskell, temporary, text, time +, unordered-containers, yaml +}: +mkDerivation { + pname = "amazonka-test"; + version = "2.0"; + src = fetchgit { + url = "https://github.com/brendanhay/amazonka.git"; + sha256 = "1wq0wyk6mgrcx3jr6js7s1y80bz8d8sv81p1b4k5wjwf17yv6rk6"; + rev = "f610f8c95e190edf86606c5f86485d198671beb0"; + fetchSubmodules = true; + }; + postUnpack = "sourceRoot+=/lib/amazonka-test; echo source root reset to $sourceRoot"; + libraryHaskellDepends = [ + aeson amazonka-core base bifunctors bytestring case-insensitive + conduit conduit-extra groom http-client http-types process + resourcet tasty tasty-hunit template-haskell temporary text time + unordered-containers yaml + ]; + homepage = "https://github.com/brendanhay/amazonka"; + description = "Common functionality for Amazonka library test-suites"; + license = lib.licenses.mpl20; +} diff --git a/nix/amazonka.nix b/nix/amazonka.nix new file mode 100644 index 0000000..1c73404 --- /dev/null +++ b/nix/amazonka.nix @@ -0,0 +1,25 @@ +{ mkDerivation, aeson, amazonka-core, amazonka-sso, amazonka-sts +, base, bytestring, conduit, directory, exceptions, fetchgit +, http-client, http-conduit, http-types, ini, lens, lib, resourcet +, retry, text, time, transformers, unordered-containers, uuid +}: +mkDerivation { + pname = "amazonka"; + version = "2.0"; + src = fetchgit { + url = "https://github.com/brendanhay/amazonka.git"; + sha256 = "1wq0wyk6mgrcx3jr6js7s1y80bz8d8sv81p1b4k5wjwf17yv6rk6"; + rev = "f610f8c95e190edf86606c5f86485d198671beb0"; + fetchSubmodules = true; + }; + postUnpack = "sourceRoot+=/lib/amazonka; echo source root reset to $sourceRoot"; + libraryHaskellDepends = [ + aeson amazonka-core amazonka-sso amazonka-sts base bytestring + conduit directory exceptions http-client http-conduit http-types + ini lens resourcet retry text time transformers + unordered-containers uuid + ]; + homepage = "https://github.com/brendanhay/amazonka"; + description = "Comprehensive Amazon Web Services SDK"; + license = lib.licenses.mpl20; +} diff --git a/src/MyLib.hs b/src/MyLib.hs new file mode 100644 index 0000000..e657c44 --- /dev/null +++ b/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/test/Main.hs b/test/Main.hs new file mode 100644 index 0000000..3e2059e --- /dev/null +++ b/test/Main.hs @@ -0,0 +1,4 @@ +module Main (main) where + +main :: IO () +main = putStrLn "Test suite not yet implemented." diff --git a/update_amazonka.sh b/update_amazonka.sh new file mode 100755 index 0000000..a345fbf --- /dev/null +++ b/update_amazonka.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# +# Update to 2.0 version of amazonka + +projects="lib/amazonka-test lib/amazonka-core lib/services/amazonka-s3 lib/amazonka lib/services/amazonka-sso lib/services/amazonka-sts" + +for project in $projects; do + nix run nixpkgs#cabal2nix -- https://github.com/brendanhay/amazonka.git --subpath $project > nix/$(basename $project).nix +done +