unison/flake.nix
Greg Pfeil c3405c27b4
Pin Haskell tool versions for VS Code
This also has the flake get its version pins (when possible) from the VS
Code settings. And we pin Cabal now, too.
2024-07-09 13:57:42 -06:00

101 lines
3.4 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
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
## Its 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 doesnt 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 doesnt 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;
});
}