diff --git a/.envrc b/.envrc new file mode 100644 index 00000000000..3550a30f2de --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 8f1097ae8a1..733d44e8390 100644 --- a/.gitignore +++ b/.gitignore @@ -82,3 +82,4 @@ bench.html # Emacs .projectile +/.direnv/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 79db2f27b38..a726cb737c2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,6 +29,16 @@ cabal v2-build Cabal-tests:unit-tests # build Cabal's unit test suite cabal v2-build cabal-tests # etc... ``` +Building Cabal for hacking with Nix (not officially supported) +-------------------------- + +``` +nix develop # if you don't have direnv installed +cabal build cabal +``` + +NOTE: Building the cabal library with nix flakes is not officially supported and as such may fall out of date. Be prepared to tweak it and please contribute fixes back. + Running tests ------------- diff --git a/changelog.d/pr-8753 b/changelog.d/pr-8753 new file mode 100644 index 00000000000..918aa965c6b --- /dev/null +++ b/changelog.d/pr-8753 @@ -0,0 +1,3 @@ +synopsis: add nix flake for easier contribution for nix users +packages: cabal-install +prs: #8753 diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000000..21300f44183 --- /dev/null +++ b/flake.lock @@ -0,0 +1,63 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1675933616, + "narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "47478a4a003e745402acf63be7f9a092d51b83d7", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1675942811, + "narHash": "sha256-/v4Z9mJmADTpXrdIlAjFa1e+gkpIIROR670UVDQFwIw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "724bfc0892363087709bd3a5a1666296759154b1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1675183161, + "narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000000..6e33f67dce0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,19 @@ +{ + description = "A devshell that enables nix users to just run `cabal build cabal` and start contributing to Cabal"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "aarch64-darwin" ]; + perSystem = { config, self', inputs', pkgs, system, ... }: { + packages.default = pkgs.lib.trace "This flake currently only contains a devshell for use with nix develop"; + devShells.default = pkgs.mkShell { + buildInputs = [ pkgs.ghc pkgs.cabal-install pkgs.zlib ]; + }; + }; + flake = {}; + }; +}