From 5bdb0be1c141214b3808fce3a30773e1194be366 Mon Sep 17 00:00:00 2001 From: pingu Date: Wed, 18 Oct 2023 19:47:11 +0200 Subject: [PATCH] =?UTF-8?q?=C2=B0=E2=80=BF=E2=80=BF=C2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .envrc | 1 + .gitignore | 2 +- CHANGELOG.md | 5 +++ LICENSE | 36 ++++++++--------- README.md | 2 - README.org | 16 ++++++++ app/Main.hs | 8 ++++ flake.lock | 61 ++++++++++++++++++++++++++++ flake.nix | 82 ++++++++++++++++++++++++++++++++++++++ snusmumrik.cabal | 101 +++++++++++++++++++++++++++++++++++++++++++++++ src/MyLib.hs | 4 ++ 11 files changed, 297 insertions(+), 21 deletions(-) create mode 100644 .envrc create mode 100644 CHANGELOG.md delete mode 100644 README.md create mode 100644 README.org create mode 100644 app/Main.hs create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 snusmumrik.cabal create mode 100644 src/MyLib.hs diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 6a62767..6cb66f1 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ cabal.project.local cabal.project.local~ .HTF/ .ghc.environment.* - +.direnv/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9247014 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for snusmumrik + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/LICENSE b/LICENSE index d4464e0..867b40a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,20 +1,20 @@ -by Jim Knoble - Copyright (C) 1999,2000,2001 Jim Knoble - - Permission to use, copy, modify, distribute, and sell this software - and its documentation for any purpose is hereby granted without fee, - provided that the above copyright notice appear in all copies and - that both that copyright notice and this permission notice appear in - supporting documentation. +Copyright (c) 2023 Nor Führ -+------------+ -| Disclaimer | -+------------+ +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - express or implied, including but not limited to the warranties of - merchantability, fitness for a particular purpose and - noninfringement. In no event shall the author(s) be liable for any - claim, damages or other liability, whether in an action of contract, - tort or otherwise, arising from, out of or in connection with the - software or the use or other dealings in the software. +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index 097e029..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# snusmumrik - diff --git a/README.org b/README.org new file mode 100644 index 0000000..6ae22e5 --- /dev/null +++ b/README.org @@ -0,0 +1,16 @@ +#+title: snusmumrik + +Intention is for a user interface to [[https://www.nomadproject.io/][nomad]]. + +* About the name +The name came from a haskell package named [[https://hackage.haskell.org/package/Snusmumrik][snusmumrik]] which has the following text + +#+begin_example +Snusmumrik is a Russian name for [Snufkin][snufkin] (Swedish: Snusmumriken), +a character in the Moomin series of books by Tove Jansson. Snufkin dislikes +all symbols of private property, forbidding signs and fenced lawns. He likes +travelling, living in a tent, smoking a pipe and playing the harmonica. +#+end_example + +It also had a text about it having two components, snus and mumrik. +It would also be funny to the same in this one. 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/flake.lock b/flake.lock new file mode 100644 index 0000000..fac91b9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1697456312, + "narHash": "sha256-roiSnrqb5r+ehnKCauPLugoU8S36KgmWraHgRqVYndo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ca012a02bf8327be9e488546faecae5e05d7d749", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..797fcca --- /dev/null +++ b/flake.nix @@ -0,0 +1,82 @@ +{ + description = "snusmumrik goes flakes"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + nixConfig.allow-import-from-derivation = true; # cabal2nix uses IFD + + outputs = { self, nixpkgs, flake-utils }: + let + ghcVer = "ghc945"; + makeHaskellOverlay = overlay: final: prev: { + haskell = prev.haskell // { + packages = prev.haskell.packages // { + ${ghcVer} = prev.haskell.packages."${ghcVer}".override (oldArgs: { + overrides = + prev.lib.composeExtensions (oldArgs.overrides or (_: _: { })) + (overlay prev); + }); + }; + }; + }; + + out = system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + config.allowBroken = true; + }; + + in + { + packages = rec { + default = snusmumrik; + snusmumrik = pkgs.haskell.packages.${ghcVer}.snusmumrik; + }; + + checks = { + inherit (self.packages.${system}) snusmumrik; + }; + + # for debugging + # inherit pkgs; + + devShells.default = + let haskellPackages = pkgs.haskell.packages.${ghcVer}; + in + haskellPackages.shellFor { + packages = p: [ self.packages.${system}.snusmumrik ]; + withHoogle = true; + buildInputs = + (with haskellPackages; [ + haskell-language-server + cabal-install + implicit-hie + ]); + # Change the prompt to show that you are in a devShell + # shellHook = "export PS1='\\e[1;34mdev > \\e[0m'"; + }; + }; + in + flake-utils.lib.eachDefaultSystem out // { + # this stuff is *not* per-system + overlays = { + default = makeHaskellOverlay (prev: hfinal: hprev: + let hlib = prev.haskell.lib; in + { + snusmumrik = hprev.callCabal2nix "snusmumrik" ./. { }; + + # here's how to do hacks to the package set + # don't run the test suite + # fast-tags = hlib.dontCheck hprev.fast-tags; + # + # don't check version bounds + # friendly = hlib.doJailbreak hprev.friendly; + }); + }; + }; +} diff --git a/snusmumrik.cabal b/snusmumrik.cabal new file mode 100644 index 0000000..73e7e9e --- /dev/null +++ b/snusmumrik.cabal @@ -0,0 +1,101 @@ +cabal-version: 3.4 +-- 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 'snusmumrik' generated by +-- 'cabal init'. For further documentation, see: +-- http://haskell.org/cabal/users-guide/ +-- +-- The name of the package. +name: snusmumrik + +-- 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: MIT + +-- The file containing the license text. +license-file: LICENSE + +-- The package author(s). +author: Nor Führ + +-- An email address to which users can send suggestions, bug reports, and patches. +maintainer: nor@acorneroftheweb.com + +-- A copyright notice. +-- copyright: +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: Snus + + -- 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.17.1.0 + + -- Directories containing source files. + hs-source-dirs: src + + -- Base language which the package is written in. + default-language: GHC2021 + +executable mumrik + -- 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.17.1.0 + , snusmumrik + , brick >= 1.9 + , vty + + -- Directories containing source files. + hs-source-dirs: app + + -- Base language which the package is written in. + default-language: GHC2021 diff --git a/src/MyLib.hs b/src/MyLib.hs new file mode 100644 index 0000000..35ef82d --- /dev/null +++ b/src/MyLib.hs @@ -0,0 +1,4 @@ +module Snus (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "someFunc"