diff --git a/src/Vger.hs b/app/Vger.hs similarity index 100% rename from src/Vger.hs rename to app/Vger.hs diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a0ada9d --- /dev/null +++ b/flake.lock @@ -0,0 +1,248 @@ +{ + "nodes": { + "easy-hls": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1646146030, + "narHash": "sha256-wkKDVVL2/rUGokxs4kqCE+ZzxljBqYDZvBuQGVGXYJM=", + "owner": "jkachmar", + "repo": "easy-hls-nix", + "rev": "ecb85ab6ba0aab0531fff32786dfc51feea19370", + "type": "github" + }, + "original": { + "owner": "jkachmar", + "repo": "easy-hls-nix", + "type": "github" + } + }, + "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" + } + }, + "hix": { + "inputs": { + "easy-hls": "easy-hls", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2", + "nixpkgs_ghc8107": "nixpkgs_ghc8107", + "nixpkgs_ghc865": "nixpkgs_ghc865", + "nixpkgs_ghc884": "nixpkgs_ghc884", + "nixpkgs_ghc901": "nixpkgs_ghc901", + "nixpkgs_ghc902": "nixpkgs_ghc902", + "nixpkgs_ghc922": "nixpkgs_ghc922", + "nmd": "nmd", + "obelisk": "obelisk", + "thax": "thax" + }, + "locked": { + "lastModified": 1658021306, + "narHash": "sha256-chR2NPBuJgI/aaN5IdH83DabILJQ8AEfjRsDlhkEQiM=", + "owner": "tek", + "repo": "hix", + "rev": "bedd71655b5fe8af681d28f197dff483edfc2f19", + "type": "github" + }, + "original": { + "owner": "tek", + "repo": "hix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1615055905, + "narHash": "sha256-Ig7CXgE5C3mwtTVBl8nSTessa1oMAm6Pm/p+T6iAJD8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f3fc074642a25ef5a1423412f09946149237e338", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1651927509, + "narHash": "sha256-fGVGUdEsriuAL1vkUh29FlOQmEkPRnSfRGImWYaVjos=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2fdb6f2e08e7989b03a2a1aa8538d99e3eeea881", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2fdb6f2e08e7989b03a2a1aa8538d99e3eeea881", + "type": "github" + } + }, + "nixpkgs_ghc8107": { + "locked": { + "lastModified": 1642069818, + "narHash": "sha256-666w6j8wl/bojfgpp0k58/UJ5rbrdYFbI2RFT2BXbSQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "46821ea01c8f54d2a20f5a503809abfc605269d7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "46821ea01c8f54d2a20f5a503809abfc605269d7", + "type": "github" + } + }, + "nixpkgs_ghc865": { + "locked": { + "lastModified": 1602473909, + "narHash": "sha256-tZfZhmjYNX4UrUySEjbosJO7Bj3eiCGnjfX5DkVClQw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "cfed29bfcb28259376713005d176a6f82951014a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "cfed29bfcb28259376713005d176a6f82951014a", + "type": "github" + } + }, + "nixpkgs_ghc884": { + "locked": { + "lastModified": 1616670887, + "narHash": "sha256-wn+l9qJfR5sj5Gq4DheJHAcBDfOs9K2p9seW2f35xzs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c0e881852006b132236cbf0301bd1939bb50867e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c0e881852006b132236cbf0301bd1939bb50867e", + "type": "github" + } + }, + "nixpkgs_ghc901": { + "locked": { + "lastModified": 1639713555, + "narHash": "sha256-w1TacWjnqhC19n+rheyOif3JxwvWMbyxfgqYCY0FLdQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "45a3f9d7725c7e21b252c223676cc56fb2ed5d6d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "45a3f9d7725c7e21b252c223676cc56fb2ed5d6d", + "type": "github" + } + }, + "nixpkgs_ghc902": { + "locked": { + "lastModified": 1642069818, + "narHash": "sha256-666w6j8wl/bojfgpp0k58/UJ5rbrdYFbI2RFT2BXbSQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "46821ea01c8f54d2a20f5a503809abfc605269d7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "46821ea01c8f54d2a20f5a503809abfc605269d7", + "type": "github" + } + }, + "nixpkgs_ghc922": { + "locked": { + "lastModified": 1651927509, + "narHash": "sha256-fGVGUdEsriuAL1vkUh29FlOQmEkPRnSfRGImWYaVjos=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2fdb6f2e08e7989b03a2a1aa8538d99e3eeea881", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2fdb6f2e08e7989b03a2a1aa8538d99e3eeea881", + "type": "github" + } + }, + "nmd": { + "flake": false, + "locked": { + "lastModified": 1648078774, + "narHash": "sha256-rWaMxlODw2uji55ANn+t0/20elreUGvvY9FaRNbBJMo=", + "ref": "master", + "rev": "de522bdd533350b3afb41e1ce9b3afb72922fba2", + "revCount": 31, + "type": "git", + "url": "https://gitlab.com/rycee/nmd" + }, + "original": { + "type": "git", + "url": "https://gitlab.com/rycee/nmd" + } + }, + "obelisk": { + "flake": false, + "locked": { + "lastModified": 1650800768, + "narHash": "sha256-bBr61MzVFyIMpsri8inOPxCHSL1ogFbpb3uGS7pZ+X0=", + "owner": "tek", + "repo": "obelisk", + "rev": "7991b4d86be0ae04e22bcbe91607d99eb113c2c2", + "type": "github" + }, + "original": { + "owner": "tek", + "ref": "ghc9", + "repo": "obelisk", + "type": "github" + } + }, + "root": { + "inputs": { + "hix": "hix" + } + }, + "thax": { + "locked": { + "lastModified": 1650770034, + "narHash": "sha256-OI4dxtNKgXogHBwYnNAfDABhHEcmWiBkkboZ+cCfyzk=", + "owner": "tek", + "repo": "thax", + "rev": "dc0025eebaba4ad97fcf48b68c14c8901d90daa5", + "type": "github" + }, + "original": { + "owner": "tek", + "repo": "thax", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..01a3231 --- /dev/null +++ b/flake.nix @@ -0,0 +1,57 @@ +{ + description = "vger"; + inputs.hix.url = github:tek/hix; + + outputs = { hix, ... }: + hix.lib.flake { + ghci.extensions = hix.inputs.nixpkgs.lib.mkForce []; + ghci.args = hix.inputs.nixpkgs.lib.mkForce []; + base = ./.; + packages = { vger = ./.; }; + hpack.packages.vger = { + name = "vger"; + + executables.vger = { + ghc-options = [ + "-Wunused-packages" + ]; + main = "Vger.hs"; + source-dirs = "app"; + dependencies = [ + "vger" + "base" + "optparse-applicative" + ]; + }; + + library = { + ghc-options = [ + "-Wunused-packages" + ]; + source-dirs = "lib"; + dependencies = [ + "base" + "regex-pcre" + "regex-compat" + "mime-types" + "utf8-string" + "directory" + "text" + ]; + }; + + tests.test = { + ghc-options = [ + "-Wunused-packages" + ]; + main = "Main.hs"; + source-dirs = "tests"; + dependencies = [ + "vger" + "base" + "HUnit" + ]; + }; + }; + }; +} diff --git a/src/Gemini.hs b/lib/Gemini.hs similarity index 100% rename from src/Gemini.hs rename to lib/Gemini.hs diff --git a/src/Unit.hs b/tests/Main.hs similarity index 95% rename from src/Unit.hs rename to tests/Main.hs index 7e3183f..0487c04 100644 --- a/src/Unit.hs +++ b/tests/Main.hs @@ -1,3 +1,5 @@ +module Main where + import Test.HUnit import Gemini @@ -63,10 +65,15 @@ mime_2 = TestCase (assertEqual (get_mime "file.txt")) mime_3 = TestCase (assertEqual - "markdown file" + "jpeg file" "image/jpeg" (get_mime "picture.jpg")) +mime_4 = TestCase (assertEqual + "png file" + "image/png" + (get_mime "picture.png")) + tests = TestList [ regex_1 , regex_2 @@ -81,6 +88,7 @@ tests = TestList , mime_1 , mime_2 , mime_3 + , mime_4 ] main :: IO Counts diff --git a/vger.cabal b/vger.cabal new file mode 100644 index 0000000..ffbf494 --- /dev/null +++ b/vger.cabal @@ -0,0 +1,57 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.34.6. +-- +-- see: https://github.com/sol/hpack + +name: vger +version: 0.0.0 +license: BSD2 +license-file: LICENSE +build-type: Simple + +library + exposed-modules: + Gemini + other-modules: + Paths_vger + hs-source-dirs: + lib + ghc-options: -Wunused-packages + build-depends: + base + , directory + , mime-types + , regex-compat + , regex-pcre + , text + , utf8-string + default-language: Haskell2010 + +executable vger + main-is: Vger.hs + hs-source-dirs: + app + ghc-options: -Wunused-packages + other-modules: + Paths_vger + build-depends: + base + , optparse-applicative + , text + , vger + default-language: Haskell2010 + +test-suite test + type: exitcode-stdio-1.0 + main-is: Main.hs + other-modules: + Paths_vger + hs-source-dirs: + tests + ghc-options: -Wunused-packages + build-depends: + HUnit + , base + , vger + default-language: Haskell2010