all repos — searchix @ 2bec215d4ceeac341ad78ddf5f3667bf5cfb48c0

Search engine for NixOS, nix-darwin, home-manager and NUR users

flake.nix (view raw)

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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{
  description = "Search tool for options and packages in the NixOS ecosystem";

  inputs = {
    nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.zst";
    pre-commit-hooks = {
      url = "github:cachix/pre-commit-hooks.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    gomod2nix = {
      url = "github:nix-community/gomod2nix";
      inputs = {
        nixpkgs.follows = "nixpkgs";
      };
    };
    treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    simple-css = {
      url = "github:kevquirk/simple.css";
      flake = false;
    };
  };

  outputs =
    {
      self,
      nixpkgs,
      gomod2nix,
      pre-commit-hooks,
      treefmt-nix,
      simple-css,
    }:
    let
      supportedSystems = [
        "aarch64-darwin"
        "aarch64-linux"
        "x86_64-linux"
      ];

      forEachSupportedSystem =
        f:
        nixpkgs.lib.genAttrs supportedSystems (
          system:
          f {
            inherit system;
            pkgs = import nixpkgs {
              inherit system;
              overlays = [
                gomod2nix.overlays.default
              ];
            };
          }
        );

      treefmtEvalFor =
        pkgs:
        treefmt-nix.lib.evalModule pkgs {
          projectRootFile = "flake.nix";
          programs = {
            nixfmt = {
              enable = true;
              package = pkgs.nixfmt;
            };
            taplo.enable = true;
            prettier = {
              enable = true;
              package = pkgs.prettier;
            };
            sqlfluff.enable = true;
            sqlfluff.dialect = "sqlite";
          };
          settings.formatter = {
            taplo.excludes = [ "gomod2nix.toml" ];
          };
        };
    in
    {
      nixosModules = {
        web = import ./nix/modules self;
      };
      overlays = {
        default = _: prev: {
          searchix = self.packages.${prev.system}.default;
        };
      };

      packages = forEachSupportedSystem (
        { pkgs, system }:
        {
          css = pkgs.concatText "simple.css" [ "${simple-css}/simple.css" ];
          default = pkgs.callPackage ./nix/package.nix {
            inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
            css = "${simple-css}/simple.css";
          };
        }
      );

      formatter = forEachSupportedSystem ({ pkgs, ... }: (treefmtEvalFor pkgs).config.build.wrapper);

      devShells = forEachSupportedSystem (
        { pkgs, system }:
        {
          default = pkgs.callPackage ./nix/dev-shell.nix {
            pre-commit-check = {
              inherit (self.checks.${system}.pre-commit-check)
                shellHook
                enabledPackages
                ;
            };
            inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
          };
        }
      );

      checks = forEachSupportedSystem (
        { pkgs, system, ... }:
        {
          pre-commit-check = pre-commit-hooks.lib.${system}.run (
            import ./nix/pre-commit-checks.nix {
              inherit pkgs;
              treefmtEval = treefmtEvalFor pkgs;
            }
          );
          buildVersion = pkgs.testers.testVersion {
            package = self.packages.${system}.default;
            command = "searchix-web version";
          };
        }
      );
    };
}