Commit 20e0a9e11eaa

Vincent Demeester <vincent@sbr.pm>
2019-02-15 18:43:18
modules: add ipfs modules and enable it on some machines
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 0e35b69
machine/hokkaido.nix
@@ -12,6 +12,7 @@ with import ../assets/machines.nix; {
   profiles = {
     dev.enable = true;
     docker.enable = true;
+    ipfs.enable = true;
     laptop.enable = true;
     ssh.enable = true;
     syncthing.enable = true;
machine/shikoku.nix
@@ -45,6 +45,7 @@ with import ../assets/machines.nix; {
     dev.enable = true;
     docker.enable = true;
     gaming.enable = true;
+    ipfs.enable = true;
     nix-config.buildCores = 4;
     ssh.enable = true;
     virtualization = {
machine/wakasu.nix
@@ -14,6 +14,7 @@ with import ../assets/machines.nix; {
   profiles = {
     dev.enable = true;
     docker.enable = true;
+    ipfs.enable = true;
     laptop.enable = true;
     nix-config.buildCores = 4;
     ssh.enable = true;
modules/profiles/ipfs.nix
@@ -0,0 +1,43 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.profiles.ipfs;
+in
+{
+  options = {
+    profiles.ipfs = {
+      enable = mkOption {
+        default = false;
+        description = "Enable ipfs profile";
+        type = types.bool;
+      };
+      autoMount = mkOption {
+        default = true;
+        description = "Automount /ipfs and /ipns";
+        type = types.bool;
+      };
+      localDiscovery = mkOption {
+        default = true;
+        description = "Enable local discovery, switch profile to server if disable";
+        type = types.bool;
+      };
+      extraConfig = mkOption {
+        default = {
+          Datastore.StorageMax = "40GB";
+        };
+        description = "Extra ipfs daemon configuration";
+        type = types.attrs;
+      };
+    };
+  };
+  config = mkIf cfg.enable {
+    services.ipfs = {
+      enable = true;
+      enableGC = true;
+      localDiscovery = cfg.localDiscovery;
+      autoMount = cfg.autoMount;
+      extraConfig = cfg.extraConfig;
+    };
+  };
+}
modules/module-list.nix
@@ -14,6 +14,7 @@
     ./profiles/gaming.nix
     ./profiles/git.nix
     ./profiles/i18n.nix
+    ./profiles/ipfs.nix
     ./profiles/laptop.nix
     ./profiles/mail.nix
     ./profiles/nix-config.nix