<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Nextcloud on Carlos Vaz</title>
    <link>https://carlosvaz.com/tags/nextcloud/</link>
    <description>Recent content in Nextcloud on Carlos Vaz</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-US</language>
    <managingEditor>carlos@carjorvaz.com (Carlos Vaz)</managingEditor>
    <webMaster>carlos@carjorvaz.com (Carlos Vaz)</webMaster>
    <lastBuildDate>Sat, 05 Aug 2023 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://carlosvaz.com/tags/nextcloud/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>The Holy Grail Nextcloud setup made easy by NixOS</title>
      <link>https://carlosvaz.com/posts/the-holy-grail-nextcloud-setup-made-easy-by-nixos/</link>
      <pubDate>Sat, 05 Aug 2023 00:00:00 +0000</pubDate><author>carlos@carjorvaz.com (Carlos Vaz)</author>
      <guid>https://carlosvaz.com/posts/the-holy-grail-nextcloud-setup-made-easy-by-nixos/</guid>
      <description>&lt;p&gt;Nextcloud really is the central piece to most people&amp;rsquo;s self-hosted infrastructure.&lt;/p&gt;&#xA;&lt;p&gt;Providing file synchronization, a web interface to navigate through them, calendar, contacts, tasks, kanban and webmail, it presents itself as a complete GSuite self-hosted alternative.&lt;/p&gt;&#xA;&lt;p&gt;Hosting Nextcloud has become easier over time, thanks to its docker-compose example setups and to the Snap for use mostly on Ubuntu systems. However, having a faster and more optimized setup can take some effort on these platforms. Thankfully, on NixOS it&amp;rsquo;s not hard at all, as I&amp;rsquo;ll show you.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Nextcloud really is the central piece to most people&rsquo;s self-hosted infrastructure.</p>
<p>Providing file synchronization, a web interface to navigate through them, calendar, contacts, tasks, kanban and webmail, it presents itself as a complete GSuite self-hosted alternative.</p>
<p>Hosting Nextcloud has become easier over time, thanks to its docker-compose example setups and to the Snap for use mostly on Ubuntu systems. However, having a faster and more optimized setup can take some effort on these platforms. Thankfully, on NixOS it&rsquo;s not hard at all, as I&rsquo;ll show you.</p>





