blob: 58aceab151044337f2433fa560c77453d1482f8b [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 Grey07584fb2023-05-01 21:37:13 +00009 outputs = { self, nixpkgs, deploy-rs, home-manager, ... }@inputs:
10 let
11 system = "x86_64-linux";
12 pkgs = import nixpkgs {
13 inherit system;
14 config.allowUnfree = true;
15 };
16 in
17 {
18 nixosConfigurations.clicks =
19 nixpkgs.lib.nixosSystem {
20 inherit system pkgs;
21 modules = [
22 ./default/configuration.nix
23 ./default/hardware-configuration.nix
24 ./modules/caddy.nix
25 ./modules/clamav.nix
26 ./modules/code-server.nix
27 ./modules/dnsmasq.nix
28 ./modules/doas.nix
29 ./modules/docker.nix
30 ./modules/ecryptfs.nix
31 ./modules/fail2ban.nix
32 ./modules/fuck.nix
33 ./modules/git.nix
34 ./modules/home-manager-users.nix
35 ./modules/kitty.nix
36 ./modules/mongodb.nix
37 ./modules/node.nix
38 ./modules/samba.nix
39 ./modules/tesseract.nix
40 {
41 users.mutableUsers = false;
42 }
43 ];
Skyler Grey4f3e6062023-03-04 01:29:29 +000044 };
Skyler Grey07584fb2023-05-01 21:37:13 +000045
46 deploy.nodes.clicks = {
47 sudo = "doas -u";
48 profiles = {
49 system = {
50 remoteBuild = true;
51 user = "root";
52 path = deploy-rs.lib.x86_64-linux.activate.nixos
53 self.nixosConfigurations.clicks;
54 };
55 } // (
56 let
57 mkServiceConfig = service: {
58 remoteBuild = true;
59 user = service;
60
61 profilePath = "/nix/var/nix/profiles/per-user/${service}/home-manager";
62 path =
63 deploy-rs.lib.x86_64-linux.activate.home-manager (home-manager.lib.homeManagerConfiguration
64 {
65 inherit pkgs;
66 modules = [
67 {
68 home.homeDirectory = "/services/${service}";
69 home.username = service;
70 home.stateVersion = "22.11";
71 programs.home-manager.enable = true;
72 }
73 "${./services}/${service}"
74 ];
75 });
76 };
77 in
78 nixpkgs.lib.pipe ./services [
79 builtins.readDir
80 (nixpkgs.lib.filterAttrs (_name: value: value == "directory"))
81 builtins.attrNames
82 (map (name: {
83 inherit name; value = mkServiceConfig name;
84 }))
85 builtins.listToAttrs
86 ]
87 );
88 hostname = "clicks";
89 profilesOrder = [ "system" ];
Skyler Grey1e2187f2023-03-03 22:45:10 +000090 };
Skyler Grey1e2187f2023-03-03 22:45:10 +000091
Skyler Grey07584fb2023-05-01 21:37:13 +000092 formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
Skyler Grey1e2187f2023-03-03 22:45:10 +000093 };
Skyler Grey1e2187f2023-03-03 22:45:10 +000094}