~cyplo/dotfiles

dotfiles/flake.nix -rw-r--r-- 7.9 KiB
2f38c023 — Cyryl Płotnicki fix permissions for mastodon user 4 days ago
                                                                                
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
{
  description = "NixOS configuration with flakes";
  outputs = { self, flake-utils, flake-compat, home-manager
    , nixpkgs-nixos-unstable, nixpkgs-master, nixpkgs-stable, darwin
    , nixos-hardware, nur, sops, nil }@inputs:

    let
      mkServer = pkgs: system: hostname:
        pkgs.lib.nixosSystem {
          inherit system;
          modules = [
            (./. + "/nixos/boxes/${hostname}")
            (import ./nixos/server-common.nix)
            sops.nixosModules.sops
          ];
          specialArgs = { inherit inputs; };
        };
      mkRaspi = pkgs: hostname:
        pkgs.lib.nixosSystem {
          system = "aarch64-linux";
          modules = [ (./. + "/nixos/boxes/${hostname}") ];
          specialArgs = { inherit inputs; };
        };
      mkKiosk = pkgs: system: hostname:
        pkgs.lib.nixosSystem {
          inherit system;
          modules = [
            (./. + "/nixos/boxes/${hostname}")

            sops.nixosModules.sops

            home-manager.nixosModules.home-manager
            {
              home-manager.useGlobalPkgs = true;
              home-manager.useUserPackages = true;
              home-manager.users.cyryl = {
                imports =
                  [ ./nixos/home-manager ./nixos/home-manager/linux.nix ];
                _module.args.inputs = inputs;
              };
            }

          ];
          specialArgs = { inherit inputs system; };
        };
      mkWorkstation = pkgs: system: hostname:
        pkgs.lib.nixosSystem {
          inherit system;
          modules = [
            (./. + "/nixos/boxes/${hostname}")
            (import ./nixos/email-accounts.nix)
            (import ./nixos/common.nix)
            sops.nixosModules.sops

            home-manager.nixosModules.home-manager
            {
              home-manager.useGlobalPkgs = true;
              home-manager.useUserPackages = true;
              home-manager.users.cyryl = {
                imports =
                  [ ./nixos/home-manager ./nixos/home-manager/linux.nix ];
                _module.args.inputs = inputs;
                _module.args.system = system;
              };
            }

          ];
          specialArgs = {
            inherit inputs system;
            nixpkgs-nixos-stable-and-unfree = import nixpkgs-stable {
              inherit system;
              config = { allowUnfree = true; };
            };
            nixpkgs-nixos-unstable-and-unfree = import nixpkgs-nixos-unstable {
              inherit system;
              config = { allowUnfree = true; };
            };
          };
        };
      mkShell = packageSet: system:
        let pkgs = packageSet.legacyPackages.${system};
        in pkgs.mkShell {
          packages = with pkgs; [
            cacert
            git
            nixpkgs-fmt
            openssh
            openssl
            pkg-config
            statix
          ];
        };
    in {
      devShells = {
        "x86_64-darwin".default = mkShell nixpkgs-stable "x86_64-darwin";
        "x86_64-linux".default = mkShell nixpkgs-stable "x86_64-linux";
      };
      darwinConfigurations = {
        "FORM3-CYRYLPLOTN" = darwin.lib.darwinSystem rec {
          system = "x86_64-darwin";
          modules = [
            (./. + "/nixos/boxes/form3")
            home-manager.darwinModules.home-manager
            {
              home-manager.useGlobalPkgs = true;
              home-manager.useUserPackages = true;
              home-manager.users.cyryl = {
                imports = [ ./nixos/home-manager ];
                _module.args.inputs = inputs;
                _module.args.system = system;
              };
            }
          ];
        };
      };

      nixosConfigurations = {
        foureighty = mkWorkstation nixpkgs-stable "x86_64-linux" "foureighty";
        skinnyv = mkWorkstation nixpkgs-stable "x86_64-linux" "skinnyv";
        thinky = mkWorkstation nixpkgs-stable "x86_64-linux" "thinky";
        bolty = mkServer nixpkgs-stable "x86_64-linux" "bolty";
        vultr1 = mkServer nixpkgs-stable "x86_64-linux" "vultr1";
        vpsfree1 = mkServer nixpkgs-stable "x86_64-linux" "vpsfree1";
        yoga = mkKiosk nixpkgs-stable "x86_64-linux" "yoga";
        homescreen = mkRaspi nixpkgs-stable "homescreen";

        bootstrap = nixpkgs-stable.lib.nixosSystem rec {
          system = "x86_64-linux";
          modules = [ (./. + "/nixos/boxes/bootstrap") ];
          specialArgs = {
            inherit inputs system;
            nixpkgs-nixos-unstable-and-unfree = import nixpkgs-nixos-unstable {
              inherit system;
              config = { allowUnfree = true; };
            };
          };
        };
        # nix build .#nixosConfigurations.raspiimage.config.system.build.sdImage
        # sudo dd if=result/sd-image/nixos-sd-image-21.11.20211201.a640d83-aarch64-linux.img of=/dev/sda bs=4M conv=fsync status=progress
        # make sure to update eeprom https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_4#Board-specific_installation_notes
        raspiimage = nixpkgs-stable.lib.nixosSystem {
          system = "aarch64-linux";
          modules = [
            (import
              "${inputs.nixpkgs-nixos-unstable}/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix")
            {
              environment.systemPackages =
                with nixpkgs-nixos-unstable.legacyPackages."aarch64-linux"; [
                  neovim
                  htop
                  btop
                  atop
                ];

              networking.networkmanager.enable = false;
              hardware.enableRedistributableFirmware = true;
              networking.wireless.enable = true;

              services.openssh = {
                enable = true;
                permitRootLogin =
                  nixpkgs-stable.lib.mkForce "prohibit-password";
                passwordAuthentication = false;
              };

              services.xserver = {
                enable = true;
                displayManager.lightdm.enable = true;
                desktopManager.gnome.enable = true;
                libinput.enable = true;
              };

              users.extraUsers.root.openssh.authorizedKeys.keys = [
                "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEo4R+6J3h6Ix3xWpOMdU7Es1/YxFchHw0c+kcCOJxFb cyryl@foureighty"
              ];
              sdImage.compressImage = false;
              console.earlySetup = true;
            }
          ];
          specialArgs = { inherit inputs; };
        };
      };
    };
  inputs = {
    nixpkgs-master = {
      type = "github";
      owner = "NixOS";
      repo = "nixpkgs";
      ref = "master";
    };

    nixpkgs-nixos-unstable = {
      type = "github";
      owner = "NixOS";
      repo = "nixpkgs";
      ref = "nixos-unstable";
    };

    nixpkgs-stable = {
      type = "github";
      owner = "NixOS";
      repo = "nixpkgs";
      ref = "nixos-22.05";
    };

    nixos-hardware = {
      type = "github";
      owner = "NixOS";
      repo = "nixos-hardware";
      ref = "master";
    };

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

    home-manager = {
      type = "github";
      owner = "nix-community";
      repo = "home-manager";
      ref = "release-22.05";
      inputs.nixpkgs.follows = "nixpkgs-stable";
    };

    flake-utils = {
      type = "github";
      owner = "numtide";
      repo = "flake-utils";
      ref = "master";
    };

    nur = {
      type = "github";
      owner = "nix-community";
      repo = "NUR";
      ref = "master";
    };

    nil = {
      type = "github";
      owner = "oxalica";
      repo = "nil";
      ref = "main";
      inputs.nixpkgs.follows = "nixpkgs-nixos-unstable";
      inputs.flake-utils.follows = "flake-utils";
    };

    sops = {
      type = "github";
      owner = "Mic92";
      repo = "sops-nix";
      ref = "master";
      inputs.nixpkgs.follows = "nixpkgs-stable";
    };

    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
  };

}