Skip to content

jmgilman/dev-container

Repository files navigation

dev-container

A devcontainer built on Debian and powered by Nix.

Features

Quickstart

Create a .devcontainer.json at the root of your repository with the following contents:

{
  "image": "jmgilman/dev-container:v1",
  "mounts": [
    "source=jmgilman-dev,target=/nix,type=volume",
    "source=jmgilman-dev-ext,target=/home/vscode/.vscode-server/extensions,type=volume",
    "source=jmgilman-dev-extin,target=/home/vscode/.vscode-server-insiders/extensions,type=volume"
  ],
  "remoteUser": "vscode",
  "settings": {
    "terminal.integrated.defaultProfile.linux": "zsh",
    "terminal.integrated.profiles.linux": {
      "zsh": {
        "path": "/home/vscode/.nix-profile/bin/zsh"
      }
    }
  }
}

Omitting anything from the above example is not recommended. The environment makes use of a variety of tools including Oh-My-Zsh and direnv, both of which rely on the terminal settings above being configured correctly. The mounted volume names should be changed to reflect your repository name.

Usage

The container utilizes the common Nix development practice of using direnv with a Nix flake. Your repository root should contain a .envrc file:

use flake

Along with a flake.nix file:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
        };
      in {
        devShell = pkgs.mkShell {
          packages = [
            pkgs.hello
          ];
        };
      }
    );
}

Once the container is loaded, opening up a new shell instance will drop you at the root of the repository and direnv will automatically load into the configured Nix development environment.

See the examples directory for more examples. For more detailed information, see the getting started guide.

Tooling

THe following tools are packaged with the container:

Name Description Source
bat A cat(1) clone with wings Link
batman Read system manual pages using bat Link
diff-so-fancy Good-lookin' diffs Link
direnv unclutter your .profile Link
fd A simple, fast and user-friendly alternative to find Link
fzf A command-line fuzzy finder Link
gh Github's official command line tool Link
jq Command-line JSON processor Link
ripgrep A modern replacement to grep Link
tldr Collaborative cheatsheets for console commands Link

Additional required tools should be included in your flake.nix. The default container user has sudo privileges if modifications are required.

Testing

You can run test/run.sh to run a rudimentary smoketest on the container. The test ensures that the image builds and the environment is configured as expected.

Contributing

Check out the issues for items needing attention or submit your own and then:

  1. Fork the repo (https://github.com/jmgilman/dev-container/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

About

A devcontainer built on Debian and powered by Nix.

Resources

License

Stars

Watchers

Forks

Packages 3