My NixOS config.
1{ description = "trespaul's nixos flake";
2
3 inputs =
4 { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
5 import-tree.url = "github:vic/import-tree";
6 ragenix =
7 { url = "github:yaxitech/ragenix";
8 inputs.nixpkgs.follows = "nixpkgs";
9 };
10 home-manager =
11 { url = "github:nix-community/home-manager";
12 inputs.nixpkgs.follows = "nixpkgs";
13 };
14 musnix =
15 { url = "github:musnix/musnix";
16 inputs.nixpkgs.follows = "nixpkgs";
17 };
18 deploy-rs =
19 { url = "github:serokell/deploy-rs";
20 inputs.nixpkgs.follows = "nixpkgs";
21 };
22 zen-browser =
23 { url = "github:mrcjkb/zen-browser-flake";
24 inputs.nixpkgs.follows = "nixpkgs";
25 };
26 };
27
28 outputs = inputs@{ self, nixpkgs, deploy-rs, ... }:
29 { nixosConfigurations =
30 let
31 mkConfig = hostname: custom: nixpkgs.lib.nixosSystem
32 { modules =
33 # all modules external and internal are imported automatically;
34 # they must be configured in `custom` config (given below in
35 # the machine attrs) or in machine-specific ./machines/….nix
36 [ { networking.hostName = hostname; }
37 # internal modules:
38 ( inputs.import-tree ./modules )
39 ( inputs.import-tree ./machines/${hostname} )
40 { inherit custom; }
41 # external:
42 inputs.ragenix.nixosModules.default
43 inputs.musnix.nixosModules.musnix
44 inputs.home-manager.nixosModules.home-manager
45 { home-manager =
46 { useGlobalPkgs = true;
47 useUserPackages = true;
48 extraSpecialArgs = { inherit (inputs) zen-browser; };
49 users.paul.imports =
50 [ inputs.ragenix.homeManagerModules.default ];
51 };
52 }
53 ];
54 };
55 in
56 builtins.mapAttrs mkConfig
57 # { hostname = custom };
58 { paulpad =
59 { headless = false; };
60 polyaenus =
61 { internet-sharing.enable = true;
62 # k3s = true;
63 };
64 metrodorus =
65 { acme = true; };
66 leontion =
67 {
68 # k3s = true;
69 kanidm.enable = true;
70 repo-watcher = true;
71 acme = true;
72 headless-pipewire.enable = true;
73 };
74 hermarchus =
75 { k3s = true; };
76 dionysius =
77 { k3s = true; };
78 };
79
80 deploy =
81 { remoteBuild = true;
82 nodes =
83 let
84 mkNode = hostname:
85 { name = hostname;
86 value =
87 { inherit hostname;
88 sshUser = "root";
89 fastConnection = true;
90 profiles.system.path =
91 deploy-rs.lib.x86_64-linux.activate.nixos
92 self.nixosConfigurations.${hostname};
93 };
94 };
95 in
96 builtins.listToAttrs <| builtins.map mkNode
97 [ "polyaenus"
98 "metrodorus"
99 "leontion"
100 "hermarchus"
101 "dionysius"
102 ];
103 };
104
105 checks = builtins.mapAttrs
106 ( system: deployLib: deployLib.deployChecks self.deploy )
107 deploy-rs.lib;
108 };
109}