Skip to content
Snippets Groups Projects
flake.nix 1.84 KiB
Newer Older
{
  description = "Horizon Haskell: Moon Base";

  inputs = {
    get-flake.url = "github:ursi/get-flake";

    horizon-shell-flake = {
      url = "git+https://gitlab.horizon-haskell.net/shells/horizon-shell";
      flake = false;
    };

    horizon-platform.url = "git+https://gitlab.horizon-haskell.net/package-sets/horizon-platform";

    lint-utils.url = "git+https://gitlab.homotopic.tech/nix/lint-utils";

    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = inputs@
    { self
    , flake-utils
    , get-flake
    , horizon-shell-flake
    , horizon-platform
    , lint-utils
    , nixpkgs
    , ...
    }:
    flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
      let
        pkgs = import nixpkgs { inherit system; };
      in
      with pkgs.lib;
      let
        horizon-shell = get-flake horizon-shell-flake;

        overrides = composeManyExtensions [
          (import ./overlay.nix { inherit pkgs; })
        ];

        legacyPackages = horizon-platform.legacyPackages.${system}.override {
          inherit overrides;
        };

        packages = filterAttrs
          (n: v: v != null
            && builtins.typeOf v == "set"
            && pkgs.lib.hasAttr "type" v
            && v.type == "derivation"
            && v.meta.broken == false)
          legacyPackages;

        devShell = pkgs.mkShell {
          buildInputs = [
            horizon-shell.packages.${system}.default
          ];
          shellHook = ''
            horizon-shell
            exit
          '';
        };

      in
      {
        checks = with lint-utils.outputs.linters.${system}; {
          dhall-format = dhall-format { src = self; };
          nixpkgs-fmt = nixpkgs-fmt { src = self; };
        };

        devShells.default = devShell;

        inherit legacyPackages;
        inherit overrides;
        inherit packages;
      });
}