From 51c91a0b9bb35d70bd8f1cf4c258562096e2375e Mon Sep 17 00:00:00 2001 From: kiana-S Date: Mon, 20 Dec 2021 00:58:35 -0500 Subject: [PATCH] Add Nix flake support --- flake.lock | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 45 +++++++++++++++++++++++++++++++++++++++++ shell.nix | 8 ++++++++ 3 files changed, 112 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 shell.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e15f5a8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,59 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1627913399, + "narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1638122382, + "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1639867199, + "narHash": "sha256-Ozed2PjzlgVvztj8QD6OtAjhgvi7nWbWFWz2Slq2tYI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "487bb1b1e232015fe4732880389f2fa664f812fc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..aa0ad4f --- /dev/null +++ b/flake.nix @@ -0,0 +1,45 @@ +# SPDX-FileCopyrightText: 2021 Serokell +# +# SPDX-License-Identifier: CC0-1.0 + +{ + description = "My haskell application"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + + flake-compat.url = "github:edolstra/flake-compat"; + flake-compat.flake = false; + }; + + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + haskellPackages = pkgs.haskellPackages; + + jailbreakUnbreak = pkg: + pkgs.haskell.lib.doJailbreak (pkg.overrideAttrs (_: { meta = { }; })); + + # DON'T FORGET TO PUT YOUR PACKAGE NAME HERE, REMOVING `throw` + packageName = "conways-game-of-life"; + in { + packages.${packageName} = + haskellPackages.callCabal2nix packageName self rec { + # Dependency overrides go here + }; + + defaultPackage = self.packages.${system}.${packageName}; + + devShell = pkgs.mkShell { + buildInputs = with haskellPackages; [ + ghcid + cabal-install + hlint + ]; + inputsFrom = builtins.attrValues self.packages.${system}; + }; + }); +} \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..81e3286 --- /dev/null +++ b/shell.nix @@ -0,0 +1,8 @@ +(import ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } +) { src = ./.; }).shellNix \ No newline at end of file