summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
authortzlil <tzlils@protonmail.com>2023-10-02 02:25:33 +0300
committertzlil <tzlils@protonmail.com>2023-10-02 02:25:33 +0300
commitee9aa9ea4b9f597ad897d0b883111f0c99268118 (patch)
tree3bc3819a57994bd063cccac338d288a664381ad9 /flake.nix
initial commit HEAD master
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix60
1 files changed, 60 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..e8c1464
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,60 @@
+
+{
+  inputs = {
+    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+
+    flake-utils = {
+      url = "github:numtide/flake-utils";
+    };
+  };
+
+  outputs = { flake-utils, nixpkgs, self }:
+    flake-utils.lib.eachDefaultSystem
+      (system:
+        let
+          config = {};
+
+          overlays = [
+            # This is an overlay we apply on top of Nixpkgs with some of our
+            # own packages defined.
+            (final: prev: {
+              # A Haskell package set with our own overrides and packages defined.
+              myHaskellPackages = final.haskellPackages.override {
+                overrides = hfinal: hprev: {
+                  # This is our local Haskell package.
+                  package =
+                    hfinal.callCabal2nix "package" ./. {};
+                };
+              };
+
+              # This is just a convenient shortcut to our package from the
+              # top-level of Nixpkgs.  We're also applying the
+              # justStaticExecutables function to our package in order to
+              # reduce the size of the output derivation.
+              package =
+                final.haskell.lib.compose.justStaticExecutables
+                  final.myHaskellPackages.package;
+
+              # A Haskell development shell for our package that includes
+              # things like cabal and HLS.
+              myDevShell = final.myHaskellPackages.shellFor {
+                packages = p: [ p.package ];
+
+                nativeBuildInputs = [
+                  final.cabal-install
+                  final.haskellPackages.haskell-language-server
+                ];
+              };
+            })
+          ];
+
+          # Our full Nixpkgs with the above overlay applied.
+          pkgs = import nixpkgs { inherit config overlays system; };
+        in
+        {
+          packages.default = pkgs.package;
+
+          devShells.default = pkgs.myDevShell;
+        }
+      );
+}