about summary refs log tree commit diff
path: root/flake.nix
blob: bfeb7eade5a88f89857ada11d2d3dc57872a10ce (plain)
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
{
  description = ''
    specimen, application and server configuration.
    enjoy! :)
  '';

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";

    agenix = {
      url = "github:ryantm/agenix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs =
    inputs@{
      self,
      nixpkgs,
      agenix,
    }:
    let
      inherit (nixpkgs) lib;

      name = "specimen";
      systems = [
        "x86_64-linux"
        "aarch64-linux"
      ];

      pkgsForSystem =
        system:
        import nixpkgs {
          inherit system;
          overlays = [ agenix.overlays.default ];
        };

      forAllSystems =
        f:
        lib.genAttrs systems (
          system:
          f {
            inherit system;
            pkgs = pkgsForSystem system;
          }
        );
    in
    {
      packages = forAllSystems (
        { system, pkgs }:
        {
          default = pkgs.callPackage ./application/. { };
        }
      );

      devShells = forAllSystems (
        { system, pkgs }:
        {
          default = pkgs.mkShell {
            buildInputs = with pkgs; [
              go
              gopls
              delve
              go-task
              golangci-lint
            ];
          };
        }
      );

      nixosModules.default = import ./application/module.nix;

      nixosConfigurations.${name} =
        let
          defaultSystem = "aarch64-linux";
          pkgs = pkgsForSystem defaultSystem;
        in
        lib.nixosSystem {
          system = defaultSystem;
          specialArgs = {
            inherit pkgs;
          } // inputs;
          modules = [
            ./configuration/configuration.nix
            self.nixosModules.default
            agenix.nixosModules.default
          ];
        };
    };
}