blob: d21549c0bd779b71c0eea47c40fc9fa28c409b79 [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
37 ./modules/home-manager-users.nix
38 ./modules/kitty.nix
39 ./modules/mongodb.nix
40 ./modules/node.nix
41 ./modules/samba.nix
42 ./modules/tesseract.nix
43 {
44 users.mutableUsers = false;
45 }
46 ];
Skyler Grey4f3e6062023-03-04 01:29:29 +000047 };
Skyler Grey07584fb2023-05-01 21:37:13 +000048
49 deploy.nodes.clicks = {
50 sudo = "doas -u";
51 profiles = {
52 system = {
53 remoteBuild = true;
54 user = "root";
55 path = deploy-rs.lib.x86_64-linux.activate.nixos
56 self.nixosConfigurations.clicks;
57 };
58 } // (
59 let
60 mkServiceConfig = service: {
61 remoteBuild = true;
62 user = service;
63
64 profilePath = "/nix/var/nix/profiles/per-user/${service}/home-manager";
65 path =
66 deploy-rs.lib.x86_64-linux.activate.home-manager (home-manager.lib.homeManagerConfiguration
67 {
68 inherit pkgs;
69 modules = [
70 {
71 home.homeDirectory = "/services/${service}";
72 home.username = service;
73 home.stateVersion = "22.11";
74 programs.home-manager.enable = true;
75 }
76 "${./services}/${service}"
77 ];
78 });
79 };
80 in
81 nixpkgs.lib.pipe ./services [
82 builtins.readDir
83 (nixpkgs.lib.filterAttrs (_name: value: value == "directory"))
84 builtins.attrNames
85 (map (name: {
86 inherit name; value = mkServiceConfig name;
87 }))
88 builtins.listToAttrs
89 ]
90 );
91 hostname = "clicks";
92 profilesOrder = [ "system" ];
Skyler Grey1e2187f2023-03-03 22:45:10 +000093 };
Skyler Grey1e2187f2023-03-03 22:45:10 +000094
Skyler Grey07584fb2023-05-01 21:37:13 +000095 formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
Skyler Grey1e2187f2023-03-03 22:45:10 +000096 };
Skyler Grey1e2187f2023-03-03 22:45:10 +000097}