From 6eba471e2426e7e4e7d5c935e3ce973e13fd6b24 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 31 Aug 2019 13:15:17 -0400 Subject: Use haskellSrc2nix over explicit cabal2nix Use the (undocumented!) helper function haskellSrc2nix over having to explicitly run cabal2nix all the time when rebuilding --- default.nix | 4 ++-- nixpkgs.nix | 9 +++++++++ pkg.nix | 7 +++++++ shell.nix | 6 +++--- xanthous.nix | 29 ----------------------------- 5 files changed, 21 insertions(+), 34 deletions(-) create mode 100644 nixpkgs.nix create mode 100644 pkg.nix delete mode 100644 xanthous.nix diff --git a/default.nix b/default.nix index f73c537abd43..7cf9f4beb451 100644 --- a/default.nix +++ b/default.nix @@ -1,8 +1,8 @@ -{ nixpkgs ? import {}, compiler ? "ghc865" }: +{ nixpkgs ? import ./nixpkgs.nix {}, compiler ? "ghc865" }: let inherit (nixpkgs) pkgs; all-hies = import (fetchTarball "https://github.com/infinisil/all-hies/tarball/master") {}; hie = all-hies.selection { selector = p: { inherit (p) ghc865; }; }; - xanthous = pkgs.haskellPackages.callPackage ./xanthous.nix {}; + xanthous = pkgs.haskellPackages.callPackage (import ./pkg.nix { inherit nixpkgs; }) {}; in xanthous // { inherit hie; } diff --git a/nixpkgs.nix b/nixpkgs.nix new file mode 100644 index 000000000000..19bf2c59cedd --- /dev/null +++ b/nixpkgs.nix @@ -0,0 +1,9 @@ +let + inherit (import {}) fetchFromGitHub; + nixpkgs = fetchFromGitHub { + owner = "NixOS"; + repo = "nixpkgs-channels"; + rev = "54f385241e6649128ba963c10314942d73245479"; + sha256 = "0bd4v8v4xcdbaiaa59yqprnc6dkb9jv12mb0h5xz7b51687ygh9l"; + }; +in import nixpkgs diff --git a/pkg.nix b/pkg.nix new file mode 100644 index 000000000000..d3b65a64f337 --- /dev/null +++ b/pkg.nix @@ -0,0 +1,7 @@ +{ nixpkgs ? import ./nixpkgs.nix {} }: +let inherit (nixpkgs) pkgs; in +import (pkgs.haskellPackages.haskellSrc2nix { + name = "xanthous"; + src = ./.; + extraCabal2nixOptions = "--hpack"; +}) diff --git a/shell.nix b/shell.nix index aefc492d3d44..966ab0bb0857 100644 --- a/shell.nix +++ b/shell.nix @@ -1,8 +1,8 @@ -{ nixpkgs ? import {}, compiler ? "ghc865", withHoogle ? true }: +{ nixpkgs ? import ./nixpkgs.nix {}, compiler ? "ghc865", withHoogle ? true }: let inherit (nixpkgs) pkgs; - xan = import ./xanthous.nix; + pkg = import ./pkg.nix { inherit nixpkgs; }; packageSet = ( if compiler == "default" @@ -21,7 +21,7 @@ let else packageSet ); - drv = haskellPackages.callPackage xan {}; + drv = haskellPackages.callPackage pkg {}; inherit (pkgs.haskell.lib) addBuildTools; in diff --git a/xanthous.nix b/xanthous.nix deleted file mode 100644 index a10ed48305bb..000000000000 --- a/xanthous.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ mkDerivation, ascii-art-to-unicode, base, brick, classy-prelude -, constraints, containers, data-default, deepseq, hpack, lens, mtl -, QuickCheck, stdenv, tasty, tasty-hunit, tasty-quickcheck, vty -}: -let - pkgs = import {}; - all-hies = import (fetchTarball "https://github.com/infinisil/all-hies/tarball/master") {}; - hie = all-hies.selection { selector = p: { inherit (p) ghc865; }; }; -in -mkDerivation { - pname = "xanthous"; - version = "0.1.0.0"; - src = ./.; - libraryHaskellDepends = [ - ascii-art-to-unicode base brick classy-prelude constraints - containers data-default deepseq lens mtl QuickCheck vty - ]; - libraryToolDepends = [ hpack ]; - testHaskellDepends = [ - ascii-art-to-unicode base brick classy-prelude constraints - containers data-default deepseq lens mtl QuickCheck tasty - tasty-hunit tasty-quickcheck - ]; - executableSystemDepends = [ hie pkgs.cabal-install ]; - preConfigure = "hpack"; - homepage = "https://github.com/glittershark/xanthous#readme"; - description = "A WIP TUI RPG"; - license = stdenv.lib.licenses.gpl3; -} -- cgit 1.4.1