From df8b17ec368a41c8d10f894f4e2410dd58b34477 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sat, 16 Dec 2023 06:30:30 +0100 Subject: [PATCH] clean nix files a bit --- default.nix | 5 +++++ flake.nix | 15 ++------------- shell.nix | 9 ++++++--- 3 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..ed67ffe --- /dev/null +++ b/default.nix @@ -0,0 +1,5 @@ +{ pkgs ? import {}, self ? ./., packageName ? "chaoszone" }: +let + gitignore = dir: pkgs.nix-gitignore.gitignoreSource [] dir; +in + pkgs.haskellPackages.callCabal2nix packageName (gitignore self) {} diff --git a/flake.nix b/flake.nix index 302c16a..e6c25b7 100644 --- a/flake.nix +++ b/flake.nix @@ -18,22 +18,11 @@ packageName = "chaoszone"; in rec { - packages.${packageName} = # (ref:haskell-package-def) - haskellPackages.callCabal2nix packageName self rec { - }; + packages.${packageName} = import ./default.nix {inherit pkgs self;}; defaultPackage = self.packages.${system}.${packageName}; - devShell = haskellPackages.shellFor { - packages = p: [ defaultPackage ]; - withHoogle = true; - buildInputs = with haskellPackages; with pkgs; [ - vim - haskell-language-server - ghcid - cabal-install - ]; - }; + devShell = import ./shell.nix {inherit pkgs; chaoszone = defaultPackage;}; #devShell = pkgs.mkShell { # buildInputs = with haskellPackages; [ # haskell-language-server diff --git a/shell.nix b/shell.nix index 1d86862..29d4cd6 100644 --- a/shell.nix +++ b/shell.nix @@ -1,8 +1,11 @@ -{ pkgs ? import {}}: +{ pkgs ? import {}, chaoszone ? null}: let - chaoszone_cz = - pkgs.haskellPackages.callCabal2nix "chaoszone" (gitignore ./.) {}; + chaoszone_cz = if isNull chaoszone + then + (import ./default.nix {inherit pkgs; packageName = "chaoszone";}) + else + chaoszone; gitignore = dir: pkgs.nix-gitignore.gitignoreSource [] dir; in pkgs.haskellPackages.shellFor {