<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>{ self<span style="color:#f92672">,</span> config<span style="color:#f92672">,</span> lib<span style="color:#f92672">,</span> pkgs<span style="color:#f92672">,</span> <span style="color:#f92672">...</span> }:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  services <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    nginx<span style="color:#f92672">.</span>virtualHosts <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;cloud.example.com&#34;</span> <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>        forceSSL <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>        enableACME <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>      };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;onlyoffice.example.com&#34;</span> <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>        forceSSL <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>        enableACME <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>      };
</span></span><span style="display:flex;"><span>    };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    nextcloud <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>      enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>      hostName <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;cloud.example.com&#34;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>       <span style="color:#75715e"># Need to manually increment with every major upgrade.</span>
</span></span><span style="display:flex;"><span>      package <span style="color:#f92672">=</span> pkgs<span style="color:#f92672">.</span>nextcloud27;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      <span style="color:#75715e"># Let NixOS install and configure the database automatically.</span>
</span></span><span style="display:flex;"><span>      database<span style="color:#f92672">.</span>createLocally <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      <span style="color:#75715e"># Let NixOS install and configure Redis caching automatically.</span>
</span></span><span style="display:flex;"><span>      configureRedis <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      <span style="color:#75715e"># Increase the maximum file upload size to avoid problems uploading videos.</span>
</span></span><span style="display:flex;"><span>      maxUploadSize <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;16G&#34;</span>;
</span></span><span style="display:flex;"><span>      https <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>      enableBrokenCiphersForSSE <span style="color:#f92672">=</span> <span style="color:#66d9ef">false</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      autoUpdateApps<span style="color:#f92672">.</span>enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>      extraAppsEnable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>      extraApps <span style="color:#f92672">=</span> <span style="color:#66d9ef">with</span> config<span style="color:#f92672">.</span>services<span style="color:#f92672">.</span>nextcloud<span style="color:#f92672">.</span>package<span style="color:#f92672">.</span>packages<span style="color:#f92672">.</span>apps; {
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># List of apps we want to install and are already packaged in</span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/nextcloud/packages/nextcloud-apps.json</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">inherit</span> calendar contacts mail notes onlyoffice tasks;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># Custom app installation example.</span>
</span></span><span style="display:flex;"><span>        cookbook <span style="color:#f92672">=</span> pkgs<span style="color:#f92672">.</span>fetchNextcloudApp <span style="color:#66d9ef">rec</span> {
</span></span><span style="display:flex;"><span>          url <span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;https://github.com/nextcloud/cookbook/releases/download/v0.10.2/Cookbook-0.10.2.tar.gz&#34;</span>;
</span></span><span style="display:flex;"><span>          sha256 <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;sha256-XgBwUr26qW6wvqhrnhhhhcN4wkI+eXDHnNSm1HDbP6M=&#34;</span>;
</span></span><span style="display:flex;"><span>        };
</span></span><span style="display:flex;"><span>      };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      config <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>        overwriteProtocol <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;https&#34;</span>;
</span></span><span style="display:flex;"><span>        defaultPhoneRegion <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;PT&#34;</span>;
</span></span><span style="display:flex;"><span>        dbtype <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;pgsql&#34;</span>;
</span></span><span style="display:flex;"><span>        adminuser <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;admin&#34;</span>;
</span></span><span style="display:flex;"><span>        adminpassFile <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/path/to/nextcloud-admin-pass&#34;</span>;
</span></span><span style="display:flex;"><span>      };
</span></span><span style="display:flex;"><span>    };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    onlyoffice <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>      enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>      hostname <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;onlyoffice.example.com&#34;</span>;
</span></span><span style="display:flex;"><span>    };
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div><p>You may want to proceed with caution while setting up the OnlyOffice server, which will allow for Google Docs-like functionality on our Nextcloud instance, by having it only accessible inside your VPN or by setting the <code>services.onlyoffice.jwtSecretFile</code> option if exposed to the public Internet.</p>
<p>With this snippet, a Nextcloud instance with a selection of pre-installed Apps, PostgreSQL as a database, Redis Caching and Let&rsquo;s Encrypt certificates will be set up for you.</p>
<p>To connect to the OnlyOffice server, configure it appropriately in Administration settings &gt; ONLYOFFICE &gt; ONLYOFFICE Docs address.</p>
<h2 id="backups">Backups</h2>
<p>In this configuration, we need to persist the <code>/var/lib/nextcloud</code> and <code>/var/lib/postgresql</code> directories.</p>
<p>For backing up, you could copy  <code>/var/lib/nextcloud</code> to another computer and, for the database, dump it to a file and copy it to another computer as well, as described <a href="https://docs.nextcloud.com/server/latest/admin_manual/maintenance/backup.html">in the official Nextcloud documentation</a>.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Once again, NixOS proves itself as an amazing self-hosting platform.</p>
<p>Nextcloud, in its default configuration, is sometimes known for running slow.
Thanks to NixOS, we&rsquo;ve optimized its performance and that&rsquo;s quite impactful, as it&rsquo;s my most used self-hosted application.
Having all of these apps running on Nextcloud has enabled me to move on from GSuite to a mostly autonomous and self-hosted infrastructure.</p>
<p>In the future, I look forward to being able to use Collabora/Nextcloud Office instead of OnlyOffice, as it&rsquo;s more aligned with Nextcloud&rsquo;s philosophical goals and hasn&rsquo;t done <a href="https://help.nextcloud.com/t/onlyoffice-removed-web-mobile-editing-from-version-5-5-0-of-community-document-server/74360">suspicious decisions in the past</a>.</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://nixos.wiki/wiki/Nextcloud">https://nixos.wiki/wiki/Nextcloud</a></li>
<li><a href="https://nixos.wiki/wiki/Onlyoffice-Documentserver">https://nixos.wiki/wiki/Onlyoffice-Documentserver</a></li>
<li><a href="https://docs.nextcloud.com/server/latest/admin_manual/maintenance/backup.html">https://docs.nextcloud.com/server/latest/admin_manual/maintenance/backup.html</a></li>
<li><a href="https://docs.nextcloud.com/server/latest/admin_manual/maintenance/restore.html">https://docs.nextcloud.com/server/latest/admin_manual/maintenance/restore.html</a></li>
</ul>
]]></content:encoded>
    </item>
  </channel>
</rss>
