about summary refs log tree commit diff
path: root/flake.nix
blob: 83db9501470ec45c9a06b7d69d8ce28d9a4ca4cc (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
{
  description = "personal NixOS configurations";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";

    home-manager = {
      url = "github:nix-community/home-manager/release-24.11";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    darwin = {
      url = "github:lnl7/nix-darwin";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    flake-utils.url = "github:numtide/flake-utils";

    pre-commit-hooks = {
      url = "github:cachix/pre-commit-hooks.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    devshell = {
      url = "github:numtide/devshell";
      inputs.nixpkgs.follows = "nixpkgs";
    };

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

  # Output config, or config for NixOS system
  outputs =
    { nixpkgs
    , darwin
    , flake-utils
    , pre-commit-hooks
    , devshell
    , agenix
    , ...
    }@inputs:
    flake-utils.lib.eachDefaultSystem
      (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [ devshell.overlays.default ];
        };

      in
      {
        checks = {
          pre-commit-check = pre-commit-hooks.lib.${system}.run {
            src = ./.;
            hooks = {
              nixpkgs-fmt.enable = true;
              check-merge-conflicts.enable = true;
              end-of-file-fixer.enable = true;
            };
          };
        };

        devShells.default = pkgs.devshell.mkShell {
          packages = with pkgs; [
            just
            agenix
            inputs.agenix.packages."${system}".default
          ];
          env = [{
            name = "DEVSHELL_NO_MOTD";
            value = "1";
          }];
        };

      }) // (flake-utils.lib.eachDefaultSystemPassThrough (system:
    let
      mkSystem = import ./nix/lib/mkSystem.nix { inherit nixpkgs inputs; };
    in
    {

      # a VM running on the MacBook Air
      nixosConfigurations.vm-aarch64 = mkSystem "vm-aarch64" {
        system = "aarch64-linux";
        user = "fcuny";
      };

      # a VM running on the synology DS923+
      nixosConfigurations.vm-synology = mkSystem "vm-synology" {
        system = "x86_64-linux";
        user = "fcuny";
      };

      # a VM running on hetzner cloud
      nixosConfigurations.vm-hetzner = mkSystem "vm-hetzner" {
        system = "x86_64-linux";
        user = "fcuny";
      };

      # my personal MacBook Air
      darwinConfigurations.mba-m2 = mkSystem "mba-m2" {
        system = "aarch64-darwin";
        user = "fcuny";
        darwin = true;
      };

      # my work MacBook Pro
      darwinConfigurations.hq-c02fk3q7md6t = mkSystem "hq-c02fk3q7md6t" {
        system = "x86_64-darwin";
        user = "fcuny";
        darwin = true;
      };
    }));
}