blob: e63112a3ba54a9c3db768f7e4acfe6fd45049e58 [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 Grey68b893f2024-04-18 10:36:40 +00006 inputs.nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
Skyler Greyb30f5dd2023-09-01 21:02:44 +00007 inputs.nixpkgs-clicksforms.url = "github:nixos/nixpkgs/nixos-22.05";
Skyler Grey061574c2023-05-01 21:39:24 +00008 inputs.flake-utils.url = "github:numtide/flake-utils";
Skyler Grey1e2187f2023-03-03 22:45:10 +00009 inputs.deploy-rs.url = "github:serokell/deploy-rs";
Skyler Grey915067d2023-12-03 13:46:53 +000010 inputs.home-manager.url = "github:nix-community/home-manager/release-23.11";
Skyler Greya7fbaee2023-05-12 00:29:20 +000011 inputs.sops-nix.url = "github:Mic92/sops-nix";
Skyler Greya78aa672023-05-20 13:48:18 +020012 inputs.scalpel.url = "github:polygon/scalpel";
Skyler Grey1e2187f2023-03-03 22:45:10 +000013
Samuel Shuertf68685d2023-10-28 20:07:56 -040014 inputs.nixpkgs-privatebin.url = "github:e1mo/nixpkgs/privatebin";
15 inputs.nixpkgs-mongodb.url = "github:nixos/nixpkgs?rev=8dfad603247387df1df4826b8bea58efc5d012d8";
16
Skyler Grey99fbd702024-03-11 00:04:20 +000017 inputs.helpers.url = "git+https://git.clicks.codes/Infra/NixHelpers";
Samuel Shuertf68685d2023-10-28 20:07:56 -040018
Samuel Shuert91424b72024-06-08 20:34:41 -040019 inputs.frappix.url = "github:blaggacao/frappix";
Skyler Greyfc048592024-03-10 13:46:17 +000020
Samuel Shuertf68685d2023-10-28 20:07:56 -040021 # follow settings
Skyler Greyfed0bb12023-05-01 21:42:03 +000022 inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs";
Skyler Greyfed0bb12023-05-01 21:42:03 +000023
Skyler Greya7fbaee2023-05-12 00:29:20 +000024 inputs.sops-nix.inputs.nixpkgs.follows = "nixpkgs";
25
Skyler Greya78aa672023-05-20 13:48:18 +020026 inputs.scalpel.inputs.nixpkgs.follows = "nixpkgs";
27 inputs.scalpel.inputs.sops-nix.follows = "sops-nix";
28
Skyler Greyc5ed69c2023-12-23 02:25:41 +000029 inputs.gerrit-oauth = {
30 url = "https://gerrit-ci.gerritforge.com/job/plugin-oauth-bazel-master-master/lastBuild/artifact/bazel-bin/plugins/oauth/oauth.jar";
31 flake = false;
32 };
33
Skyler Grey68b893f2024-04-18 10:36:40 +000034 outputs = { self, nixpkgs, nixpkgs-unstable, deploy-rs, home-manager, sops-nix, scalpel
Skyler Greyfc048592024-03-10 13:46:17 +000035 , nixpkgs-privatebin, frappix, ... }@inputs:
Skyler Grey07584fb2023-05-01 21:37:13 +000036 let
37 system = "x86_64-linux";
38 pkgs = import nixpkgs {
39 inherit system;
40 config.allowUnfree = true;
Skyler Greyfc048592024-03-10 13:46:17 +000041
42 # frappix -> wkhtmltopdf
43 config.permittedInsecurePackages = ["openssl-1.1.1w"];
44
Skyler Grey9fe61282023-08-20 21:52:48 +000045 overlays = [
Skyler Greyfe1740c2023-10-21 01:24:18 +000046 (final: prev: {
Skyler Grey68b893f2024-04-18 10:36:40 +000047 inherit (nixpkgs-unstable.legacyPackages.${system})
48 vaultwarden vaultwarden-postgresql # vaultwarden updates often fix compatibility with the extension
49 matrix-sliding-sync; # matrix-sliding-sync updates very fast and being on an old version breaks app compatibility
50 }) # pin-unstable
51 (final: prev: {
Skyler Greyfe1740c2023-10-21 01:24:18 +000052 inherit (nixpkgs-privatebin.legacyPackages.${system})
53 privatebin pbcli;
54 })
Skyler Grey99fbd702024-03-11 00:04:20 +000055 (functorBuster: frappix.toolsOverlay.${system} functorBuster)
56 (functorBuster: frappix.pythonOverlay.${system} functorBuster)
57 (functorBuster: frappix.frappeOverlay.${system} functorBuster)
58 (final: prev: {
59 python311 = prev.python311.override {
60 packageOverrides = pyFinal: pyPrev: {
61 elasticsearch = (
62 pyPrev.elasticsearch.overrideAttrs (prevAttrs: {
63 propagatedBuildInputs = prevAttrs.propagatedBuildInputs ++ [
64 final.python311Packages.elastic-transport
65 ];
66 })
67 );
68 };
69 };
70 })
Skyler Grey9fe61282023-08-20 21:52:48 +000071 ];
Skyler Grey07584fb2023-05-01 21:37:13 +000072 };
Samuel Shuertf68685d2023-10-28 20:07:56 -040073 helpers = inputs.helpers.helpers { inherit pkgs nixpkgs; };
74 drive_paths = import ./variables/drive_paths.nix;
75
76 a1d1 = import ./modules/a1d1 { inherit self pkgs system inputs drive_paths; };
77 a1d2 = import ./modules/a1d2 { inherit self pkgs system inputs; drive_paths = null; };
Skyler Greyfe1740c2023-10-21 01:24:18 +000078 in rec {
79 nixosConfigurations.clicks = let
80 base = nixpkgs.lib.nixosSystem {
81 inherit system pkgs;
Skyler Grey07584fb2023-05-01 21:37:13 +000082 modules = [
Samuel Shuertf68685d2023-10-28 20:07:56 -040083 {
84 system.stateVersion = "22.11";
85 nix.settings.experimental-features = [ "nix-command" "flakes" ];
Samuel Shuert32d3fb52023-11-22 16:25:10 -050086 nix.settings.trusted-users = [ "minion" "coded" ];
Samuel Shuertf68685d2023-10-28 20:07:56 -040087 time.timeZone = "Etc/UTC";
88 users.mutableUsers = false;
89
90 fileSystems."/" = {};
91 }
92 ]
93 ++ (helpers.nixFilesIn ./modules/common)
94 ++ [
Skyler Greyfe1740c2023-10-21 01:24:18 +000095 sops-nix.nixosModules.sops
96 "${nixpkgs-privatebin}/nixos/modules/services/web-apps/privatebin.nix"
Skyler Greyfc048592024-03-10 13:46:17 +000097 frappix.nixosModules.${system}.frappix
Skyler Grey07584fb2023-05-01 21:37:13 +000098 ];
Samuel Shuertf68685d2023-10-28 20:07:56 -040099 specialArgs = inputs // {
Skyler Greyfe1740c2023-10-21 01:24:18 +0000100 base = null;
Skyler Greyfe1740c2023-10-21 01:24:18 +0000101 inherit system;
Samuel Shuertf68685d2023-10-28 20:07:56 -0400102 inherit helpers;
103 drive_paths = null;
Skyler Greyfe1740c2023-10-21 01:24:18 +0000104 };
Skyler Grey4f3e6062023-03-04 01:29:29 +0000105 };
Skyler Greyfe1740c2023-10-21 01:24:18 +0000106 in base.extendModules {
107 modules = [ scalpel.nixosModules.scalpel ];
108 specialArgs = { inherit base; };
109 };
Skyler Grey07584fb2023-05-01 21:37:13 +0000110
Skyler Greyb3516c22023-05-24 19:17:11 +0200111 nixosConfigurations.clicks-without-mongodb =
112 nixosConfigurations.clicks.extendModules {
Skyler Greyfe1740c2023-10-21 01:24:18 +0000113 modules = [{ services.mongodb.enable = nixpkgs.lib.mkForce false; }];
Skyler Greyb3516c22023-05-24 19:17:11 +0200114 };
115
Samuel Shuertf68685d2023-10-28 20:07:56 -0400116 nixosConfigurations.a1d1 = a1d1.config;
117 nixosConfigurations.a1d2 = a1d2.config;
Skyler Grey07584fb2023-05-01 21:37:13 +0000118
Samuel Shuertf68685d2023-10-28 20:07:56 -0400119 deploy.nodes.a1d1 = a1d1.deploy;
120 deploy.nodes.a1d2 = a1d2.deploy;
Skyler Grey1e2187f2023-03-03 22:45:10 +0000121
Skyler Greyfe1740c2023-10-21 01:24:18 +0000122 devShells.x86_64-linux.default =
123 pkgs.mkShell { packages = [ pkgs.deploy-rs ]; };
Skyler Greyb30f5dd2023-09-01 21:02:44 +0000124
Skyler Grey2ca6ccd2023-10-14 22:56:43 +0000125 formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
Skyler Grey1e2187f2023-03-03 22:45:10 +0000126 };
Skyler Grey1e2187f2023-03-03 22:45:10 +0000127}