diff --git a/.gitignore b/.gitignore index febbcdd..8b7ca09 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,7 @@ cabal.sandbox.config .*.swp *.log *.dump-hi +.direnv/ +.envrc dist-newstyle/ +result/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..db382ba --- /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": 1695360818, + "narHash": "sha256-JlkN3R/SSoMTa+CasbxS1gq+GpGxXQlNZRUh9+LIy/0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e35dcc04a3853da485a396bdd332217d0ac9054f", + "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..c537278 --- /dev/null +++ b/flake.nix @@ -0,0 +1,82 @@ +{ + description = "mat-chalmers 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 = mat; + mat = pkgs.haskell.packages.${ghcVer}.mat; + }; + + checks = { + inherit (self.packages.${system}) mat; + }; + + # for debugging + # inherit pkgs; + + devShells.default = + let haskellPackages = pkgs.haskell.packages.${ghcVer}; + in + haskellPackages.shellFor { + packages = p: [ self.packages.${system}.mat ]; + withHoogle = true; + buildInputs = + [ pkgs.docker ] ++ + (with haskellPackages; [ + haskell-language-server + cabal-install + ]); + # 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 + { + mat = hprev.callCabal2nix "mat" ./. { }; + + # 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/mat-chalmers.cabal b/mat-chalmers.cabal index 03b9b10..d20044a 100644 --- a/mat-chalmers.cabal +++ b/mat-chalmers.cabal @@ -1,3 +1,4 @@ +cabal-version: 3.0 name: mat-chalmers version: 0.1.0.0 license: MIT @@ -6,7 +7,6 @@ author: Adam Sandberg Eriksson maintainer: adam@sandbergericsson.se category: Web build-type: Simple -cabal-version: >=1.10 Tested-With: GHC ==9.4.5 data-files: static/style.css @@ -38,7 +38,7 @@ library , css-text >= 0.1.3.0 && < 0.2 , exceptions >= 0.10.5 && < 0.11.0 , heredoc == 0.2.0.0 - , http-client >= 0.7.14 && < 0.8 + , http-client >= 0.7.13.1 && < 0.8 , http-client-tls >= 0.3.6.1 && <= 0.4 , logging-effect >= 1.4.0 && <= 2.0 , microlens-platform >= 0.4.3.3 && < 0.5 @@ -61,7 +61,7 @@ executable mat-chalmers , base , bytestring , file-embed - , http-client-tls + , http-client-tls >= 0.3.5.3 , microlens-platform , logging-effect , mtl @@ -83,4 +83,4 @@ Test-Suite test-mat , hspec >= 2.10.10 && < 3.0 , HUnit >= 1.6.2.0 && < 2.0 , text - , thyme + , thyme >= 0.3.5.5 diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 84e1ccf..0000000 --- a/shell.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ nixpkgs ? import {}, compiler ? "default", doBenchmark ? false }: - -let - - inherit (nixpkgs) pkgs; - - f = { mkDerivation, aeson, base, bytestring, css-text, errors - , exceptions, file-embed, heredoc, http-client, http-client-tls - , logging-effect, lucid, microlens-platform, mtl, old-locale - , prettyprinter, safe, scotty, stdenv, text, thyme, time, wai-extra - , wai-middleware-static-embedded - }: - mkDerivation { - pname = "mat-chalmers"; - version = "0.1.0.0"; - src = ./.; - isLibrary = true; - isExecutable = true; - buildTools = [ haskellPackages.cabal-install ]; - enableSeparateDataOutput = true; - libraryHaskellDepends = [ - aeson base bytestring css-text errors exceptions file-embed heredoc - http-client logging-effect lucid microlens-platform mtl old-locale - prettyprinter safe text thyme - ]; - executableHaskellDepends = [ - base bytestring file-embed http-client-tls logging-effect - microlens-platform mtl scotty time wai-extra - wai-middleware-static-embedded - ]; - license = stdenv.lib.licenses.mit; - }; - - haskellPackages = if compiler == "default" - then pkgs.haskellPackages - else pkgs.haskell.packages.${compiler}; - - variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; - - drv = variant (haskellPackages.callPackage f {}); - -in - - if pkgs.lib.inNixShell then drv.env else drv