Loading...
Loading...
Creates reproducible builds, manages flake inputs, defines devShells, and builds packages with flake.nix. Use when initializing Nix projects, locking dependencies, or running nix build/develop commands.
npx skill4agent add knoopx/pi nix-flakes# Initialize a new flake in the current directory
nix flake init
# Create a new flake from template
nix flake new hello -t templates#hello
# Update flake.lock (updates all inputs)
nix flake update
# Update specific input only
nix flake update nixpkgs
# Lock without updating (create missing entries)
nix flake lock
# Check flake for syntax and common errors
nix flake check
# Show flake outputs
nix flake show
# Show flake metadata (inputs, revisions)
nix flake metadata path:.
nix flake info path:. # Alias for metadata
# Prefetch flake and inputs into store
nix flake prefetch github:NixOS/nixpkgs
nix flake prefetch-inputs path:.
# Clone flake repository
nix flake clone nixpkgs --dest ./nixpkgspath:path:.# Build the default package
nix build path:.
# Build a specific output
nix build path:.#packageName
# Run the default app
nix run path:.
# Run a specific app from a flake
nix run path:.#appName
# Run an app from a remote flake
nix run github:numtide/treefmtnix develop--command# Run a command inside the devShell
nix develop path:. --command make build
# Check if current environment matches devShell
nix develop path:. --command envflake.nixflake.nix{
description = "A basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
packages.${system}.default = pkgs.hello;
devShells.${system}.default = pkgs.mkShell {
buildInputs = [ pkgs.git pkgs.vim ];
};
};
}flake.locknix develop--command# Inspect inputs
nix flake metadata path:.
# Evaluate a specific output
nix eval path:.#packages.x86_64-linux.default.name