blob: 99bd1c623240503deadbbaafe41262e817dc73df [file] [log] [blame]
Skyler Grey1e2187f2023-03-03 22:45:10 +00001{
2 description = "A flake to deploy and configure Clicks' NixOS server";
3
Skyler Grey07584fb2023-05-01 21:37:13 +00004 inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
Skyler Grey061574c2023-05-01 21:39:24 +00005 inputs.flake-utils.url = "github:numtide/flake-utils";
Skyler Grey1e2187f2023-03-03 22:45:10 +00006 inputs.deploy-rs.url = "github:serokell/deploy-rs";
Skyler Grey07584fb2023-05-01 21:37:13 +00007 inputs.home-manager.url = "github:nix-community/home-manager/release-22.11";
Skyler Grey1e2187f2023-03-03 22:45:10 +00008
Skyler Greyfed0bb12023-05-01 21:42:03 +00009 inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs";
10 inputs.home-manager.inputs.utils.follows = "deploy-rs/utils";
11
Skyler Grey07584fb2023-05-01 21:37:13 +000012 outputs = { self, nixpkgs, deploy-rs, home-manager, ... }@inputs:
13 let
14 system = "x86_64-linux";
15 pkgs = import nixpkgs {
16 inherit system;
17 config.allowUnfree = true;
18 };
19 in
20 {
21 nixosConfigurations.clicks =
22 nixpkgs.lib.nixosSystem {
23 inherit system pkgs;
24 modules = [
25 ./default/configuration.nix
26 ./default/hardware-configuration.nix
27 ./modules/caddy.nix
28 ./modules/clamav.nix
29 ./modules/code-server.nix
30 ./modules/dnsmasq.nix
31 ./modules/doas.nix
32 ./modules/docker.nix
33 ./modules/ecryptfs.nix
34 ./modules/fail2ban.nix
35 ./modules/fuck.nix
36 ./modules/git.nix
Skyler Grey6f0f43d2023-05-03 15:01:05 +000037 ./modules/grafana.nix
Skyler Grey07584fb2023-05-01 21:37:13 +000038 ./modules/home-manager-users.nix
39 ./modules/kitty.nix
40 ./modules/mongodb.nix
41 ./modules/node.nix
42 ./modules/samba.nix
43 ./modules/tesseract.nix
44 {
45 users.mutableUsers = false;
46 }
47 ];
Skyler Grey4f3e6062023-03-04 01:29:29 +000048 };
Skyler Grey07584fb2023-05-01 21:37:13 +000049
50 deploy.nodes.clicks = {
51 sudo = "doas -u";
52 profiles = {
53 system = {
54 remoteBuild = true;
55 user = "root";
56 path = deploy-rs.lib.x86_64-linux.activate.nixos
57 self.nixosConfigurations.clicks;
58 };
59 } // (
60 let
61 mkServiceConfig = service: {
62 remoteBuild = true;
63 user = service;
64
65 profilePath = "/nix/var/nix/profiles/per-user/${service}/home-manager";
66 path =
67 deploy-rs.lib.x86_64-linux.activate.home-manager (home-manager.lib.homeManagerConfiguration
68 {
69 inherit pkgs;
70 modules = [
71 {
72 home.homeDirectory = "/services/${service}";
73 home.username = service;
74 home.stateVersion = "22.11";
75 programs.home-manager.enable = true;
76 }
77 "${./services}/${service}"
78 ];
79 });
80 };
81 in
82 nixpkgs.lib.pipe ./services [
83 builtins.readDir
84 (nixpkgs.lib.filterAttrs (_name: value: value == "directory"))
85 builtins.attrNames
86 (map (name: {
87 inherit name; value = mkServiceConfig name;
88 }))
89 builtins.listToAttrs
90 ]
91 );
92 hostname = "clicks";
93 profilesOrder = [ "system" ];
Skyler Grey1e2187f2023-03-03 22:45:10 +000094 };
Skyler Grey1e2187f2023-03-03 22:45:10 +000095
Skyler Grey07584fb2023-05-01 21:37:13 +000096 formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
Skyler Grey1e2187f2023-03-03 22:45:10 +000097 };
Skyler Grey1e2187f2023-03-03 22:45:10 +000098}