advent-of-code-2023/flake.nix

53 lines
1.8 KiB
Nix

{
description = "Dev Setup";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = {nixpkgs, flake-utils, ...}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
# Avoids unnecessary recompiles
filteredSource = pkgs.lib.cleanSourceWith {
src = ./haskell;
filter = path: type:
let baseName = baseNameOf (toString path);
in pkgs.lib.cleanSourceFilter path type && !(
baseName == "flake.nix" ||
baseName == "flake.lock" ||
baseName == "dist-newstyle" ||
builtins.match "^cabal\.project\..*$" baseName != null ||
baseName == "hls.sh" ||
baseName == ".envrc" ||
baseName == "hie.yaml" ||
baseName == ".hlint.yaml" ||
baseName == ".hspec" ||
baseName == "ci"
);
};
ghcOverrides = hself: hsuper: rec {
aoc2023 = pkgs.haskell.lib.overrideSrc (hsuper.callPackage ./haskell/default.nix {}) {
src = filteredSource;
};
};
ghc94Pkgs = pkgs.haskell.packages.ghc94.override {
overrides = ghcOverrides;
};
in rec {
packages = rec {
dev-env = ghc94Pkgs.shellFor {
packages = p: [p.aoc2023];
buildInputs = [
pkgs.haskellPackages.cabal-install
(pkgs.haskell-language-server.override {supportedGhcVersions = ["948"];})
pkgs.cabal2nix
pkgs.ormolu
];
};
aoc2023 = ghc94Pkgs.aoc2023;
};
defaultPackage = packages.dev-env;
});
}