Skip to content
Snippets Groups Projects
flake.nix 2.96 KiB
Newer Older
  • Learn to ignore specific revisions
  • chrg's avatar
    chrg committed
    {
      inputs = {
        nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable;
        flake-utils.url = github:numtide/flake-utils;
    
    chrg's avatar
    chrg committed
        nix-filter.url = github:numtide/nix-filter;
    
    chrg's avatar
    chrg committed
        language-c = {
          url = github:kalhauge/language-c;
          flake = false;
        };
    
    chrg's avatar
    chrg committed
        hspec-glitter.url = github:kalhauge/hspec-glitter;
    
    chrg's avatar
    chrg committed
      };
    
    chrg's avatar
    chrg committed
      outputs = {
        self,
        nixpkgs,
        flake-utils,
    
    chrg's avatar
    chrg committed
        nix-filter,
    
    chrg's avatar
    chrg committed
        ...
      } @ inputs: let
    
    chrg's avatar
    chrg committed
        load = p: n:
          p.callCabal2nixWithOptions n (nix-filter.lib {root = "${self}/${n}";}) "" {};
    
    
    chrg's avatar
    chrg committed
        packages = lib: p: {
    
    chrg's avatar
    chrg committed
          "language-c" = lib.dontCheck (p.callCabal2nixWithOptions "language-c" inputs.language-c "" {});
    
    chrg's avatar
    chrg committed
          "hspec-glitter" = p.callCabal2nixWithOptions "hspec-glitter" inputs.hspec-glitter "" {};
    
    chrg's avatar
    chrg committed
          "rtree" = lib.dontCheck (load p "rtree");
          "rtree-c" = lib.dontCheck (load p "rtree-c");
    
    chrg's avatar
    chrg committed
        };
      in
    
    chrg's avatar
    chrg committed
        flake-utils.lib.eachDefaultSystem
    
    chrg's avatar
    chrg committed
        (system: let
    
    chrg's avatar
    chrg committed
          pkgs = import nixpkgs {
            inherit system;
    
    chrg's avatar
    chrg committed
            overlays = [];
    
    chrg's avatar
    chrg committed
          };
          lib = pkgs.haskell.lib;
    
    chrg's avatar
    chrg committed
          hpkgs = pkgs.haskellPackages.override (hpArgs: {
            overrides = pkgs.lib.composeExtensions (hpArgs.overrides or (_: _: {})) (
              _hfinal: hprev: packages lib hprev
            );
          });
        in {
    
    chrg's avatar
    chrg committed
          packages = {
    
    chrg's avatar
    chrg committed
            default = lib.justStaticExecutables (hpkgs.rtree-c);
    
    chrg's avatar
    chrg committed
            rtree = hpkgs.rtree;
    
    chrg's avatar
    chrg committed
            rtree-c = hpkgs.rtree-c;
    
    chrg's avatar
    chrg committed
          };
          devShells = let
    
    chrg's avatar
    chrg committed
            nativeBuildInputs = with hpkgs; [
    
    chrg's avatar
    chrg committed
              cabal-install
              ghcid
              haskell-language-server
              hpack
              fourmolu
            ];
            withHoogle = true;
    
    chrg's avatar
    chrg committed
            profiles = hpkgs.override (hpArgs: {
              overrides = pkgs.lib.composeExtensions (hpArgs.overrides or (_: _: {})) (
                _hfinal: hprev: {
                  mkDerivation = args:
                    hprev.mkDerivation ({
                        doCheck = false;
                        doBenchmark = false;
                        doHoogle = true;
                        doHaddock = true;
                        enableLibraryProfiling = true;
                        enableExecutableProfiling = true;
                      }
                      // args);
                  aeson = hprev.aeson.override {
                    mkDerivation = args:
                      hprev.mkDerivation (
                        args
                        // {
                          doCheck = false;
                          enableExecutableProfiling = false;
                        }
                      );
                  };
                }
              );
            });
    
    chrg's avatar
    chrg committed
          in {
    
    chrg's avatar
    chrg committed
            rtree = hpkgs.rtree;
    
    chrg's avatar
    chrg committed
            default =
    
    chrg's avatar
    chrg committed
              profiles.shellFor
    
    chrg's avatar
    chrg committed
              {
    
    chrg's avatar
    chrg committed
                name = "rtree-shells";
    
                packages = p: [
    
    chrg's avatar
    chrg committed
                  (lib.doCheck p.rtree)
                  (lib.doCheck p.rtree-c)
    
    chrg's avatar
    chrg committed
                doBenchmark = true;
    
    chrg's avatar
    chrg committed
                genericBuilderArgsModifier = args:
                  args
                  // {
                    doCheck = true;
                    doBenchmark = true;
                  };
    
    chrg's avatar
    chrg committed
                inherit nativeBuildInputs withHoogle;
    
    chrg's avatar
    chrg committed
              };
    
    chrg's avatar
    chrg committed
          };
        });
    
    chrg's avatar
    chrg committed
    }