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