Skip to content

Commit

Permalink
dev: switch to mainline devenv
Browse files Browse the repository at this point in the history
  • Loading branch information
sandydoo committed May 23, 2024
1 parent 56bbfa5 commit 78bd7f9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 34 deletions.
25 changes: 25 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ pkgs, lib, ghcVersion, getNix, ... }:

{
imports = [ ./git-hooks.nix ];

packages = [
pkgs.pkg-config

# Dependencies
pkgs.lzma
pkgs.zlib
pkgs.boost
pkgs.libsodium
(getNix { inherit pkgs; })

# Haskell
pkgs.stack
pkgs.haskell.compiler."ghc${ghcVersion}"
(pkgs.haskell-language-server.override { supportedGhcVersions = [ ghcVersion ]; })
]
++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Cocoa
pkgs.darwin.apple_sdk.frameworks.CoreServices
];
}
43 changes: 9 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@

# Try to use the same Nix version as cnix-store, if available.
getNix = { pkgs, haskellPackages ? pkgs.haskellPackages }:
haskellPackages.hercules-ci-cnix-store.nixPackage
or pkgs.nix;
haskellPackages.hercules-ci-cnix-store.nixPackage or pkgs.nix;

customHaskellPackages = { pkgs, haskellPackages }: rec {
cachix-api = haskellPackages.callCabal2nix "cachix-api" ./cachix-api {};
Expand All @@ -47,13 +46,6 @@
nix = getNix { inherit pkgs haskellPackages; };
};
};

preCommitHooks = {
cabal-fmt.enable = true;
hlint.enable = true;
ormolu.enable = true;
shellcheck.enable = true;
};
in
{
packages = forAllSystems (system:
Expand All @@ -72,44 +64,27 @@
default = pkgs.haskell.lib.justStaticExecutables cachix;
ci = self.devShells.${system}.default.ci;
release = pkgs.symlinkJoin { name = "release"; paths = builtins.attrValues release; };
devenv-up = self.devShells.${system}.default.config.procfileScript;
});

checks = forAllSystems (system: {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = preCommitHooks;
inherit ((import ./git-hooks.nix).pre-commit) hooks;
};
});

devShells = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};

packages = [
pkgs.lzma
pkgs.zlib
pkgs.boost
pkgs.stack
pkgs.pkg-config
pkgs.libsodium
(getNix { inherit pkgs; })
pkgs.haskell.compiler."ghc${ghcVersion}"
(pkgs.haskell-language-server.override { supportedGhcVersions = [ ghcVersion ]; })
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Cocoa
pkgs.darwin.apple_sdk.frameworks.CoreServices
];
in
rec {
default = devenv;

devenv = inputs.devenv.lib.mkShell {
{
default = inputs.devenv.lib.mkShell {
inherit inputs pkgs;
modules = [{
inherit packages;
pre-commit.hooks = preCommitHooks;
}];
modules = [
({ _module.args = { inherit ghcVersion getNix; }; })
./devenv.nix
];
};
}
);
Expand Down
8 changes: 8 additions & 0 deletions git-hooks.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
pre-commit.hooks = {
cabal-fmt.enable = true;
hlint.enable = true;
ormolu.enable = true;
shellcheck.enable = true;
};
}

0 comments on commit 78bd7f9

Please sign in to comment.