oliverdavies.uk/content/node.8b84ccf4-bb4b-48fd-8009-2c2641466185.yml

126 lines
4.6 KiB
YAML
Raw Normal View History

2025-07-10 00:14:12 +01:00
uuid:
- value: 8b84ccf4-bb4b-48fd-8009-2c2641466185
langcode:
- value: en
type:
- target_id: daily_email
target_type: node_type
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
revision_timestamp:
- value: '2025-05-11T09:00:38+00:00'
revision_uid:
- target_type: user
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
revision_log: { }
status:
- value: true
uid:
- target_type: user
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
title:
- value: |
Docker or Nix?
created:
- value: '2023-07-02T00:00:00+00:00'
changed:
- value: '2025-05-11T09:00:38+00:00'
promote:
- value: false
sticky:
- value: false
default_langcode:
- value: true
revision_translation_affected:
- value: true
path:
- alias: /daily/2023/07/02/docker-or-nix
langcode: en
body:
- value: |
<p>I've been a Nix user for about a year, starting with its package manager on my previously installed Linux distribution.</p>
<p>I started to use Home Manager for my user configuration and dotfiles and later switched to the NixOS operating system.</p>
<h2 id="using-nix-for-software-development">Using Nix for software development</h2>
<p>I've also been using Nix Flakes for per-project configuration.</p>
<p>A Flake file is a simple file written in the Nix language that defines the project's dependencies and installs them from the Nix package manager.</p>
<p>Here is an example Flake for a PHP CLI application:</p>
<pre><code class="nix">{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  outputs = inputs@{ flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      systems = [ "x86_64-linux" ];
      perSystem = { config, self', inputs', pkgs, system, ... }: {
        devShells = {
          default = pkgs.mkShell {
            buildInputs = with pkgs; [ php82 php82Packages.composer ];
          };
        };
      };
    };
}
</code></pre>
<p>It declares that PHP 8.2 and Composer are available, even if I have different versions installed globally.</p>
<h2 id="will-nix-replace-docker%3F">Will Nix replace Docker?</h2>
<p>Nix and Flakes have replaced Docker for me on some projects.</p>
<p>If I have a simple setup and need a specific version of PHP or Node and some additional programs, I can get those from the Flake.</p>
<p>I don't know if it'll replace Docker for me completely and work on more complex projects, but it's working well for me where I'm using it.</p>
format: full_html
processed: |
<p>I've been a Nix user for about a year, starting with its package manager on my previously installed Linux distribution.</p>
<p>I started to use Home Manager for my user configuration and dotfiles and later switched to the NixOS operating system.</p>
<h2 id="using-nix-for-software-development">Using Nix for software development</h2>
<p>I've also been using Nix Flakes for per-project configuration.</p>
<p>A Flake file is a simple file written in the Nix language that defines the project's dependencies and installs them from the Nix package manager.</p>
<p>Here is an example Flake for a PHP CLI application:</p>
<pre><code class="nix">{
&nbsp; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
&nbsp; outputs = inputs@{ flake-parts, ... }:
&nbsp; &nbsp; flake-parts.lib.mkFlake { inherit inputs; } {
&nbsp; &nbsp; &nbsp; systems = [ "x86_64-linux" ];
&nbsp; &nbsp; &nbsp; perSystem = { config, self', inputs', pkgs, system, ... }: {
&nbsp; &nbsp; &nbsp; &nbsp; devShells = {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default = pkgs.mkShell {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buildInputs = with pkgs; [ php82 php82Packages.composer ];
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; };
&nbsp; &nbsp; &nbsp; &nbsp; };
&nbsp; &nbsp; &nbsp; };
&nbsp; &nbsp; };
}
</code></pre>
<p>It declares that PHP 8.2 and Composer are available, even if I have different versions installed globally.</p>
<h2 id="will-nix-replace-docker%3F">Will Nix replace Docker?</h2>
<p>Nix and Flakes have replaced Docker for me on some projects.</p>
<p>If I have a simple setup and need a specific version of PHP or Node and some additional programs, I can get those from the Flake.</p>
<p>I don't know if it'll replace Docker for me completely and work on more complex projects, but it's working well for me where I'm using it.</p>
summary: null
field_daily_email_cta: { }