Skip to content
Snippets Groups Projects
flake.nix 2.37 KiB
Newer Older
  • Learn to ignore specific revisions
  •   description = "gbs-downloader";
    
    
      inputs = {
        # Nix Inputs
        nixpkgs.follows = "hs-flake-utils/nixpkgs";
        flake-utils.url = github:numtide/flake-utils;
        hs-flake-utils.url = "git+https://whetstone.private.storage/jcalderone/hs-flake-utils.git?ref=main";
      };
    
      outputs = {
        self,
        nixpkgs,
        flake-utils,
        hs-flake-utils,
      }: let
        ulib = flake-utils.lib;
        ghcVersion = "ghc8107";
      in
        ulib.eachSystem ["x86_64-linux" "aarch64-darwin"] (system: let
          # Get a nixpkgs customized for this system and including our overlay.
          pkgs = import nixpkgs {
            inherit system;
          };
          hslib = hs-flake-utils.lib {
            inherit pkgs;
            src = ./.;
            compilerVersion = ghcVersion;
    
            packageName = "gbs-downloader";
    
            hsPkgsOverrides = import ./nix/haskell-packages.nix {
              haskellLib = pkgs.haskell.lib;
            };
    
          };
        in {
          checks = hslib.checks {};
    
          devShells = hslib.devShells {
            extraBuildInputs = pkgs:
              with pkgs; [
    
                # We configure cabal to use zlib:pkg-config so we better supply
                # pkg-config in the dev shell or `cabal ...` builds will surely
                # fail.
                pkg-config
    
                # And also that pesky zlib dependency.
    
          packages = hslib.packages {};
          apps.hlint = hslib.apps.hlint {};
    
          # Using the working directory of `nix run`, do a build with cabal and
          # then run the test suite.
          apps.cabal-test = {
            type = "app";
            program = "${
              pkgs.writeShellApplication {
                name = "cabal-build-and-test";
    
                # Only put packages with things that need to be on PATH here
    
    Jean-Paul Calderone's avatar
    Jean-Paul Calderone committed
                # because that's all that runtimeInputs buys us.  Packages with
    
                # different requirements need to be handled differently.
                runtimeInputs = with pkgs; [
                  pkg-config
                  haskell.compiler.${ghcVersion}
                  cabal-install
                ];
    
                  # Here we make zlib discoverable by pkg-config so cabal can find
                  # headers and stuff.
                  export PKG_CONFIG_PATH=${pkgs.lib.makeSearchPath "lib/pkgconfig" [pkgs.zlib.dev]}
    
    
                  cabal update hackage.haskell.org
    
                '';
              }
            }/bin/cabal-build-and-test";
          };
        });
    }