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 | fed0bb1 | 2023-05-01 21:42:03 +0000 | [diff] [blame^] | 9 | inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs"; |
| 10 | inputs.home-manager.inputs.utils.follows = "deploy-rs/utils"; |
| 11 | |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 12 | 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 Grey | 4f3e606 | 2023-03-04 01:29:29 +0000 | [diff] [blame] | 47 | }; |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 48 | |
| 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 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 | |
Skyler Grey | 07584fb | 2023-05-01 21:37:13 +0000 | [diff] [blame] | 95 | formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 96 | }; |
Skyler Grey | 1e2187f | 2023-03-03 22:45:10 +0000 | [diff] [blame] | 97 | } |