blob: 2067d5035cf43552efbee7c17674c899aad88f01 [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 Grey07c947a2023-06-08 14:11:23 +02005 inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
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 Grey07c947a2023-06-08 14:11:23 +02009 inputs.home-manager.url = "github:nix-community/home-manager/release-23.05";
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
18 # follow settings
Skyler Greyfed0bb12023-05-01 21:42:03 +000019 inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs";
Skyler Greyfed0bb12023-05-01 21:42:03 +000020
Skyler Greya7fbaee2023-05-12 00:29:20 +000021 inputs.sops-nix.inputs.nixpkgs.follows = "nixpkgs";
22
Skyler Greya78aa672023-05-20 13:48:18 +020023 inputs.scalpel.inputs.nixpkgs.follows = "nixpkgs";
24 inputs.scalpel.inputs.sops-nix.follows = "sops-nix";
25
Skyler Greyfe1740c2023-10-21 01:24:18 +000026 outputs = { self, nixpkgs, deploy-rs, home-manager, sops-nix, scalpel
Samuel Shuertf68685d2023-10-28 20:07:56 -040027 , nixpkgs-privatebin, ... }@inputs:
Skyler Grey07584fb2023-05-01 21:37:13 +000028 let
29 system = "x86_64-linux";
30 pkgs = import nixpkgs {
31 inherit system;
32 config.allowUnfree = true;
Skyler Grey9fe61282023-08-20 21:52:48 +000033 overlays = [
Skyler Greyfe1740c2023-10-21 01:24:18 +000034 (final: prev: {
35 inherit (nixpkgs-privatebin.legacyPackages.${system})
36 privatebin pbcli;
37 })
Skyler Grey9fe61282023-08-20 21:52:48 +000038 ];
Skyler Grey07584fb2023-05-01 21:37:13 +000039 };
Samuel Shuertf68685d2023-10-28 20:07:56 -040040 helpers = inputs.helpers.helpers { inherit pkgs nixpkgs; };
41 drive_paths = import ./variables/drive_paths.nix;
42
43 a1d1 = import ./modules/a1d1 { inherit self pkgs system inputs drive_paths; };
44 a1d2 = import ./modules/a1d2 { inherit self pkgs system inputs; drive_paths = null; };
Skyler Greyfe1740c2023-10-21 01:24:18 +000045 in rec {
46 nixosConfigurations.clicks = let
47 base = nixpkgs.lib.nixosSystem {
48 inherit system pkgs;
Skyler Grey07584fb2023-05-01 21:37:13 +000049 modules = [
Samuel Shuertf68685d2023-10-28 20:07:56 -040050 {
51 system.stateVersion = "22.11";
52 nix.settings.experimental-features = [ "nix-command" "flakes" ];
53 nix.settings.trusted-users = [ "minion" ];
54 time.timeZone = "Etc/UTC";
55 users.mutableUsers = false;
56
57 fileSystems."/" = {};
58 }
59 ]
60 ++ (helpers.nixFilesIn ./modules/common)
61 ++ [
Skyler Greyfe1740c2023-10-21 01:24:18 +000062 sops-nix.nixosModules.sops
63 "${nixpkgs-privatebin}/nixos/modules/services/web-apps/privatebin.nix"
Skyler Grey07584fb2023-05-01 21:37:13 +000064 ];
Samuel Shuertf68685d2023-10-28 20:07:56 -040065 specialArgs = inputs // {
Skyler Greyfe1740c2023-10-21 01:24:18 +000066 base = null;
Skyler Greyfe1740c2023-10-21 01:24:18 +000067 inherit system;
Samuel Shuertf68685d2023-10-28 20:07:56 -040068 inherit helpers;
69 drive_paths = null;
Skyler Greyfe1740c2023-10-21 01:24:18 +000070 };
Skyler Grey4f3e6062023-03-04 01:29:29 +000071 };
Skyler Greyfe1740c2023-10-21 01:24:18 +000072 in base.extendModules {
73 modules = [ scalpel.nixosModules.scalpel ];
74 specialArgs = { inherit base; };
75 };
Skyler Grey07584fb2023-05-01 21:37:13 +000076
Skyler Greyb3516c22023-05-24 19:17:11 +020077 nixosConfigurations.clicks-without-mongodb =
78 nixosConfigurations.clicks.extendModules {
Skyler Greyfe1740c2023-10-21 01:24:18 +000079 modules = [{ services.mongodb.enable = nixpkgs.lib.mkForce false; }];
Skyler Greyb3516c22023-05-24 19:17:11 +020080 };
81
Samuel Shuertf68685d2023-10-28 20:07:56 -040082 nixosConfigurations.a1d1 = a1d1.config;
83 nixosConfigurations.a1d2 = a1d2.config;
Skyler Grey07584fb2023-05-01 21:37:13 +000084
Samuel Shuertf68685d2023-10-28 20:07:56 -040085 deploy.nodes.a1d1 = a1d1.deploy;
86 deploy.nodes.a1d2 = a1d2.deploy;
Skyler Grey1e2187f2023-03-03 22:45:10 +000087
Skyler Greyfe1740c2023-10-21 01:24:18 +000088 devShells.x86_64-linux.default =
89 pkgs.mkShell { packages = [ pkgs.deploy-rs ]; };
Skyler Greyb30f5dd2023-09-01 21:02:44 +000090
Skyler Grey2ca6ccd2023-10-14 22:56:43 +000091 formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
Skyler Grey1e2187f2023-03-03 22:45:10 +000092 };
Skyler Grey1e2187f2023-03-03 22:45:10 +000093}