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 | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 4 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; |
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 | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 7 | inputs.home-manager.url = "github:nix-community/home-manager/release-22.11"; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 8 | |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 9 | 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 Grey | 4f3e606 | 2023-03-04 01:29:29 +0000 | [diff] [blame] | 44 | }; |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 45 | |
| 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 Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 90 | }; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 91 | |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 92 | formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 93 | }; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 94 | } |