<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Package-Manager on Charlie Chiang's blog</title><link>https://charlie0129.github.io/blog/categories/package-manager/</link><description>Recent content in Package-Manager on Charlie Chiang's blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Thu, 27 Jun 2024 15:13:00 +0800</lastBuildDate><atom:link href="https://charlie0129.github.io/blog/categories/package-manager/index.xml" rel="self" type="application/rss+xml"/><item><title>macOS Nix First Taste</title><link>https://charlie0129.github.io/blog/p/macos-nix-first-taste/</link><pubDate>Thu, 27 Jun 2024 15:13:00 +0800</pubDate><guid>https://charlie0129.github.io/blog/p/macos-nix-first-taste/</guid><description>&lt;h2 id="note">Note
&lt;/h2>&lt;p>Note that this blog currently acts as a reference for me. It is not a comprehensive guide on why and how to use Nix on macOS.&lt;/p>
&lt;p>I chose nix because I am tired of Homebrew&amp;rsquo;s slowness and NOT PROVIDING BOTTLES (BINARY) FOR OLD MACOS VERSIONS.&lt;/p>
&lt;h2 id="install">Install
&lt;/h2>&lt;p>I am not using the official installer because it cannot survive macOS updates. Instead, I am using the Determinate System&amp;rsquo;s Nix Installer.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="nv">ARCH&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="k">$(&lt;/span>uname -m &lt;span class="p">|&lt;/span> sed &lt;span class="s1">&amp;#39;s/arm64/aarch64/&amp;#39;&lt;/span>&lt;span class="k">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nv">OS&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="k">$(&lt;/span>uname -s &lt;span class="p">|&lt;/span> tr &lt;span class="s1">&amp;#39;[:upper:]&amp;#39;&lt;/span> &lt;span class="s1">&amp;#39;[:lower:]&amp;#39;&lt;/span>&lt;span class="k">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">curl -L -o nix-installer https://github.com/DeterminateSystems/nix-installer/releases/latest/download/nix-installer-&lt;span class="nv">$ARCH&lt;/span>-&lt;span class="nv">$OS&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">chmod +x nix-installer
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Optionally, move nix-installer to your PATH&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># sudo install nix-installer /usr/local/bin&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">./nix-installer install --explain
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="pin-nixpkgs">Pin Nixpkgs
&lt;/h2>&lt;p>I don&amp;rsquo;t want to download a tarball and extract it every now and then. I know you can set tarball-ttl to a higher value, but I don&amp;rsquo;t want to do that either. Just pin nixpkgs.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">nix registry pin nixpkgs
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>If you are like me in China, you may want to use a mirror.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;substituters = https://mirrors.sjtug.sjtu.edu.cn/nix-channels/store/ https://cache.nixos.org/&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> sudo tee -a /etc/nix/nix.conf
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="using">Using
&lt;/h2>&lt;p>I wrote some scripts just to make my life easier.&lt;/p>
&lt;ul>
&lt;li>&lt;a class="link" href="https://github.com/charlie0129/dotfiles/blob/master/bin/common/nix-install" target="_blank" rel="noopener"
>nix-install&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="htts://github.com/charlie0129/dotfiles/blob/master/bin/common/nix-list" >nix-list&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="htts://github.com/charlie0129/dotfiles/blob/master/bin/common/nix-search" >nix-search&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="htts://github.com/charlie0129/dotfiles/blob/master/bin/common/nix-uninstall" >nix-uninstall&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="later-steps">Later Steps
&lt;/h2>&lt;p>There is &lt;a class="link" href="https://github.com/LnL7/nix-darwin" target="_blank" rel="noopener"
>nix-darwin&lt;/a> to make declarative configuration easier. I don&amp;rsquo;t have time to try it yet but I will definitely give it a try when I have time.&lt;/p></description></item></channel></rss>