スキル一覧に戻る
FlexNetOS

nix-environment

by FlexNetOS

0🍴 0📅 2026年1月21日
GitHubで見るManusで実行

SKILL.md


name: nix-environment description: Nix flakes, home-manager, and reproducible environment management icon: ❄️ category: environment tools:

  • nix
  • nom
  • direnv
  • home-manager

Nix Environment Skills

Overview

This skill provides expertise in Nix-based environment management including flakes, home-manager, and cross-platform configurations.

Development Shell

Enter Environment

nom develop                           # Preferred (with progress UI)
nix develop                           # Standard
direnv allow                          # Automatic via direnv

Shell Commands (defined in devshell)

CommandDescription
cbcolcon build --symlink-install
ctcolcon test
ctrcolcon test-result --verbose
ros2-envShow ROS2 environment variables
update-depsRun pixi update
aiAI chat assistant (aichat)
pairAI pair programming (aider)

Flake Operations

Check and Validate

nix flake check                       # Validate flake
nix flake check --no-build            # Quick syntax check
nix flake show                        # Show flake outputs

Update Dependencies

nix flake update                      # Update all inputs
nix flake lock --update-input nixpkgs # Update specific input

Build Outputs

nix build .#package                   # Build specific output
nix build -L                          # Build with logs
nix log /nix/store/...                # View build log

Package Management

Nix Profile

nix profile install nixpkgs#package   # Install package
nix profile remove package            # Remove package
nix profile list                      # List installed
nix profile upgrade '.*'              # Upgrade all

Search Packages

nix search nixpkgs package            # Search nixpkgs
nix search nixpkgs#python3Packages.X  # Search Python packages

Home Manager

Importing Modules

This flake exports home-manager modules that can be imported:

{
  inputs = {
    ripple-env.url = "github:FlexNetOS/ripple-env";
    home-manager.url = "github:nix-community/home-manager";
  };

  outputs = { self, nixpkgs, home-manager, ripple-env, ... }: {
    homeConfigurations.myuser = home-manager.lib.homeManagerConfiguration {
      pkgs = nixpkgs.legacyPackages.x86_64-linux;
      modules = [
        ripple-env.homeManagerModules.default
        # Your modules...
      ];
    };
  };
}

Available Exports

ExportDescription
homeManagerModules.defaultAll modules (platform-detected)
homeManagerModules.commonCross-platform modules only
homeManagerModules.linuxLinux-specific modules
homeManagerModules.macosmacOS-specific modules
nixosModules.defaultNixOS system module
darwinModules.defaultnix-darwin module
libUtility functions

Module Options

Each module supports enable/disable:

{
  ros2-env.shell.zsh.enable = true;
  ros2-env.shell.nushell.enable = true;
  ros2-env.editor.helix.enable = true;
  ros2-env.direnv.enable = true;
}

Pixi Integration

Package Management

pixi add <package>                    # Add package
pixi remove <package>                 # Remove package
pixi search <pattern>                 # Search packages
pixi update                           # Update lockfile
pixi install                          # Install from lockfile
pixi info                             # Environment info

ROS2 Packages

pixi add ros-humble-desktop           # Full desktop
pixi add ros-humble-rviz2             # Visualization
pixi search ros-humble-*              # List all ROS packages

direnv Configuration

Setup

direnv allow                          # Allow directory
direnv deny                           # Deny directory
direnv reload                         # Reload environment

.envrc File

# Standard flake integration
use flake

# With nix-direnv caching
use flake . --impure

Cross-Platform Support

Platform Detection in Nix

{ pkgs, lib, ... }:
let
  isLinux = pkgs.stdenv.isLinux;
  isDarwin = pkgs.stdenv.isDarwin;
in {
  config = lib.mkMerge [
    (lib.mkIf isLinux { /* Linux config */ })
    (lib.mkIf isDarwin { /* macOS config */ })
  ];
}

Windows/WSL2

  • Use bootstrap.ps1 for automated setup
  • NixOS-WSL provides full Nix experience
  • See: .github/docs/self-hosted-runner-setup.md

Debugging

Flake Issues

nix flake check                       # Check for errors
nix flake show                        # Show structure
nix eval .#someOutput                 # Evaluate expression
nix repl                              # Interactive REPL

Build Issues

nix build -L                          # Verbose build output
nix log /nix/store/hash-name          # View stored log
nix-store -q --references /nix/store/path  # Show dependencies

Cache Issues

nix store gc                          # Garbage collect
nix store optimise                    # Deduplicate store
nix-collect-garbage -d               # Remove old generations

Module Structure

Creating a New Module

{ config, lib, pkgs, ... }:
{
  options.mymodule = {
    enable = lib.mkEnableOption "my module";

    setting = lib.mkOption {
      type = lib.types.str;
      default = "value";
      description = "Setting description";
    };
  };

  config = lib.mkIf config.mymodule.enable {
    # Implementation
    home.packages = [ pkgs.sometool ];
  };
}

Module Location

  • Cross-platform: modules/common/
  • Linux-specific: modules/linux/
  • macOS-specific: modules/macos/

Best Practices

  1. Lock dependencies - Commit flake.lock
  2. Use mkIf - For conditional configuration
  3. Type options - Use lib.types.* for validation
  4. Document options - Add description to each option
  5. Platform check - Use stdenv.isLinux/isDarwin

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です