unison/flake.nix

140 lines
5.0 KiB
Nix
Raw Normal View History

2022-06-04 04:33:25 +03:00
{
2023-05-31 16:23:20 +03:00
description = "Unison";
nixConfig = {
extra-substituters = [ "https://unison.cachix.org" ];
2023-07-04 05:10:18 +03:00
extra-trusted-public-keys = [
"unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k="
2023-06-14 20:40:27 +03:00
];
2023-05-31 16:23:20 +03:00
};
2022-06-04 04:33:25 +03:00
inputs = {
2023-05-31 16:23:20 +03:00
haskellNix.url = "github:input-output-hk/haskell.nix";
nixpkgs.follows = "haskellNix/nixpkgs-unstable";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
2022-06-04 04:33:25 +03:00
flake-utils.url = "github:numtide/flake-utils";
2023-05-31 16:23:20 +03:00
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
2022-06-04 04:33:25 +03:00
};
outputs = { self, nixpkgs, flake-utils, haskellNix, flake-compat, nixpkgs-unstable }:
2023-05-31 16:23:20 +03:00
flake-utils.lib.eachSystem [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
2023-06-13 23:18:52 +03:00
]
(system:
let
versions = {
ghc = "928";
ormolu = "0.5.2.0";
hls = "2.4.0.0";
stack = "2.13.1";
hpack = "0.35.2";
};
2023-06-13 23:18:52 +03:00
overlays = [
haskellNix.overlay
(import ./nix/haskell-nix-overlay.nix)
(import ./nix/unison-overlay.nix)
2023-06-13 23:18:52 +03:00
];
pkgs = import nixpkgs {
inherit system overlays;
inherit (haskellNix) config;
};
haskell-nix-flake = import ./nix/haskell-nix-flake.nix {
inherit pkgs versions;
inherit (nixpkgs-packages) stack hpack;
};
unstable = import nixpkgs-unstable {
inherit system;
overlays = [
(import ./nix/unison-overlay.nix)
(import ./nix/nixpkgs-overlay.nix { inherit versions; })
];
};
nixpkgs-packages =
2023-06-13 23:18:52 +03:00
let
hpkgs = unstable.haskell.packages.ghcunison;
exe = unstable.haskell.lib.justStaticExecutables;
2023-06-13 23:18:52 +03:00
in
{
ghc = unstable.haskell.compiler."ghc${versions.ghc}";
ormolu = exe hpkgs.ormolu;
hls = unstable.unison-hls;
2023-11-17 19:31:37 +03:00
stack = unstable.unison-stack;
unwrapped-stack = unstable.stack;
hpack = unstable.hpack;
};
nixpkgs-devShells = {
2023-12-04 19:45:24 +03:00
only-tools-nixpkgs = unstable.mkShell {
name = "only-tools-nixpkgs";
2023-12-04 19:05:02 +03:00
buildInputs =
let
build-tools = with nixpkgs-packages; [
ghc
ormolu
hls
stack
hpack
];
native-packages = pkgs.lib.optionals pkgs.stdenv.isDarwin
2023-12-04 19:53:26 +03:00
(with unstable.darwin.apple_sdk.frameworks;
2023-12-04 19:05:02 +03:00
[ Cocoa ]);
2023-12-04 19:53:26 +03:00
c-deps = with unstable;
2023-12-04 19:05:02 +03:00
[ pkg-config zlib glibcLocales ];
in
build-tools ++ c-deps ++ native-packages;
shellHook = ''
export LD_LIBRARY_PATH=${pkgs.zlib}/lib:$LD_LIBRARY_PATH
'';
};
};
renameAttrs = fn: nixpkgs.lib.mapAttrs' (name: value: {
inherit value;
name = fn name;});
2023-06-13 23:18:52 +03:00
in
assert nixpkgs-packages.ormolu.version == versions.ormolu;
assert nixpkgs-packages.hls.version == versions.hls;
2023-11-17 19:31:37 +03:00
assert nixpkgs-packages.unwrapped-stack.version == versions.stack;
assert nixpkgs-packages.hpack.version == versions.hpack;
2023-11-17 00:50:58 +03:00
{
packages =
nixpkgs-packages
// renameAttrs (name: "component-${name}") haskell-nix-flake.packages
// renameAttrs (name: "docker-${name}") (import ./nix/docker.nix { inherit pkgs; haskell-nix = haskell-nix-flake.packages; })
// {
default = haskell-nix-flake.defaultPackage;
build-tools = pkgs.symlinkJoin {
name = "build-tools";
paths = self.devShells."${system}".only-tools-nixpkgs.buildInputs;
};
all = pkgs.symlinkJoin {
name = "all";
paths =
let
all-other-packages = builtins.attrValues (builtins.removeAttrs self.packages."${system}" [ "all" "build-tools" ]);
devshell-inputs = builtins.concatMap
(devShell: devShell.buildInputs ++ devShell.nativeBuildInputs)
[
self.devShells."${system}".only-tools-nixpkgs
];
in
all-other-packages ++ devshell-inputs;
};
};
apps = renameAttrs (name: "component-${name}") haskell-nix-flake.apps // {
default = self.apps."${system}"."component-unison-cli-main:exe:unison";
};
devShells =
nixpkgs-devShells
// renameAttrs (name: "cabal-${name}") haskell-nix-flake.devShells
// {
default = self.devShells."${system}".only-tools-nixpkgs;
};
formatter = pkgs.alejandra;
2023-06-13 23:18:52 +03:00
});
2022-06-04 04:33:25 +03:00
}