From 12235422265b5cc6e50547fe976fcc8a1296c1f2 Mon Sep 17 00:00:00 2001
From: coolneng <akasroua@gmail.com>
Date: Thu, 10 Sep 2020 13:13:25 +0200
Subject: [PATCH] Set up cachix as emacs-overlay binary cache

---
 cachix/nix-community.nix |  8 ++++++++
 configuration.nix        |  1 +
 modules/cachix.nix       | 13 +++++++++++++
 modules/software.nix     |  3 ++-
 4 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 cachix/nix-community.nix
 create mode 100644 modules/cachix.nix

diff --git a/cachix/nix-community.nix b/cachix/nix-community.nix
new file mode 100644
index 0000000..b0a63e9
--- /dev/null
+++ b/cachix/nix-community.nix
@@ -0,0 +1,8 @@
+{
+  nix = {
+    binaryCaches = [ "https://nix-community.cachix.org" ];
+    binaryCachePublicKeys = [
+      "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
+    ];
+  };
+}
diff --git a/configuration.nix b/configuration.nix
index 8752507..e8aea42 100644
--- a/configuration.nix
+++ b/configuration.nix
@@ -103,6 +103,7 @@
     ./modules/printing.nix
     ./modules/periodic.nix
     ./modules/power.nix
+    ./modules/cachix.nix
     ./overlays/emacs-overlay.nix
   ];
 
diff --git a/modules/cachix.nix b/modules/cachix.nix
new file mode 100644
index 0000000..104ea98
--- /dev/null
+++ b/modules/cachix.nix
@@ -0,0 +1,13 @@
+# WARN: this file will get overwritten by $ cachix use <name>
+{ pkgs, lib, ... }:
+
+let
+  folder = ../cachix;
+  toImport = name: value: folder + ("/" + name);
+  filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key;
+  imports = lib.mapAttrsToList toImport
+    (lib.filterAttrs filterCaches (builtins.readDir folder));
+in {
+  inherit imports;
+  nix.binaryCaches = [ "https://cache.nixos.org/" ];
+}
diff --git a/modules/software.nix b/modules/software.nix
index 4d8a225..d030d3e 100644
--- a/modules/software.nix
+++ b/modules/software.nix
@@ -37,7 +37,6 @@
     podman-compose
     shellcheck
     shfmt
-    android-studio
     gnumake
     nodePackages.pyright
     black
@@ -75,6 +74,8 @@
     zip
     unzip
     unrar
+    # Overlays
+    cachix
   ];
 
   # Fonts declaration