about summary refs log tree commit diff
path: root/flake.nix
blob: c3561cd163d033fd01271aeda43c1554b705c77d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
  description = "Personal XMonad configuration.";

  inputs = {
    nixpkgs = {
      type = "github";
      owner = "NixOS";
      repo = "nixpkgs";
      ref = "nixpkgs-unstable";
    };

    flake-utils = {
      type = "github";
      owner = "numtide";
      repo = "flake-utils";
      ref = "master";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = inputs:
    with inputs; let
      name = "xmonad-ng";
    in
      flake-utils.lib.eachSystem ["x86_64-linux"] (system: let
        pkgs = import nixpkgs {inherit system;};

        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.default = haskellPackages.${name};

        devShells.default = with haskellPackages;
          shellFor {
            nativeBuildInputs = [
              brittany
              cabal-install
              haskell-language-server
              hpack
              stack
            ];
            packages = p: [p.${name}];
          };

        formatter = pkgs.alejandra;
      })
      // {
        overlays.default = final: prev: {
          # TODO Figure out how to generalise the system here.
          ${name} = packages.default."x86_64-linux";
        };
      };
}

Consider giving Nix/NixOS a try! <3