blob: 0ca01860a880d0020d83c36637522abb9190b7bd [file] [log] [blame]
Skyler Grey1e2187f2023-03-03 22:45:10 +00001{
2 description = "A flake to deploy and configure Clicks' NixOS server";
3
Samuel Shuertf68685d2023-10-28 20:07:56 -04004 # input URLs
Skyler Grey915067d2023-12-03 13:46:53 +00005 inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
Skyler Greyb30f5dd2023-09-01 21:02:44 +00006 inputs.nixpkgs-clicksforms.url = "github:nixos/nixpkgs/nixos-22.05";
Skyler Grey061574c2023-05-01 21:39:24 +00007 inputs.flake-utils.url = "github:numtide/flake-utils";
Skyler Grey1e2187f2023-03-03 22:45:10 +00008 inputs.deploy-rs.url = "github:serokell/deploy-rs";
Skyler Grey915067d2023-12-03 13:46:53 +00009 inputs.home-manager.url = "github:nix-community/home-manager/release-23.11";
Skyler Greya7fbaee2023-05-12 00:29:20 +000010 inputs.sops-nix.url = "github:Mic92/sops-nix";
Skyler Greya78aa672023-05-20 13:48:18 +020011 inputs.scalpel.url = "github:polygon/scalpel";
Skyler Grey1e2187f2023-03-03 22:45:10 +000012
Samuel Shuertf68685d2023-10-28 20:07:56 -040013 inputs.nixpkgs-privatebin.url = "github:e1mo/nixpkgs/privatebin";
14 inputs.nixpkgs-mongodb.url = "github:nixos/nixpkgs?rev=8dfad603247387df1df4826b8bea58efc5d012d8";
15
Skyler Grey22428b02023-11-19 13:20:56 +000016 inputs.helpers.url = "git+https://git.clicks.codes/Clicks/NixHelpers";
Samuel Shuertf68685d2023-10-28 20:07:56 -040017
Skyler Greyfc048592024-03-10 13:46:17 +000018 inputs.frappix.url = "github:blaggacao/frappix";
19
Samuel Shuertf68685d2023-10-28 20:07:56 -040020 # follow settings
Skyler Greyfed0bb12023-05-01 21:42:03 +000021 inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs";
Skyler Greyfed0bb12023-05-01 21:42:03 +000022
Skyler Greya7fbaee2023-05-12 00:29:20 +000023 inputs.sops-nix.inputs.nixpkgs.follows = "nixpkgs";
24
Skyler Greya78aa672023-05-20 13:48:18 +020025 inputs.scalpel.inputs.nixpkgs.follows = "nixpkgs";
26 inputs.scalpel.inputs.sops-nix.follows = "sops-nix";
27
Skyler Greyc5ed69c2023-12-23 02:25:41 +000028 inputs.gerrit-oauth = {
29 url = "https://gerrit-ci.gerritforge.com/job/plugin-oauth-bazel-master-master/lastBuild/artifact/bazel-bin/plugins/oauth/oauth.jar";
30 flake = false;
31 };
32
Skyler Greyfc048592024-03-10 13:46:17 +000033 inputs.frappix.inputs.nixpkgs.follows = "nixpkgs";
34
Skyler Greyfe1740c2023-10-21 01:24:18 +000035 outputs = { self, nixpkgs, deploy-rs, home-manager, sops-nix, scalpel
Skyler Greyfc048592024-03-10 13:46:17 +000036 , nixpkgs-privatebin, frappix, ... }@inputs:
Skyler Grey07584fb2023-05-01 21:37:13 +000037 let
38 system = "x86_64-linux";
39 pkgs = import nixpkgs {
40 inherit system;
41 config.allowUnfree = true;
Skyler Greyfc048592024-03-10 13:46:17 +000042
43 # frappix -> wkhtmltopdf
44 config.permittedInsecurePackages = ["openssl-1.1.1w"];
45
Skyler Grey9fe61282023-08-20 21:52:48 +000046 overlays = [
Skyler Greyfe1740c2023-10-21 01:24:18 +000047 (final: prev: {
48 inherit (nixpkgs-privatebin.legacyPackages.${system})
49 privatebin pbcli;
50 })
Skyler Greyfc048592024-03-10 13:46:17 +000051 frappix.toolsOverlay.${system}
52 frappix.pythonOverlay.${system}
53 frappix.frappeOverlay.${system}
Skyler Grey9fe61282023-08-20 21:52:48 +000054 ];
Skyler Grey07584fb2023-05-01 21:37:13 +000055 };
Samuel Shuertf68685d2023-10-28 20:07:56 -040056 helpers = inputs.helpers.helpers { inherit pkgs nixpkgs; };
57 drive_paths = import ./variables/drive_paths.nix;
58
59 a1d1 = import ./modules/a1d1 { inherit self pkgs system inputs drive_paths; };
60 a1d2 = import ./modules/a1d2 { inherit self pkgs system inputs; drive_paths = null; };
Skyler Greyfe1740c2023-10-21 01:24:18 +000061 in rec {
62 nixosConfigurations.clicks = let
63 base = nixpkgs.lib.nixosSystem {
64 inherit system pkgs;
Skyler Grey07584fb2023-05-01 21:37:13 +000065 modules = [
Samuel Shuertf68685d2023-10-28 20:07:56 -040066 {
67 system.stateVersion = "22.11";
68 nix.settings.experimental-features = [ "nix-command" "flakes" ];
Samuel Shuert32d3fb52023-11-22 16:25:10 -050069 nix.settings.trusted-users = [ "minion" "coded" ];
Samuel Shuertf68685d2023-10-28 20:07:56 -040070 time.timeZone = "Etc/UTC";
71 users.mutableUsers = false;
72
73 fileSystems."/" = {};
74 }
75 ]
76 ++ (helpers.nixFilesIn ./modules/common)
77 ++ [
Skyler Greyfe1740c2023-10-21 01:24:18 +000078 sops-nix.nixosModules.sops
79 "${nixpkgs-privatebin}/nixos/modules/services/web-apps/privatebin.nix"
Skyler Greyfc048592024-03-10 13:46:17 +000080 frappix.nixosModules.${system}.frappix
Skyler Grey07584fb2023-05-01 21:37:13 +000081 ];
Samuel Shuertf68685d2023-10-28 20:07:56 -040082 specialArgs = inputs // {
Skyler Greyfe1740c2023-10-21 01:24:18 +000083 base = null;
Skyler Greyfe1740c2023-10-21 01:24:18 +000084 inherit system;
Samuel Shuertf68685d2023-10-28 20:07:56 -040085 inherit helpers;
86 drive_paths = null;
Skyler Greyfe1740c2023-10-21 01:24:18 +000087 };
Skyler Grey4f3e6062023-03-04 01:29:29 +000088 };
Skyler Greyfe1740c2023-10-21 01:24:18 +000089 in base.extendModules {
90 modules = [ scalpel.nixosModules.scalpel ];
91 specialArgs = { inherit base; };
92 };
Skyler Grey07584fb2023-05-01 21:37:13 +000093
Skyler Greyb3516c22023-05-24 19:17:11 +020094 nixosConfigurations.clicks-without-mongodb =
95 nixosConfigurations.clicks.extendModules {
Skyler Greyfe1740c2023-10-21 01:24:18 +000096 modules = [{ services.mongodb.enable = nixpkgs.lib.mkForce false; }];
Skyler Greyb3516c22023-05-24 19:17:11 +020097 };
98
Samuel Shuertf68685d2023-10-28 20:07:56 -040099 nixosConfigurations.a1d1 = a1d1.config;
100 nixosConfigurations.a1d2 = a1d2.config;
Skyler Grey07584fb2023-05-01 21:37:13 +0000101
Samuel Shuertf68685d2023-10-28 20:07:56 -0400102 deploy.nodes.a1d1 = a1d1.deploy;
103 deploy.nodes.a1d2 = a1d2.deploy;
Skyler Grey1e2187f2023-03-03 22:45:10 +0000104
Skyler Greyfe1740c2023-10-21 01:24:18 +0000105 devShells.x86_64-linux.default =
106 pkgs.mkShell { packages = [ pkgs.deploy-rs ]; };
Skyler Greyb30f5dd2023-09-01 21:02:44 +0000107
Skyler Grey2ca6ccd2023-10-14 22:56:43 +0000108 formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
Skyler Grey1e2187f2023-03-03 22:45:10 +0000109 };
Skyler Grey1e2187f2023-03-03 22:45:10 +0000110}