Skip to content

Commit

Permalink
nix: reworked flake
Browse files Browse the repository at this point in the history
  • Loading branch information
leana8959 committed Oct 2, 2024
1 parent f4612ab commit 814082e
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 64 deletions.
47 changes: 22 additions & 25 deletions flake.lock

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

75 changes: 36 additions & 39 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,45 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-parts.url = "github:hercules-ci/flake-parts";
};

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

hPkgs = pkgs.haskellPackages;
in
{
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 = [
hPkgs.ghc
pkgs.cabal-install
hPkgs.cabal-fmt
hPkgs.haskell-language-server
hPkgs.fourmolu
];
inputs.flake-parts.lib.mkFlake { inherit inputs; } {

imports = [ ./nix/overlays.nix ];

systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

perSystem =
{ pkgs, self', ... }:
{
formatter = pkgs.nixfmt-rfc-style;

packages.default = (inputs.self.overlays.default pkgs pkgs).prop-solveur;

devShells.default = pkgs.mkShell {
packages =
let
hPkgs = pkgs.haskellPackages;
in
[
hPkgs.ghc
pkgs.cabal-install
hPkgs.cabal-fmt
hPkgs.haskell-language-server
hPkgs.fourmolu
];
};

};
}
);

};

}
33 changes: 33 additions & 0 deletions nix/overlays.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{

flake.overlays.default =
final: _:

let
rawPackage = final.haskellPackages.callCabal2nix "prop-solveur" ../. { };

prop-solveur = final.lib.pipe rawPackage [
(
p:
p.overrideAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ final.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")
'';
})
)

final.haskell.lib.justStaticExecutables
];
in

{
inherit prop-solveur;
};

}

0 comments on commit 814082e

Please sign in to comment.