From 6fa93ca2dad88f7b8db10e09db58fdd7ac17d2a2 Mon Sep 17 00:00:00 2001 From: weiss Date: Sun, 21 Jan 2024 10:40:47 +0100 Subject: [PATCH] Initial commit --- .github/workflows/CI.yaml | 63 ++++++++++++++++++++++++++++++++++++ .gitignore | 27 ++++++++++++++++ .hlint.yaml | 15 +++++++++ CHANGELOG.md | 7 ++++ LICENSE | 29 +++++++++++++++++ README.md | 5 +++ app/Main.hs | 4 +++ bench/Main.hs | 4 +++ cabal.project | 5 +++ flake.lock | 43 +++++++++++++++++++++++++ flake.nix | 45 ++++++++++++++++++++++++++ hie.yaml | 16 +++++++++ src/Lib.hs | 7 ++++ test/Spec.hs | 8 +++++ weiss-xmonad.cabal | 68 +++++++++++++++++++++++++++++++++++++++ 15 files changed, 346 insertions(+) create mode 100644 .github/workflows/CI.yaml create mode 100644 .gitignore create mode 100644 .hlint.yaml create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 app/Main.hs create mode 100644 bench/Main.hs create mode 100644 cabal.project create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hie.yaml create mode 100644 src/Lib.hs create mode 100644 test/Spec.hs create mode 100644 weiss-xmonad.cabal diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml new file mode 100644 index 0000000..a397a76 --- /dev/null +++ b/.github/workflows/CI.yaml @@ -0,0 +1,63 @@ +name: CI + +on: + - push + - pull_request + +jobs: + + nix-build: + name: Nix build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v16 + - name: Build dependencies + run: nix develop --command ghc --version + - name: Build weiss-xmonad + run: nix build -L + - name: Build weiss-xmonad shell + run: nix build -L '.#devShells.x86_64-linux.default' + + stack-build: + name: Stack ${{ matrix.resolver }} on ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + resolver: [ nightly, lts-19, lts-18, lts-17, lts-16, lts-15, lts-14 ] + os: [ macos-latest, ubuntu-latest ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: haskell/actions/setup@v1 + with: + enable-stack: true + ## For some reason, stack caching seems to be very brittle, and cause a lot of build failures. + ## I haven't investigated very thoroughly what to best do about this, but for now, I'm just not caching stack builds. + - run: stack init --resolver ${{ matrix.resolver }} + - run: stack build --resolver ${{ matrix.resolver }} --only-dependencies + - run: stack build --resolver ${{ matrix.resolver }} + - run: stack build --resolver ${{ matrix.resolver }} --haddock --test --bench --no-run-benchmarks + + cabal-build: + name: Cabal with GHC ${{ matrix.ghc }} on ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + ghc: [ '8.6.5', '8.8.3', '8.10.7', '9.0.2', '9.2.2' ] + os: [ ubuntu-latest, macos-latest ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: haskell/actions/setup@v1 + with: + ghc-version: ${{ matrix.ghc }} + - uses: actions/cache@v2 + with: + path: | + ~/.cabal + dist-newstyle + key: cabal-cache-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal') }} + - run: cabal new-build --only-dependencies + - run: cabal new-build + - run: cabal new-test --test-show-details=direct diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..edb8907 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +### Nix ### +result + +### Haskell ### +dist +dist-* +cabal-dev +*.o +*.hi +*.hie +*.chi +*.chs.h +*.dyn_o +*.dyn_hi +.hpc +.hsenv +.cabal-sandbox/ +cabal.sandbox.config +*.prof +*.aux +*.hp +*.eventlog +.stack-work/ +cabal.project.local +cabal.project.local~ +.HTF/ +.ghc.environment.* diff --git a/.hlint.yaml b/.hlint.yaml new file mode 100644 index 0000000..9c20f4f --- /dev/null +++ b/.hlint.yaml @@ -0,0 +1,15 @@ +# template-haskell example hlint file + +# Generalise map to fmap, ++ to <>. Off by default +- group: + name: generalise + enabled: true + +- ignore: + name: Use section + +- ignore: + name: Use infix + +- ignore: + name: Avoid lambda using `infix` diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5fccd0a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## 0 + +### [Added] +### [Removed] +### [Changed] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..163da81 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2024, weiss +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. 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. + +3. Neither the name of the copyright holder nor the names of its + 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 HOLDER 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/README.md b/README.md new file mode 100644 index 0000000..9092146 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# weiss-xmonad +[![weiss-xmonad on hackage](https://img.shields.io/hackage/v/weiss-xmonad)](http://hackage.haskell.org/package/weiss-xmonad) +[![weiss-xmonad on Stackage Nightly](https://stackage.org/package/weiss-xmonad/badge/nightly)](https://stackage.org/nightly/package/weiss-xmonad) + +Generated with [template-haskell](https://github.com/jonascarpay/template-haskell) diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..2ca1f1d --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,4 @@ +import Lib + +main :: IO () +main = putStrLn "heyyyyyy" diff --git a/bench/Main.hs b/bench/Main.hs new file mode 100644 index 0000000..04c2719 --- /dev/null +++ b/bench/Main.hs @@ -0,0 +1,4 @@ +import Lib + +main :: IO () +main = putStrLn "heyyyyyyyyyyyyyyyyyyyy" diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..9ce5498 --- /dev/null +++ b/cabal.project @@ -0,0 +1,5 @@ +packages: + ./ + +package weiss-xmonad + tests: True diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a0d255d --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1705543379, + "narHash": "sha256-8wC0vVz/LTqJprbAAvE9P4L01Mi6DJHYwvuM0Uq57og=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3d7dbcfb56a1cff0729280da3f1185044628975b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "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..3f3e135 --- /dev/null +++ b/flake.nix @@ -0,0 +1,45 @@ +{ + description = "weiss-xmonad"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-23.11"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = inputs: + let + overlay = final: prev: { + haskell = prev.haskell // { + packageOverrides = hfinal: hprev: + prev.haskell.packageOverrides hfinal hprev // { + weiss-xmonad = hfinal.callCabal2nix "weiss-xmonad" ./. { }; + }; + }; + weiss-xmonad = final.haskell.lib.compose.justStaticExecutables final.haskellPackages.weiss-xmonad; + }; + perSystem = system: + let + pkgs = import inputs.nixpkgs { inherit system; overlays = [ overlay ]; }; + hspkgs = pkgs.haskellPackages; + in + { + devShells = rec { + default = weiss-xmonad-shell; + weiss-xmonad-shell = hspkgs.shellFor { + withHoogle = true; + packages = p: [ p.weiss-xmonad ]; + buildInputs = [ + hspkgs.cabal-install + hspkgs.haskell-language-server + hspkgs.hlint + hspkgs.ormolu + pkgs.bashInteractive + ]; + }; + }; + packages = rec { + default = weiss-xmonad; + weiss-xmonad = pkgs.weiss-xmonad; + }; + }; + in + { inherit overlay; } // inputs.flake-utils.lib.eachDefaultSystem perSystem; +} diff --git a/hie.yaml b/hie.yaml new file mode 100644 index 0000000..4c415ce --- /dev/null +++ b/hie.yaml @@ -0,0 +1,16 @@ +cradle: + multi: + # - path: "ignore/" + # config: {cradle: {none: }} + + - path: "src" + config: {cradle: {cabal: {component: "lib:weiss-xmonad"}}} + + - path: "app" + config: {cradle: {cabal: {component: "weiss-xmonad:weiss-xmonad-exe"}}} + + - path: "test" + config: {cradle: {cabal: {component: "weiss-xmonad:weiss-xmonad-test"}}} + + - path: "bench" + config: {cradle: {cabal: {component: "weiss-xmonad:weiss-xmonad-bench"}}} diff --git a/src/Lib.hs b/src/Lib.hs new file mode 100644 index 0000000..1055c22 --- /dev/null +++ b/src/Lib.hs @@ -0,0 +1,7 @@ +module Lib + ( someFunc, + ) +where + +someFunc :: IO () +someFunc = putStrLn "hey" diff --git a/test/Spec.hs b/test/Spec.hs new file mode 100644 index 0000000..469f02b --- /dev/null +++ b/test/Spec.hs @@ -0,0 +1,8 @@ +import Test.Hspec + +main :: IO () +main = + hspec $ + describe "weiss-xmonad-test" $ + it "works" $ + 2 + 2 `shouldBe` (4 :: Int) diff --git a/weiss-xmonad.cabal b/weiss-xmonad.cabal new file mode 100644 index 0000000..f1481f9 --- /dev/null +++ b/weiss-xmonad.cabal @@ -0,0 +1,68 @@ +cabal-version: 2.4 +name: weiss-xmonad +version: 0 +license: BSD-3-Clause +build-type: Simple +license-file: LICENSE +author: weiss +maintainer: weiss +copyright: 2024 weiss +tested-with: GHC ==8.6.5 || ==8.8.3 || ==8.10.7 || ==9.0.2 || ==9.2.2 +extra-doc-files: + CHANGELOG.md + README.md + +-- category: +-- description: description +-- synopsis: one-line synopsis +-- homepage: https://github.com/FIXME/weiss-xmonad#readme +-- source-repository head +-- type: git +-- location: git://github.com/FIXME/weiss-xmonad.git + +common common-options + build-depends: base >=4.9 && <5 + default-language: Haskell2010 + ghc-options: + -Wall -Wcompat -Widentities -Wincomplete-uni-patterns + -Wincomplete-record-updates -Wredundant-constraints + -fhide-source-paths -Wpartial-fields + +library + import: common-options + hs-source-dirs: src + exposed-modules: Lib + build-depends: + , containers + , mtl + +executable weiss-xmonad-exe + import: common-options + hs-source-dirs: app + main-is: Main.hs + build-depends: weiss-xmonad + ghc-options: -threaded -rtsopts -with-rtsopts=-N + +test-suite weiss-xmonad-test + import: common-options + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: Spec.hs + build-depends: + , hspec + , HUnit + , weiss-xmonad + , QuickCheck + + ghc-options: -threaded -rtsopts -with-rtsopts=-N + +benchmark weiss-xmonad-bench + import: common-options + type: exitcode-stdio-1.0 + hs-source-dirs: bench + main-is: Main.hs + build-depends: + , criterion + , weiss-xmonad + + ghc-options: -threaded -rtsopts -with-rtsopts=-N