Skip to content

Commit

Permalink
improved flake
Browse files Browse the repository at this point in the history
  • Loading branch information
leana8959 committed Sep 13, 2024
1 parent 653879c commit 79f78ee
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 76 deletions.
10 changes: 5 additions & 5 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 29 additions & 46 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,47 @@
description = "prop-solveur, a simple logic solver";

inputs = {
# stackage 21.25 / ghc948 (Jan 7 2024) (Last of 9.4.x)
nixpkgs.url = "github:NixOS/nixpkgs/edebca765c17d551b9634c02f6a02f1b122e0ba0";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
inputs:
inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
pkgs = import inputs.nixpkgs { inherit system; };

hPkgs = pkgs.haskellPackages;

devTools = [
stack-wrapped
hPkgs.ghc
hPkgs.haskell-language-server
hPkgs.stylish-haskell
];

stack-wrapped = pkgs.symlinkJoin {
name = "stack";
paths = [ pkgs.stack ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/stack \
--add-flags "--no-nix --system-ghc --no-install-ghc"
'';
};
in
{
formatter = pkgs.alejandra;

packages.default = pkgs.haskell.lib.justStaticExecutables (
(pkgs.haskellPackages.callCabal2nix "prop-solveur" ./. { }).overrideAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.installShellFiles ];
postInstall =
(old.postInstall or "")
+ ''
installShellCompletion --cmd prop-solveur \
--bash <("$out/bin/prop-solveur" --bash-completion-script "$out/bin/prop-solveur") \
--fish <("$out/bin/prop-solveur" --fish-completion-script "$out/bin/prop-solveur") \
--zsh <("$out/bin/prop-solveur" --zsh-completion-script "$out/bin/prop-solveur")
'';
})
);
formatter = pkgs.nixfmt-rfc-style;

packages.default =
let
rawPackage = pkgs.haskellPackages.callCabal2nix "prop-solveur" ./. { };
in
pkgs.haskell.lib.justStaticExecutables (
rawPackage.overrideAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.installShellFiles ];
postInstall =
(old.postInstall or "")
+ ''
installShellCompletion --cmd prop-solveur \
--bash <("$out/bin/prop-solveur" --bash-completion-script "$out/bin/prop-solveur") \
--fish <("$out/bin/prop-solveur" --fish-completion-script "$out/bin/prop-solveur") \
--zsh <("$out/bin/prop-solveur" --zsh-completion-script "$out/bin/prop-solveur")
'';
})
);

devShells.default = pkgs.mkShell {
buildInputs = devTools;

# Make external Nix c libraries like zlib known to GHC, like pkgs.haskell.lib.buildStackProject does
# https://github.com/NixOS/nixpkgs/blob/d64780ea0e22b5f61cd6012a456869c702a72f20/pkgs/development/haskell-modules/generic-stack-builder.nix#L38
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath devTools;
buildInputs = [
pkgs.cabal-install
hPkgs.ghc
hPkgs.haskell-language-server
hPkgs.stylish-haskell
];
};
}
);
Expand Down
18 changes: 9 additions & 9 deletions prop-solveur.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ common common
default-language: GHC2021
ghc-options: -Wall -Wextra
build-depends:
, base ^>=4.17
, containers ^>=0.6
, megaparsec ^>=9.3.1
, pretty-simple ^>=4.1.2.0
, text ^>=2.0.2
, base
, containers
, megaparsec
, pretty-simple
, text

default-extensions: BlockArguments

Expand All @@ -29,8 +29,8 @@ executable prop-solveur
import: common
main-is: app/Main.hs
build-depends:
, ansi-terminal ^>=0.11.5
, optparse-applicative ^>=0.17.1.0
, ansi-terminal
, optparse-applicative
, prop-solveur

test-suite prop-solveur-spec
Expand All @@ -40,6 +40,6 @@ test-suite prop-solveur-spec
main-is: Spec.hs
other-modules: ParserSpec
build-depends:
, hspec >=2.10.10
, hspec
, prop-solveur
, QuickCheck >=2.14.3
, QuickCheck
4 changes: 0 additions & 4 deletions stack.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions stack.yaml.lock

This file was deleted.

0 comments on commit 79f78ee

Please sign in to comment.