about summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2022-08-16 01:46:04 +0300
committerAzat Bahawi <azat@bahawi.net>2022-08-16 01:46:04 +0300
commit3cd06b22069c009b8c5fea2d5fad5f996667d2e3 (patch)
tree4b5f1cb453de13c560bc8aa5a57952713cf360aa /flake.nix
parentabsolute garbage wtf (diff)
huge update-o
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix126
1 files changed, 43 insertions, 83 deletions
diff --git a/flake.nix b/flake.nix
index 38edac0..c3561cd 100644
--- a/flake.nix
+++ b/flake.nix
@@ -16,98 +16,58 @@
       ref = "master";
       inputs.nixpkgs.follows = "nixpkgs";
     };
-
-    flake-compat = {
-      type = "github";
-      owner = "edolstra";
-      repo = "flake-compat";
-      ref = "master";
-      flake = false;
-    };
-
-    pre-commit-hooks = {
-      type = "github";
-      owner = "cachix";
-      repo = "pre-commit-hooks.nix";
-      ref = "master";
-      inputs = {
-        nixpkgs.follows = "nixpkgs";
-        flake-utils.follows = "flake-utils";
-      };
-    };
   };
 
   outputs = inputs:
-    with inputs;
-    let name = "xmonad-ng";
-    in flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
-      let
-        pkgs = import nixpkgs {
-          inherit system;
-          inputs = null;
-          nixpkgs = nixpkgs.legacyPackages.${system};
-        };
+    with inputs; let
+      name = "xmonad-ng";
+    in
+      flake-utils.lib.eachSystem ["x86_64-linux"] (system: let
+        pkgs = import nixpkgs {inherit system;};
 
-        package = { returnShellEnv ? false }:
-          with pkgs;
-          haskellPackages.developPackage {
-            inherit name returnShellEnv;
-            root = ./.;
-            overrides = _: _:
-              with haskellPackages; {
-                xmonad = xmonad_0_17_0;
-                xmonad-contrib = xmonad-contrib_0_17_0;
-              };
-            modifier = drv:
-              haskell.lib.addBuildTools drv (with haskellPackages; [
-                brittany
-                cabal-install
-                haskell-language-server
-                hlint
-                hpack
-                stack
-              ]);
+        haskellPackages = pkgs.haskellPackages.override {
+          overrides = _: super: {
+            ${name} = with pkgs.haskell.lib;
+              justStaticExecutables (
+                failOnAllWarnings (
+                  disableExecutableProfiling (
+                    disableLibraryProfiling (
+                      (pkgs.haskellPackages.developPackage {
+                        inherit name;
+                        root = inputs.self;
+                      })
+                      .overrideAttrs (_: _: {
+                        postInstall = ''
+                          rm -rf $out/share
+                        '';
+                      })
+                    )
+                  )
+                )
+              );
           };
+        };
       in {
-        packages.${name} = package { };
-        defaultPackage = self.packages.${system}.${name};
+        packages.default = haskellPackages.${name};
 
-        checks.preCommit = pre-commit-hooks.lib.${system}.run {
-          src = ./.;
-          hooks = {
-            nix-linter.enable = true;
-            nixfmt.enable = true;
-            hpack.enable = true;
-            hlint.enable = true;
-            yamllint.enable = true;
-            brittany.enable = true;
-            shellcheck.enable = true;
-            shfmt = {
-              enable = true;
-              name = "shfmt";
-              entry = "${pkgs.shfmt}/bin/shfmt -s -w";
-              types = [ "shell" ];
-            };
-            prettier = {
-              enable = true;
-              types = [ ];
-              files = "\\.((yaml)|\\d)$";
-            };
+        devShells.default = with haskellPackages;
+          shellFor {
+            nativeBuildInputs = [
+              brittany
+              cabal-install
+              haskell-language-server
+              hpack
+              stack
+            ];
+            packages = p: [p.${name}];
           };
-        };
 
-        devShells = {
-          ${name} = package { returnShellEnv = true; };
-          preCommit = pkgs.mkShell {
-            inherit (self.checks.${system}.preCommit) shellHook;
-          };
+        formatter = pkgs.alejandra;
+      })
+      // {
+        overlays.default = final: prev: {
+          # TODO Figure out how to generalise the system here.
+          ${name} = packages.default."x86_64-linux";
         };
-        devShell = self.devShells.${system}.${name};
-      }) // {
-        # FIXME This exposes an attribute set of "system.package" thus making
-        # importing this package from the overlay to look like this
-        # "pkgs.xmonad-ng.${system}" which is fucking stupid. I have to fix that
-        # somehow.
-        overlay = _: _: { ${name} = self.defaultPackage; };
       };
 }

Consider giving Nix/NixOS a try! <3