aboutsummaryrefslogtreecommitdiffstats
path: root/flake.nix
blob: 23e773f2505ebd9e1ab126208806fdffbe03d7d7 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
  description = "NixOS server config";

  inputs = {};

  outputs = {self, ...} @ attrs: let
    sources = import ./unflake.nix;

    inherit (sources) nixpkgs;
    inherit (sources) nixpkgs-unstable;
    inherit (sources) library;
    inherit (sources) treefmt-nix;
    inherit (sources) deploy-rs;
    # modules
    inherit (sources) agenix;
    inherit (sources) turtle;
    inherit (sources) disko;
    inherit (sources) impermanence;
    inherit (sources) simple-nixos-mailserver;
    inherit (sources) rocie;

    system = "x86_64-linux";

    nixos-lib = import (nixpkgs + "/nixos/lib") {};
    pkgs = nixpkgs.legacyPackages.${system};
    pkgsUnstable = nixpkgs-unstable.legacyPackages.${system};

    specialArgs =
      attrs
      // {
        inherit
          pkgsUnstable
          vhackPackages
          nixpkgs-unstable
          nixos-lib
          extraModules
          nixLib
          turtle
          ;
      };

    extraModules = [
      agenix.nixosModules.default
      turtle.nixosModules.nixos
      disko.nixosModules.default
      impermanence.nixosModules.impermanence
      simple-nixos-mailserver.nixosModule
      rocie.nixosModules.default
    ];

    deployChecks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
    tests = pkgs.lib.attrsets.filterAttrs (_: v: !(v ? meta && v.meta.broken)) (import ./tests {inherit pkgs specialArgs nixLib;});
    vhackPackages = import ./pkgs {inherit pkgs nixLib pkgsUnstable;};

    hosts = import ./hosts {inherit self deploy-rs pkgs nixLib nixpkgs specialArgs extraModules;};

    inherit (library) nixLib;
    treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
  in {
    checks."${system}" =
      nixLib.warnMerge deployChecks."${system}" (nixLib.warnMerge tests {
        formatting = treefmtEval.config.build.check self;
      } "the flake checks and formatting")
      "the flake checks and deploy rs checks";

    packages."${system}" = vhackPackages;
    formatter."${system}" = treefmtEval.config.build.wrapper;

    devShells."${system}" = {
      default = pkgs.mkShell {
        packages = [
          pkgs.git-bug

          pkgs.deploy-rs

          # Used to update the stalwart-mail spamfilter
          pkgs.nix-update

          pkgs.cocogitto

          (agenix.packages."${system}".default.override {
            nix = pkgs.lixPackageSets.latest.lix;
          })
        ];
      };
    };

    deploy.nodes = hosts.nodes;

    inherit (hosts) nixosConfigurations;
  };
}