From f3f2592787976e573cd49d0c4b3e293ffe816ec3 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sun, 8 Dec 2024 19:42:52 +0530 Subject: [PATCH 1/7] nix: Test IFD using haskell-flake --- default.nix | 19 +++++++++++++++++++ flake.lock | 11 ++++++----- flake.nix | 2 +- nix/modules/flake-parts/haskell.nix | 1 + nix/modules/flake-parts/pre-commit.nix | 7 ++++++- 5 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..d17d05a --- /dev/null +++ b/default.nix @@ -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"; +} diff --git a/flake.lock b/flake.lock index 83243c9..9f662b0 100644 --- a/flake.lock +++ b/flake.lock @@ -53,15 +53,16 @@ }, "haskell-flake": { "locked": { - "lastModified": 1733021212, - "narHash": "sha256-rnEfkMDX94VKi07K+M5k+CvZJXDexpvXv5Hg29zZmxg=", - "owner": "srid", + "lastModified": 1733665041, + "narHash": "sha256-uh/VoMJaHE8s006gQ8K9Q+VnI6aoP+DRAMmevUSBksw=", + "owner": "rsrohitsingh682", "repo": "haskell-flake", - "rev": "c60351652c71ebeb5dd237f7da874412a7a96970", + "rev": "762a24ba5a3d85aaff25de6cc1ec16f8e587e13a", "type": "github" }, "original": { - "owner": "srid", + "owner": "rsrohitsingh682", + "ref": "cache-cabal2nix", "repo": "haskell-flake", "type": "github" } diff --git a/flake.nix b/flake.nix index 4d5e1cb..44bead2 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,7 @@ 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"; diff --git a/nix/modules/flake-parts/haskell.nix b/nix/modules/flake-parts/haskell.nix index 64fd871..e1ae311 100644 --- a/nix/modules/flake-parts/haskell.nix +++ b/nix/modules/flake-parts/haskell.nix @@ -17,6 +17,7 @@ (root + /haskell-template.cabal) (root + /LICENSE) (root + /README.md) + (root + /default.nix) ]; }); diff --git a/nix/modules/flake-parts/pre-commit.nix b/nix/modules/flake-parts/pre-commit.nix index 340ca8f..a1c5344 100644 --- a/nix/modules/flake-parts/pre-commit.nix +++ b/nix/modules/flake-parts/pre-commit.nix @@ -7,13 +7,18 @@ 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 = [ "default.nix" ]; + }; cabal-fmt.enable = true; fourmolu = { enable = true; package = config.fourmolu.wrapper; }; hlint.enable = true; + cabal2nix.enable = true; }; }; From 82bb0832a8167d0d0c942d1400491986314e07b9 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Tue, 10 Dec 2024 14:49:49 +0530 Subject: [PATCH 2/7] nix: bump git-hooks,haskell-flake to use option to set filename for `cabal2nix` expression; --- cabal.nix | 42 ++++++++++++++++++++++++++ flake.lock | 17 ++++++----- flake.nix | 2 +- nix/modules/flake-parts/haskell.nix | 7 ++++- nix/modules/flake-parts/pre-commit.nix | 7 +++-- 5 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 cabal.nix diff --git a/cabal.nix b/cabal.nix new file mode 100644 index 0000000..1d2eaa6 --- /dev/null +++ b/cabal.nix @@ -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"; +} diff --git a/flake.lock b/flake.lock index 9f662b0..1bdce11 100644 --- a/flake.lock +++ b/flake.lock @@ -38,26 +38,27 @@ "git-hooks": { "flake": false, "locked": { - "lastModified": 1733318908, - "narHash": "sha256-SVQVsbafSM1dJ4fpgyBqLZ+Lft+jcQuMtEL3lQWx2Sk=", - "owner": "cachix", + "lastModified": 1733744945, + "narHash": "sha256-IKEqpBW4mxRxVIu2EOJldp7gJYwxBN+yNZxoW0QhP2w=", + "owner": "rsrohitsingh682", "repo": "git-hooks.nix", - "rev": "6f4e2a2112050951a314d2733a994fbab94864c6", + "rev": "be16516ddd761e03509849c2d037925f826740cc", "type": "github" }, "original": { - "owner": "cachix", + "owner": "rsrohitsingh682", + "ref": "cabal2nix", "repo": "git-hooks.nix", "type": "github" } }, "haskell-flake": { "locked": { - "lastModified": 1733665041, - "narHash": "sha256-uh/VoMJaHE8s006gQ8K9Q+VnI6aoP+DRAMmevUSBksw=", + "lastModified": 1733821413, + "narHash": "sha256-1/I+745OA5msBChRdqooY5lh64vQ9pLhYVDXumjob64=", "owner": "rsrohitsingh682", "repo": "haskell-flake", - "rev": "762a24ba5a3d85aaff25de6cc1ec16f8e587e13a", + "rev": "81599f78edabade801f9fa6a445c9ea23b8ba01c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 44bead2..5a87a4b 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,7 @@ 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"; git-hooks.flake = false; }; diff --git a/nix/modules/flake-parts/haskell.nix b/nix/modules/flake-parts/haskell.nix index e1ae311..861d79b 100644 --- a/nix/modules/flake-parts/haskell.nix +++ b/nix/modules/flake-parts/haskell.nix @@ -17,7 +17,7 @@ (root + /haskell-template.cabal) (root + /LICENSE) (root + /README.md) - (root + /default.nix) + (root + /cabal.nix) ]; }); @@ -26,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) /* diff --git a/nix/modules/flake-parts/pre-commit.nix b/nix/modules/flake-parts/pre-commit.nix index a1c5344..a62ab8a 100644 --- a/nix/modules/flake-parts/pre-commit.nix +++ b/nix/modules/flake-parts/pre-commit.nix @@ -10,7 +10,7 @@ nixpkgs-fmt = { enable = true; # cabal2nix, nixpkgs-fmt both modifies default.nix, hence exlude fmt. - excludes = [ "default.nix" ]; + excludes = [ "cabal.nix" ]; }; cabal-fmt.enable = true; fourmolu = { @@ -18,7 +18,10 @@ package = config.fourmolu.wrapper; }; hlint.enable = true; - cabal2nix.enable = true; + cabal2nix = { + enable = true; + settings.output_filename = "cabal.nix"; + }; }; }; From c84c36cf4071aa51e7a254757e74e516cf8d2742 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Wed, 11 Dec 2024 00:41:01 +0530 Subject: [PATCH 3/7] fix: CI failure --- cabal.nix | 33 +++++---------------------------- default.nix | 19 ------------------- 2 files changed, 5 insertions(+), 47 deletions(-) delete mode 100644 default.nix diff --git a/cabal.nix b/cabal.nix index 1d2eaa6..d17d05a 100644 --- a/cabal.nix +++ b/cabal.nix @@ -1,18 +1,6 @@ -{ mkDerivation -, aeson -, async -, base -, data-default -, directory -, filepath -, lib -, mtl -, optics-core -, profunctors -, relude -, shower -, time -, with-utf8 +{ mkDerivation, aeson, async, base, data-default, directory +, filepath, lib, mtl, optics-core, profunctors, relude, shower +, time, with-utf8 }: mkDerivation { pname = "haskell-template"; @@ -21,19 +9,8 @@ mkDerivation { isLibrary = false; isExecutable = true; executableHaskellDepends = [ - aeson - async - base - data-default - directory - filepath - mtl - optics-core - profunctors - relude - shower - time - with-utf8 + 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"; diff --git a/default.nix b/default.nix deleted file mode 100644 index d17d05a..0000000 --- a/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ 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"; -} From 8ce9e69971eae6f020ec0b5dde378d792a8ba0eb Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sat, 21 Dec 2024 22:00:42 +0530 Subject: [PATCH 4/7] update git-hooks --- flake.lock | 17 ++++++++--------- flake.nix | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 1bdce11..3e32315 100644 --- a/flake.lock +++ b/flake.lock @@ -38,27 +38,26 @@ "git-hooks": { "flake": false, "locked": { - "lastModified": 1733744945, - "narHash": "sha256-IKEqpBW4mxRxVIu2EOJldp7gJYwxBN+yNZxoW0QhP2w=", - "owner": "rsrohitsingh682", + "lastModified": 1734797603, + "narHash": "sha256-ulZN7ps8nBV31SE+dwkDvKIzvN6hroRY8sYOT0w+E28=", + "owner": "cachix", "repo": "git-hooks.nix", - "rev": "be16516ddd761e03509849c2d037925f826740cc", + "rev": "f0f0dc4920a903c3e08f5bdb9246bb572fcae498", "type": "github" }, "original": { - "owner": "rsrohitsingh682", - "ref": "cabal2nix", + "owner": "cachix", "repo": "git-hooks.nix", "type": "github" } }, "haskell-flake": { "locked": { - "lastModified": 1733821413, - "narHash": "sha256-1/I+745OA5msBChRdqooY5lh64vQ9pLhYVDXumjob64=", + "lastModified": 1734580521, + "narHash": "sha256-jleFPA58o6HNiSwCF9r/JFk2W5QFyGtgE/6AWio13Nk=", "owner": "rsrohitsingh682", "repo": "haskell-flake", - "rev": "81599f78edabade801f9fa6a445c9ea23b8ba01c", + "rev": "792e3e8c7b77e6d716e40a9834dd414a7297e18c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 5a87a4b..44bead2 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,7 @@ haskell-flake.url = "github:rsrohitsingh682/haskell-flake/cache-cabal2nix"; fourmolu-nix.url = "github:jedimahdi/fourmolu-nix"; - git-hooks.url = "github:rsrohitsingh682/git-hooks.nix/cabal2nix"; + git-hooks.url = "github:cachix/git-hooks.nix"; git-hooks.flake = false; }; From 885c04ce71f7019023ed03716ac00d88035dac11 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sat, 21 Dec 2024 22:01:05 +0530 Subject: [PATCH 5/7] nix: use outputFile from config --- nix/modules/flake-parts/haskell.nix | 2 +- nix/modules/flake-parts/pre-commit.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nix/modules/flake-parts/haskell.nix b/nix/modules/flake-parts/haskell.nix index 861d79b..c60db35 100644 --- a/nix/modules/flake-parts/haskell.nix +++ b/nix/modules/flake-parts/haskell.nix @@ -30,7 +30,7 @@ # 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"; + haskell-template.cabal2NixFile = config.pre-commit.settings.hooks.cabal2nix.settings.outputFilename; # Add source or Hackage overrides here # (Local packages are added automatically) /* diff --git a/nix/modules/flake-parts/pre-commit.nix b/nix/modules/flake-parts/pre-commit.nix index a62ab8a..183c5f0 100644 --- a/nix/modules/flake-parts/pre-commit.nix +++ b/nix/modules/flake-parts/pre-commit.nix @@ -10,7 +10,7 @@ nixpkgs-fmt = { enable = true; # cabal2nix, nixpkgs-fmt both modifies default.nix, hence exlude fmt. - excludes = [ "cabal.nix" ]; + excludes = [ config.pre-commit.settings.hooks.cabal2nix.settings.outputFilename ]; }; cabal-fmt.enable = true; fourmolu = { @@ -20,7 +20,7 @@ hlint.enable = true; cabal2nix = { enable = true; - settings.output_filename = "cabal.nix"; + settings.outputFilename = "cabal.nix"; }; }; }; From e1fc560821b45b4ea4318e19594db22fb2519fd0 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sun, 22 Dec 2024 00:17:16 +0530 Subject: [PATCH 6/7] nix: Update haskell-flake --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 3e32315..b7fb226 100644 --- a/flake.lock +++ b/flake.lock @@ -53,11 +53,11 @@ }, "haskell-flake": { "locked": { - "lastModified": 1734580521, - "narHash": "sha256-jleFPA58o6HNiSwCF9r/JFk2W5QFyGtgE/6AWio13Nk=", + "lastModified": 1734803734, + "narHash": "sha256-5m2dE4Nj7p4iqWab0d9kTnc3NzMtJNklHWj1zvSggs4=", "owner": "rsrohitsingh682", "repo": "haskell-flake", - "rev": "792e3e8c7b77e6d716e40a9834dd414a7297e18c", + "rev": "54e75baf7c76c1589d71cba5319408a629ffc265", "type": "github" }, "original": { From 6bcabac01675d336ee06a67ef5e517c344625656 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Mon, 23 Dec 2024 19:01:11 +0530 Subject: [PATCH 7/7] nix: Update haskell-flake --- flake.lock | 11 +++++------ flake.nix | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index b7fb226..02d6180 100644 --- a/flake.lock +++ b/flake.lock @@ -53,16 +53,15 @@ }, "haskell-flake": { "locked": { - "lastModified": 1734803734, - "narHash": "sha256-5m2dE4Nj7p4iqWab0d9kTnc3NzMtJNklHWj1zvSggs4=", - "owner": "rsrohitsingh682", + "lastModified": 1734920822, + "narHash": "sha256-YQo6LBiVVT05AcznDtlMuJkigM04FKW+lXQ5uRuT1yQ=", + "owner": "srid", "repo": "haskell-flake", - "rev": "54e75baf7c76c1589d71cba5319408a629ffc265", + "rev": "d8a21e6d8c6c01416e20bc944d7157eaf39ae93c", "type": "github" }, "original": { - "owner": "rsrohitsingh682", - "ref": "cache-cabal2nix", + "owner": "srid", "repo": "haskell-flake", "type": "github" } diff --git a/flake.nix b/flake.nix index 44bead2..4d5e1cb 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,7 @@ 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:rsrohitsingh682/haskell-flake/cache-cabal2nix"; + haskell-flake.url = "github:srid/haskell-flake"; fourmolu-nix.url = "github:jedimahdi/fourmolu-nix"; git-hooks.url = "github:cachix/git-hooks.nix";