Skip to content

Commit

Permalink
Minor simplification of haskell-nix-flake
Browse files Browse the repository at this point in the history
  • Loading branch information
sellout committed Jun 27, 2024
1 parent 66f78e4 commit d483188
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
};
haskell-nix-flake = import ./nix/haskell-nix-flake.nix {
inherit pkgs unison-project versions;
inherit (nixpkgs-haskellNix) lib;
};
renameAttrs = fn:
nixpkgs-haskellNix.lib.mapAttrs' (name: value: {
Expand Down
75 changes: 37 additions & 38 deletions nix/haskell-nix-flake.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
lib,
pkgs,
unison-project,
versions,
Expand All @@ -14,7 +15,7 @@
additional = hpkgs: with hpkgs; [Cabal stm exceptions ghc ghc-heap];
buildInputs = let
native-packages =
pkgs.lib.optionals pkgs.stdenv.isDarwin
lib.optionals pkgs.stdenv.isDarwin
(with pkgs.darwin.apple_sdk.frameworks; [Cocoa]);
in
(args.buildInputs or [])
Expand Down Expand Up @@ -52,46 +53,44 @@

shellFor = args: unison-project.shellFor (commonShellArgs args);

localPackages = with pkgs.lib; filterAttrs (k: v: v.isLocal or false) unison-project.hsPkgs;
localPackages = lib.filterAttrs (k: v: v.isLocal or false) unison-project.hsPkgs;
localPackageNames = builtins.attrNames localPackages;
devShells = let
mkDevShell = pkgName:
shellFor {
packages = hpkgs: [hpkgs."${pkgName}"];
withHoogle = true;
};
localPackageDevShells =
pkgs.lib.genAttrs localPackageNames mkDevShell;
in
{
only-tools = shellFor {
packages = _: [];
withHoogle = false;
};
local = shellFor {
packages = hpkgs: (map (p: hpkgs."${p}") localPackageNames);
withHoogle = false;
};
}
// localPackageDevShells;

checks =
haskell-nix-flake.checks
// {
## This check has a test that tries to write to $HOME, so we give it a fake one.
"unison-cli:test:cli-tests" = haskell-nix-flake.checks."unison-cli:test:cli-tests".overrideAttrs (old: {
## The builder here doesn’t `runHook preBuild`, so we just prepend onto `buildPhase`.
buildPhase =
''
export HOME="$TMP/fake-home"
mkdir -p "$HOME"
''
+ old.buildPhase or "";
});
};
in
haskell-nix-flake
// {
checks =
haskell-nix-flake.checks
// {
## This check has a test that tries to write to $HOME, so we give it a fake one.
"unison-cli:test:cli-tests" = haskell-nix-flake.checks."unison-cli:test:cli-tests".overrideAttrs (old: {
## The builder here doesn’t `runHook preBuild`, so we just prepend onto `buildPhase`.
buildPhase =
''
export HOME="$TMP/fake-home"
mkdir -p "$HOME"
''
+ old.buildPhase or "";
});
};

defaultPackage = haskell-nix-flake.packages."unison-cli-main:exe:unison";
inherit checks devShells;

devShells = let
mkDevShell = pkgName:
shellFor {
packages = hpkgs: [hpkgs."${pkgName}"];
withHoogle = true;
};
in
{
only-tools = shellFor {
packages = _: [];
withHoogle = false;
};
local = shellFor {
packages = hpkgs: (map (p: hpkgs."${p}") localPackageNames);
withHoogle = false;
};
}
// lib.genAttrs localPackageNames mkDevShell;
}

0 comments on commit d483188

Please sign in to comment.