From ea1ecaed8ead1263d14f80bdffc87e8eba46eb3a Mon Sep 17 00:00:00 2001 From: pingu Date: Mon, 28 Aug 2023 14:40:33 +0200 Subject: [PATCH] muhahaha --- .envrc | 2 ++ .gitignore | 2 +- flake.lock | 61 +++++++++++++++++++++++++++++++++++++ flake.nix | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ stack.yaml | 7 ----- stack.yaml.lock | 40 ------------------------- 6 files changed, 144 insertions(+), 48 deletions(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 stack.yaml delete mode 100644 stack.yaml.lock diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..cc94b51 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +nix_direnv_watch_file *.cabal +use flake diff --git a/.gitignore b/.gitignore index 6a62767..f870747 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ cabal.project.local cabal.project.local~ .HTF/ .ghc.environment.* - +./.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ffc92ea --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1693099187, + "narHash": "sha256-FXCc6OIghv9k4xYOhSMZI6bj7o56S8BJKzKtTKzdUVQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cf2004afe4d4b95a295c63c911e949e40915eedb", + "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..0e1e111 --- /dev/null +++ b/flake.nix @@ -0,0 +1,80 @@ +{ + description = "Example Haskell flake showing overrides and adding stuff to the dev shell"; + + 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 = "ghc902"; + 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 = sample; + sample = pkgs.haskell.packages.${ghcVer}.sample; + }; + + checks = { + inherit (self.packages.${system}) sample; + }; + + # for debugging + # inherit pkgs; + + devShells.default = + let haskellPackages = pkgs.haskell.packages.${ghcVer}; + in + haskellPackages.shellFor { + packages = p: [ self.packages.${system}.sample ]; + withHoogle = true; + buildInputs = 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 + { + sample = hprev.callCabal2nix "sample" ./. { }; + + # 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/stack.yaml b/stack.yaml deleted file mode 100644 index 8f6b155..0000000 --- a/stack.yaml +++ /dev/null @@ -1,7 +0,0 @@ -resolver: lts-19.33 - -extra-deps: - - clash-ghc-1.6.4 - - clash-prelude-1.6.4 - - clash-lib-1.6.4 - - concurrent-supply-0.1.8 diff --git a/stack.yaml.lock b/stack.yaml.lock deleted file mode 100644 index 39112d0..0000000 --- a/stack.yaml.lock +++ /dev/null @@ -1,40 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: -- completed: - hackage: clash-ghc-1.6.4@sha256:43e4c9c949bf9623633f08bb09bb4495578b517be4e99140d9ea22dd2a9cd13b,9042 - pantry-tree: - sha256: 9484d37cd6c8cb0217a02cf020b6398dbe1a68fa332472b40cfb511ce54a743a - size: 3634 - original: - hackage: clash-ghc-1.6.4 -- completed: - hackage: clash-prelude-1.6.4@sha256:67b5c26ad7c712e23f5d54187d691cbb007931a89b4aabd4a738c307d71b2a27,17249 - pantry-tree: - sha256: b12774016a4f9bd456ecdf7bc1e5182d33ef4ac9e16db0f344d27189a26bfe2d - size: 13292 - original: - hackage: clash-prelude-1.6.4 -- completed: - hackage: clash-lib-1.6.4@sha256:336e57d424852f2ad9285b6fa820e634f32d39d52755d3245d5f4ac04ea37f85,13688 - pantry-tree: - sha256: 750ffc9d2f5ed3690f6a2a7da46090970594dbbcf8a6b55d785e8f809b4dfbf1 - size: 22460 - original: - hackage: clash-lib-1.6.4 -- completed: - hackage: concurrent-supply-0.1.8@sha256:9373f4868ad28936a7b93781b214ef4afdeacf377ef4ac729583073491c9f9fb,1627 - pantry-tree: - sha256: bdfaa167ae3249f858ba248aea2e9b97ab9b13af6e68c73b7c3192e717e11b83 - size: 400 - original: - hackage: concurrent-supply-0.1.8 -snapshots: -- completed: - sha256: 6d1532d40621957a25bad5195bfca7938e8a06d923c91bc52aa0f3c41181f2d4 - size: 619204 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/33.yaml - original: lts-19.33