NixOS and Nix Flakes Development

VerifiedSafe

Specialized in NixOS and Nix flake development for multi-repo architectures, airgapped deployments, and K3s infrastructure. Covers flake.nix, NixOS modules, derivations, devShells, overlays, OCI image packaging, and composing multiple flake repositories. Useful when managing declarative infrastructure with NixOS or packaging applications for airgapped environments.

Sby Skills Guide Bot
DevelopmentAdvanced
6/2/2026
Claude Code
#nixos#nix-flakes#declarative-infrastructure#devops#package-management

Recommended for

Automated summary

This skill enables NixOS configuration and Nix flake development for multi-repo architectures, airgapped deployments, and K3s infrastructure, providing patterns for composing flakes, modules, derivations, and OCI image packaging.

Strengths

  • Comprehensive coverage of NixOS and Nix flake patterns, including multi-repo composition.
  • Handles advanced scenarios like airgapped deployments and OCI image packaging.
  • Provides efficient patterns for conditional module loading and lazy evaluation.
  • Integrates with Kubernetes tooling (Helm, Kustomize) within Nix builds.

Limitations

  • Requires substantial Nix language expertise to use effectively.
  • The advanced patterns (airgapped, multi-repo) may not be needed for simpler single-machine setups.
  • Documentation references are only linked, not embedded, so the user may need to consult additional files.
When to use it

Use this skill when managing complex NixOS fleets, multiple repos with shared dependencies, or when deploying NixOS to airgapped or K3s environments.

When not to use it

Do not use for simple single-machine NixOS configurations where standard NixOS guides suffice, or if you are new to Nix and need basic setup guidance.

Security analysis

Safe
Quality score90/100

The skill is a reference document for NixOS development, containing only standard and necessary commands for building, developing, and deploying Nix configurations. No malicious, destructive, or exfiltrating instructions are present.

No concerns found

How this analysis is made

Examples

Create a multi-repo flake setup
Help me set up a Nix flake that depends on an internal Git repository and pins the same nixpkgs version across both repos.
Package an OCI image for airgapped deployment
Write a Nix derivation that downloads a Docker image and outputs it as an OCI tarball for use in an airgapped environment.
Build a NixOS module with conditional options
Create a NixOS module with an enable option that conditionally loads additional configuration using `lib.mkIf`.

name: nixos description: NixOS and Nix flake development for multi-repo architectures, airgapped deployments, and K3s infrastructure. Use when working with flake.nix files, NixOS modules, derivations, devShells, overlays, OCI image packaging, or composing multiple flake repositories. Covers Nix language syntax, flake inputs/outputs, nixosModules exports, stdenv.mkDerivation, and home-manager integration.

NixOS Development

Overview

Build and maintain NixOS configurations using Nix flakes. Focus on multi-repo composition, airgapped deployments, and declarative infrastructure.

Quick Reference

| Task | Command | |------|---------| | Build package | nix build .#packageName | | Enter devShell | nix develop | | Update flake inputs | nix flake update | | Update single input | nix flake lock --update-input nixpkgs | | Show flake outputs | nix flake show | | Check flake | nix flake check | | Rebuild NixOS | sudo nixos-rebuild switch --flake .#hostname | | Build ISO | nix build .#nixosConfigurations.iso.config.system.build.isoImage |

Flake Structure

Standard multi-repo flake pattern:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    # Pin dependent flakes to same nixpkgs
    other-flake.url = "git+ssh://gitlab.example.com/repo";
    other-flake.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, other-flake, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };
    in {
      # NixOS system configurations
      nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
        inherit system;
        modules = [
          other-flake.nixosModules.default
          ./configuration.nix
        ];
      };

      # Reusable NixOS modules
      nixosModules.default = import ./modules;

      # Packages
      packages.${system} = { /* ... */ };

      # Development shells
      devShells.${system}.default = pkgs.mkShell { /* ... */ };
    };
}

NixOS Module Pattern

Export modules for composition:

# modules/default.nix
{ config, lib, pkgs, ... }:
{
  imports = [ ./service.nix ];

  options.myModule.enable = lib.mkEnableOption "my module";

  config = lib.mkIf config.myModule.enable {
    # configuration here
  };
}

OCI Image Packaging

For airgapped deployments, package images as store paths:

# Single image to OCI tarball
imagePackage = pkgs.runCommand "image-name" {
  buildInputs = [ pkgs.skopeo ];
} ''
  skopeo copy docker://registry/image:tag oci-archive:$out
'';

Helm + Kustomize in Nix

Render manifests at build time:

manifests = pkgs.runCommand "manifests" {
  buildInputs = [ pkgs.kubernetes-helm pkgs.kustomize ];
} ''
  helm template release ${./chart} --namespace ns > base.yaml
  kustomize build ${./overlays} > $out
'';

Detailed References

For comprehensive documentation on specific topics:

| Topic | Reference File | |-------|----------------| | Nix language syntax | references/nix-language.md | | Flake inputs/outputs | references/flakes.md | | NixOS modules & options | references/nixos-modules.md | | Packaging & derivations | references/packaging.md | | DevShells & overlays | references/devshells.md | | Home Manager | references/home-manager.md |

Common Patterns

Pin nixpkgs across repos

Use inputs.X.inputs.nixpkgs.follows = "nixpkgs" to ensure consistent package versions.

Conditional module loading

imports = lib.optionals config.feature.enable [ ./optional-module.nix ];

Lazy evaluation with mkIf

Always use lib.mkIf for conditional config to avoid infinite recursion:

config = lib.mkIf config.myService.enable { /* ... */ };

Override priorities

  • lib.mkDefault (priority 1000) - easily overridable defaults
  • lib.mkForce (priority 50) - force value regardless of other definitions
  • lib.mkOverride N - custom priority (lower = higher priority)

Troubleshooting

"error: getting status of '/nix/store/...': No such file or directory"

Missing store path. Run nix build or ensure binary cache is configured.

"error: infinite recursion encountered"

Using config values in imports or not wrapping conditional config in lib.mkIf.

"error: attribute 'X' missing"

Check flake inputs match expected names. Verify follows directives.

Flake not seeing local changes

Run git add . - flakes ignore untracked files.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/nixos-and-nix-flakes-development-mm5t8ag6/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/nixos-and-nix-flakes-development-mm5t8ag6' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/nixos-and-nix-flakes-development-mm5t8ag6/download' --output '.skill-downloads/nixos-and-nix-flakes-development-mm5t8ag6/SKILL.md.part' && mv '.skill-downloads/nixos-and-nix-flakes-development-mm5t8ag6/SKILL.md.part' '.skill-downloads/nixos-and-nix-flakes-development-mm5t8ag6/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Original excerpt: Quick Reference
TaskCommand
Build packagenix build .#packageName
Enter devShellnix develop
Update flake inputsnix flake update
Update single inputnix flake lock --update-input nixpkgs
Show flake outputsnix flake show
Check flakenix flake check
Rebuild NixOSsudo nixos-rebuild switch --flake .#hostname
Build ISOnix build .#nixosConfigurations.iso.config.system.build.isoImage

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/nixos-and-nix-flakes-development-mm5t8ag6/SKILL.md' && test -s '.skill-downloads/nixos-and-nix-flakes-development-mm5t8ag6/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/nixos' && cp -R '.skill-downloads/nixos-and-nix-flakes-development-mm5t8ag6' '.claude/skills/nixos'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/nixos-and-nix-flakes-development-mm5t8ag6'

openskills read 'nixos-and-nix-flakes-development-mm5t8ag6'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/nixos-and-nix-flakes-development-mm5t8ag6/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills