Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions cabal.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ mkDerivation
, aeson
, async
, base
, data-default
, directory
, filepath
, lib
, mtl
, optics-core
, profunctors
, relude
, shower
, time
, with-utf8
}:
mkDerivation {
pname = "haskell-template";
version = "0.1.0.0";
src = ./.;
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [
aeson
async
base
data-default
directory
filepath
mtl
optics-core
profunctors
relude
shower
time
with-utf8
];
homepage = "https://srid.ca/haskell-template";
description = "A template for Haskell projects using Nix";
license = lib.licenses.mit;
mainProgram = "haskell-template";
}
19 changes: 19 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ mkDerivation, aeson, async, base, data-default, directory
, filepath, lib, mtl, optics-core, profunctors, relude, shower
, time, with-utf8
}:
mkDerivation {
pname = "haskell-template";
version = "0.1.0.0";
src = ./.;
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [
aeson async base data-default directory filepath mtl optics-core
profunctors relude shower time with-utf8
];
homepage = "https://srid.ca/haskell-template";
description = "A template for Haskell projects using Nix";
license = lib.licenses.mit;
mainProgram = "haskell-template";
}
22 changes: 12 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
nixos-unified.url = "github:srid/nixos-unified";
haskell-flake.url = "github:srid/haskell-flake";
haskell-flake.url = "github:rsrohitsingh682/haskell-flake/cache-cabal2nix";
fourmolu-nix.url = "github:jedimahdi/fourmolu-nix";

git-hooks.url = "github:cachix/git-hooks.nix";
git-hooks.url = "github:rsrohitsingh682/git-hooks.nix/cabal2nix";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to get all git-hooks.nix PRs merged.

git-hooks.flake = false;
};

Expand Down
6 changes: 6 additions & 0 deletions nix/modules/flake-parts/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
(root + /haskell-template.cabal)
(root + /LICENSE)
(root + /README.md)
(root + /cabal.nix)
];
});

Expand All @@ -25,6 +26,11 @@

# Packages to add on top of `basePackages`
packages = {
# For IFD-less evaluation, you can point to pre-generated `cabal2nix` expression
# here for each package,
# haskell-flake will use this file to build the package.
# By default haskell-flake refers to `cabal.nix`
haskell-template.cabal2NixFile = "cabal.nix";
# Add source or Hackage overrides here
# (Local packages are added automatically)
/*
Expand Down
10 changes: 9 additions & 1 deletion nix/modules/flake-parts/pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@
perSystem = { config, ... }: {
pre-commit.settings = {
hooks = {
nixpkgs-fmt.enable = true;
nixpkgs-fmt = {
enable = true;
# cabal2nix, nixpkgs-fmt both modifies default.nix, hence exlude fmt.
excludes = [ "cabal.nix" ];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
excludes = [ "cabal.nix" ];
excludes = [ config.pre-commit.settings.hooks.cabal2nix.settings.output_filename ];

(Or you could use the config from pre-commit module)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this was not needed. But I put it just for example.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your link is just going to this very conversation. I don't know what you are referring to.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am talking about this.

Screenshot 2024-12-11 at 12 56 31 AM

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you use it there? It'd be a cyclic dependency.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for haskell-flake. There are in total 3 places where I am using cabal.nix

  1. While setting output_filename for cabal2nix pre-commit
  2. While setting exclude for nixpkgs-fmt
  3. For haskell-flake to refer to the cachedcabal2nix file

In this particular case I was talking about 3.

ideally we can set at one place use it at all other places.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, you can just reuse the module option (3) in both the palces (1 & 2). Good idea.

};
cabal-fmt.enable = true;
fourmolu = {
enable = true;
package = config.fourmolu.wrapper;
};
hlint.enable = true;
cabal2nix = {
enable = true;
settings.output_filename = "cabal.nix";
};
};
};

Expand Down