Skip to content

PhysShell/nix-devkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Nix Development Kit

. A collection of Nix flake modules running on top of devenv I find useful to have. And it's a place for my nixperiments :) Updates are totally random.

Features

DCM Integration

This devkit provides seamless integration with DCM (Dart Code Metrics) module that:

  • Automatically uses FHS-patched DCM - No need to manually specify the package (didn't get it working with patchelf)
  • Creates project symlinks - DCM binary is symlinked to .devkit/bin/dcm for easy IDE integration
  • Works out of the box - Just enable the module and start using DCM

Usage

Quick Start with Template

Use the DCM template to create a new project (If you want to use someone else's templates, copy them into your own repo - you aren't really reproducible if you rely on someone else's GitHub repo):

nix flake init --template github:yourusername/nix-devkit#dcm

Manual Setup

Add to your project's flake.nix:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    devenv.url = "github:cachix/devenv";
    devkit = {
      url = "github:yourusername/nix-devkit?dir=devkit";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { nixpkgs, devenv, devkit, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };
    in {
      devShells.${system}.default = devenv.lib.mkShell {
        inherit pkgs;
        inputs = { inherit nixpkgs devenv; };
        modules = [
          ({ ... }: { _module.args.self = devkit; })
          devkit.devenvModules.dcm
          ({ ... }: { devkit.dcm.enable = true; })
        ];
      };
    };
}

Running Development Environment

Important: Use --impure or --no-pure-eval flag when running nix develop:

# Recommended
nix develop --impure

# Or alternative
nix develop --no-pure-eval

This is required for the module to properly access and integrate with the devkit packages.

The other way would be to use devenv shell but it's not shown here for now.

Configuration Options

devkit.dcm = {
  enable = true;  # Enable DCM integration
  
  # Optional: specify custom DCM package (overrides auto-selection)
  # package = pkgs.dcm;
  
  # Optional: disable preference for devkit's FHS-patched DCM
  # preferSelfPackage = false;
  
  # Optional: customize symlink path
  # linkPath = ".devkit/bin/dcm";
};

IDE Integration

After running nix develop --impure, DCM will be available:

  • In PATH: dcm --version
  • As project symlink: .devkit/bin/dcm --version

For VS Code it works automatically if you launch it from nix develop's shell, just install the extension, alternatively you can use nix-env-selector extension.

Add .devkit to .gitignore to keep your repo clean


Development Commands (Internal Reference)

Evaluate flake: nix flake check

Run smoke test from devkit directory: "DEVENV_ROOT="$PWD" nix develop --impure .#dcm-smoke -c bash -lc ' set -euo pipefail test -x .devkit/bin/dcm .devkit/bin/dcm --version >/dev/null echo "OK: dcm is linked and runs" '", or "nix develop --command .devkit/bin/dcm --version"

Make devkit accessible without providing specific url every time: nix registry add devkit git+file:../devkit, in flake.nix: inputs.devkit.url = "devkit";

Check local changes (commited): "nix flake lock --override-input devkit 'git+file:///home/physshell/Documents/repos/nix-devkit?ref=main&dir=devkit'"

Check localchanges (uncommited): "nix develop --override-input devkit 'path:/home/physshell/Documents/repos/nix-devkit/devkit'"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages