Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 1 | { |
| 2 | description = "A flake to deploy and configure Clicks' NixOS server"; |
| 3 | |
Skyler Grey | 07c947a | 2023-06-08 14:11:23 +0200 | [diff] [blame] | 4 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; |
Skyler Grey | 061574c | 2023-05-01 21:39:24 +0000 | [diff] [blame] | 5 | inputs.flake-utils.url = "github:numtide/flake-utils"; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 6 | inputs.deploy-rs.url = "github:serokell/deploy-rs"; |
Skyler Grey | 07c947a | 2023-06-08 14:11:23 +0200 | [diff] [blame] | 7 | inputs.home-manager.url = "github:nix-community/home-manager/release-23.05"; |
Skyler Grey | a7fbaee | 2023-05-12 00:29:20 +0000 | [diff] [blame] | 8 | inputs.sops-nix.url = "github:Mic92/sops-nix"; |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 9 | inputs.scalpel.url = "github:polygon/scalpel"; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 10 | |
Skyler Grey | fed0bb1 | 2023-05-01 21:42:03 +0000 | [diff] [blame] | 11 | inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs"; |
Skyler Grey | fed0bb1 | 2023-05-01 21:42:03 +0000 | [diff] [blame] | 12 | |
Skyler Grey | a7fbaee | 2023-05-12 00:29:20 +0000 | [diff] [blame] | 13 | inputs.sops-nix.inputs.nixpkgs.follows = "nixpkgs"; |
| 14 | |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 15 | inputs.scalpel.inputs.nixpkgs.follows = "nixpkgs"; |
| 16 | inputs.scalpel.inputs.sops-nix.follows = "sops-nix"; |
| 17 | |
Skyler Grey | 07c947a | 2023-06-08 14:11:23 +0200 | [diff] [blame] | 18 | outputs = { self, nixpkgs, deploy-rs, home-manager, sops-nix, scalpel, ... }@inputs: |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 19 | let |
| 20 | system = "x86_64-linux"; |
| 21 | pkgs = import nixpkgs { |
| 22 | inherit system; |
| 23 | config.allowUnfree = true; |
| 24 | }; |
| 25 | in |
Skyler Grey | b3516c2 | 2023-05-24 19:17:11 +0200 | [diff] [blame] | 26 | rec { |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 27 | nixosConfigurations.clicks = |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 28 | let |
| 29 | base = nixpkgs.lib.nixosSystem { |
| 30 | inherit system pkgs; |
| 31 | modules = [ |
| 32 | ./default/configuration.nix |
| 33 | ./default/hardware-configuration.nix |
Skyler Grey | 703e75a | 2023-06-08 13:39:50 +0200 | [diff] [blame] | 34 | ./modules/cache.nix |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 35 | ./modules/caddy.nix |
| 36 | ./modules/clamav.nix |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 37 | ./modules/dmarc.nix |
| 38 | ./modules/dnsmasq.nix |
| 39 | ./modules/doas.nix |
| 40 | ./modules/docker.nix |
| 41 | ./modules/ecryptfs.nix |
| 42 | ./modules/fail2ban.nix |
| 43 | ./modules/fuck.nix |
| 44 | ./modules/git.nix |
| 45 | ./modules/grafana.nix |
| 46 | ./modules/home-manager-users.nix |
| 47 | ./modules/kitty.nix |
Skyler Grey | 480fd8b | 2023-05-24 19:11:16 +0200 | [diff] [blame] | 48 | ./modules/loginctl-linger.nix |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 49 | ./modules/matrix.nix |
| 50 | ./modules/mongodb.nix |
| 51 | ./modules/node.nix |
| 52 | ./modules/postgres.nix |
| 53 | ./modules/samba.nix |
| 54 | ./modules/scalpel.nix |
Skyler Grey | 07c947a | 2023-06-08 14:11:23 +0200 | [diff] [blame] | 55 | ./modules/ssh.nix |
Skyler Grey | 5b2c038 | 2023-05-29 11:09:05 +0200 | [diff] [blame] | 56 | ./modules/static-ip.nix |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 57 | ./modules/tesseract.nix |
| 58 | sops-nix.nixosModules.sops |
| 59 | { |
| 60 | users.mutableUsers = false; |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 61 | } |
| 62 | ]; |
TheCodedProf | d23784c | 2023-06-13 14:28:23 -0400 | [diff] [blame] | 63 | specialArgs = { base = null; drive_paths = import ./variables/drive_paths.nix; }; |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 64 | }; |
| 65 | in |
| 66 | base.extendModules { |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 67 | modules = [ |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 68 | scalpel.nixosModules.scalpel |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 69 | ]; |
Skyler Grey | a78aa67 | 2023-05-20 13:48:18 +0200 | [diff] [blame] | 70 | specialArgs = { inherit base; }; |
Skyler Grey | 4f3e606 | 2023-03-04 01:29:29 +0000 | [diff] [blame] | 71 | }; |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 72 | |
Skyler Grey | b3516c2 | 2023-05-24 19:17:11 +0200 | [diff] [blame] | 73 | nixosConfigurations.clicks-without-mongodb = |
| 74 | nixosConfigurations.clicks.extendModules { |
| 75 | modules = [ |
| 76 | { services.mongodb.enable = nixpkgs.lib.mkForce false; } |
| 77 | ]; |
| 78 | }; |
| 79 | |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 80 | deploy.nodes.clicks = { |
| 81 | sudo = "doas -u"; |
| 82 | profiles = { |
| 83 | system = { |
| 84 | remoteBuild = true; |
| 85 | user = "root"; |
| 86 | path = deploy-rs.lib.x86_64-linux.activate.nixos |
| 87 | self.nixosConfigurations.clicks; |
| 88 | }; |
| 89 | } // ( |
| 90 | let |
| 91 | mkServiceConfig = service: { |
| 92 | remoteBuild = true; |
| 93 | user = service; |
| 94 | |
| 95 | profilePath = "/nix/var/nix/profiles/per-user/${service}/home-manager"; |
| 96 | path = |
| 97 | deploy-rs.lib.x86_64-linux.activate.home-manager (home-manager.lib.homeManagerConfiguration |
| 98 | { |
| 99 | inherit pkgs; |
| 100 | modules = [ |
| 101 | { |
| 102 | home.homeDirectory = "/services/${service}"; |
| 103 | home.username = service; |
| 104 | home.stateVersion = "22.11"; |
| 105 | programs.home-manager.enable = true; |
| 106 | } |
| 107 | "${./services}/${service}" |
| 108 | ]; |
| 109 | }); |
| 110 | }; |
| 111 | in |
| 112 | nixpkgs.lib.pipe ./services [ |
| 113 | builtins.readDir |
| 114 | (nixpkgs.lib.filterAttrs (_name: value: value == "directory")) |
| 115 | builtins.attrNames |
| 116 | (map (name: { |
| 117 | inherit name; value = mkServiceConfig name; |
| 118 | })) |
| 119 | builtins.listToAttrs |
| 120 | ] |
Skyler Grey | 5b2c038 | 2023-05-29 11:09:05 +0200 | [diff] [blame] | 121 | ) // ( |
| 122 | let |
| 123 | mkBlankConfig = username: |
| 124 | { |
| 125 | remoteBuild = true; |
| 126 | user = username; |
| 127 | |
| 128 | profilePath = "/nix/var/nix/profiles/per-user/${username}/home-manager"; |
| 129 | path = |
| 130 | deploy-rs.lib.x86_64-linux.activate.home-manager (home-manager.lib.homeManagerConfiguration |
| 131 | { |
| 132 | inherit pkgs; |
| 133 | modules = [ |
| 134 | { |
| 135 | home.username = username; |
| 136 | home.stateVersion = "22.11"; |
| 137 | programs.home-manager.enable = true; |
| 138 | } |
| 139 | "${./homes}/${username}" |
| 140 | ]; |
| 141 | }); |
| 142 | }; |
| 143 | in |
| 144 | nixpkgs.lib.pipe ./homes [ |
| 145 | builtins.readDir |
| 146 | (nixpkgs.lib.filterAttrs (_name: value: value == "directory")) |
| 147 | builtins.attrNames |
| 148 | (map (name: { |
| 149 | inherit name; value = mkBlankConfig name; |
| 150 | })) |
| 151 | builtins.listToAttrs |
| 152 | ] |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 153 | ); |
| 154 | hostname = "clicks"; |
| 155 | profilesOrder = [ "system" ]; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 156 | }; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 157 | |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 158 | formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 159 | }; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 160 | } |