summary refs log tree commit diff stats
path: root/flake.nix
blob: 41e8a2f1f9646ab6a3a22b98ce0128b75fb471e5 (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
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
134
135
136
{
  description = "Nixos server config";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small";
    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable-small";

    # inputs for following
    systems = {
      url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
    };
    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
    crane = {
      url = "github:ipetkov/crane";
      inputs = {};
    };
    flake-utils = {
      url = "github:numtide/flake-utils";
      inputs = {
        systems.follows = "systems";
      };
    };
    rust-overlay = {
      url = "github:oxalica/rust-overlay";
      inputs = {
        nixpkgs.follows = "nixpkgs";
      };
    };

    # modules
    disko = {
      url = "github:nix-community/disko";
      inputs = {
        nixpkgs.follows = "nixpkgs";
      };
    };
    agenix = {
      url = "github:ryantm/agenix";
      inputs = {
        nixpkgs.follows = "nixpkgs";
        systems.follows = "systems";
      };
    };
    impermanence = {
      url = "github:nix-community/impermanence";
      inputs = {};
    };
    simple-nixos-mailserver = {
      url = "gitlab:simple-nixos-mailserver/nixos-mailserver/master";
      inputs = {
        flake-compat.follows = "flake-compat";
        nixpkgs.follows = "nixpkgs";
      };
    };

    # bins
    ragenix = {
      url = "github:yaxitech/ragenix";
      inputs = {
        nixpkgs.follows = "nixpkgs";
        agenix.follows = "agenix";
        flake-utils.follows = "flake-utils";
        rust-overlay.follows = "rust-overlay";
        crane.follows = "crane";
      };
    };
  };

  outputs = {
    self,
    nixpkgs,
    nixpkgs-unstable,
    # modules
    simple-nixos-mailserver,
    impermanence,
    disko,
    agenix,
    # bins
    ragenix,
    ...
  } @ attrs: let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages.${system};
    nixos-lib = import (nixpkgs + "/nixos/lib") {};
    pkgsUnstable = nixpkgs-unstable.legacyPackages.${system};

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

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

    inherit (pkgs) lib;
    tests = import ./tests.nix {inherit lib pkgs specialArgs;};
  in {
    nixosConfigurations."server1" = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      inherit specialArgs;
      modules =
        extraModules
        ++ [
          ./modules/nixos
          ./hosts/server1/configuration.nix
        ];
    };

    checks."${system}" = tests;

    devShells."${system}" = {
      default = pkgs.mkShell {
        packages = with pkgs; [
          alejandra

          # used for certificate generation in the taskserver setup
          gnutls

          git-bug

          cocogitto
          # ragenix.packages."${system}".default
        ];
      };
    };
    formatter."${system}" = pkgs.alejandra;
  };
}