mirror of
https://github.com/unisonweb/unison.git
synced 2024-10-04 05:37:14 +03:00
c3405c27b4
This also has the flake get its version pins (when possible) from the VS Code settings. And we pin Cabal now, too.
101 lines
3.4 KiB
Nix
101 lines
3.4 KiB
Nix
{
|
||
description = "Unison";
|
||
|
||
nixConfig = {
|
||
extra-substituters = ["https://unison.cachix.org"];
|
||
extra-trusted-public-keys = ["unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k="];
|
||
};
|
||
|
||
inputs = {
|
||
haskellNix.url = "github:input-output-hk/haskell.nix";
|
||
nixpkgs-haskellNix.follows = "haskellNix/nixpkgs-unstable";
|
||
nixpkgs-release.url = "github:NixOS/nixpkgs/release-24.05";
|
||
flake-utils.url = "github:numtide/flake-utils";
|
||
};
|
||
|
||
outputs = {
|
||
self,
|
||
haskellNix,
|
||
nixpkgs-haskellNix,
|
||
nixpkgs-release,
|
||
flake-utils,
|
||
}:
|
||
flake-utils.lib.eachSystem [
|
||
"x86_64-linux"
|
||
"x86_64-darwin"
|
||
"aarch64-darwin"
|
||
]
|
||
(system: let
|
||
## It’s much easier to read from a JSON file than to have JSON import from some other file, so we extract some
|
||
## configuration from the VS Code settings to avoid duplication.
|
||
vscodeSettings = nixpkgs-release.lib.importJSON ./.vscode/settings.json;
|
||
versions =
|
||
vscodeSettings."haskell.toolchain"
|
||
## There are some things we want to pin that the VS Code Haskell extension doesn’t let us control.
|
||
// {
|
||
hpack = "0.35.2";
|
||
ormolu = "0.7.2.0";
|
||
};
|
||
pkgs = import nixpkgs-haskellNix {
|
||
inherit system;
|
||
inherit (haskellNix) config;
|
||
overlays = [
|
||
haskellNix.overlay
|
||
(import ./nix/dependencies.nix {inherit nixpkgs-release;})
|
||
];
|
||
};
|
||
unison-project = import ./nix/unison-project.nix {
|
||
inherit (nixpkgs-haskellNix) lib;
|
||
inherit (pkgs) haskell-nix;
|
||
};
|
||
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: {
|
||
inherit value;
|
||
name = fn name;
|
||
});
|
||
in
|
||
assert pkgs.stack.version == versions.stack;
|
||
assert pkgs.hpack.version == versions.hpack; {
|
||
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;
|
||
all = pkgs.symlinkJoin {
|
||
name = "all";
|
||
paths = let
|
||
all-other-packages =
|
||
builtins.attrValues (builtins.removeAttrs self.packages."${system}" [
|
||
"all"
|
||
"docker-ucm" # this package doesn’t produce a directory
|
||
]);
|
||
devshell-inputs =
|
||
builtins.concatMap
|
||
(devShell: devShell.buildInputs ++ devShell.nativeBuildInputs)
|
||
(builtins.attrValues self.devShells."${system}");
|
||
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 =
|
||
renameAttrs (name: "cabal-${name}") haskell-nix-flake.devShells
|
||
// {default = self.devShells."${system}".cabal-local;};
|
||
|
||
checks = renameAttrs (name: "component-${name}") haskell-nix-flake.checks;
|
||
|
||
formatter = pkgs.alejandra;
|
||
});
|
||
}
|