ワンクリックで
nixos-development
Best practices for using NixOS, Flakes, and direnv for reproducible development environments.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Best practices for using NixOS, Flakes, and direnv for reproducible development environments.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Best practices and guidelines for developing applications and applets for the COSMIC Desktop Environment.
Guidelines, idioms, and best practices for writing high-quality Rust code.
| name | NixOS Development |
| description | Best practices for using NixOS, Flakes, and direnv for reproducible development environments. |
This skill outlines how to use NixOS, Nix Flakes, and direnv to create robust, reproducible development environments.
flake.lock file.flake.nix. They provide all necessary compilers, tools, and libraries without polluting your global system.flake.nix)Every project should have a flake.nix in its root. A standard Rust project flake looks like this:
{
description = "My Rust Project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# Rust Toolchain
(rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
})
# Common Tools
pkg-config
openssl
# GUI/System Dependencies (Example for Cosmic/Iced)
wayland
libxkbcommon
vulkan-loader
];
# Environment Variables
shellHook = ''
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [
pkgs.wayland
pkgs.libxkbcommon
pkgs.vulkan-loader
]}:$LD_LIBRARY_PATH
echo "🚀 Development environment loaded!"
'';
};
}
);
}
direnv)To automatically activate the flake when you cd into the directory:
Install Direnv & Nix-Direnv:
Add this to your system configuration (configuration.nix or home-manager):
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
Create .envrc:
In your project root, create a file named .envrc with this single line:
use flake
Allow:
Run direnv allow in the terminal.
flake.lock. This guarantees that every developer uses the EXACT same version of Rust, external libraries, and system tools.just or cargo-nextest, add them to buildInputs in flake.nix.buildInputs. If a binary fails with "library not found", you likely need to add it to LD_LIBRARY_PATH in the shellHook.fenix or rust-overlay for managing Rust toolchains in Nix.RUST_SRC_PATH environment variable if rust-analyzer complains about missing source code.buildInputs. Run nix flake update to refresh inputs.code .). This ensures it inherits the direnv environment variables.nix-direnv is enabled. It caches the shell calculation.