Sign inSign up

pipex/sweet-home

By pipex

•Updated over 1 year ago

Your $HOME in a container

Image
0

2.4K

pipex/sweet-home repository overview

⁠sweet-home

This project provides an quick way to set up a container to serve as a temporary (or permanent) work environment, for those instances where you may find yourself working in a different computer and want your favorite tools at your disposal.

⁠Features

⁠Usage

⁠Quickstart

You can launch a container using one of the pre-built images in hub.docker.com⁠ (only amd64 and aarch64 architectures are supported).

docker run --rm --name sweet-home -ti -v packages:/nix -v home:/home/me pipex/sweet-home

On start, the container will update the local list of packages from the nix channel and run home-manager switch to setup the home configuration, so on the first run it will take some time to get a shell prompt.

By design, the base system only includes a minimal set of packages, but the configuration can be easily extended making changes to ~/.config/nixpkgs/home.nix and running home-manager switch. The changes wil be persisted on the following run because of the flags -v packages:/nix -v home:/home/me that set up these directories as volumes.

A custom startup configuration can be provided to the container through the environment variable NIXPKGS_REPO_URL. The variable must point to a public git repository containing a valid home manager configuration, as it will used to replace the contents of the ~/.config/nixpkgs directory. For an example, see my personal configuration⁠.

docker run --rm --name sweet-home -ti -e NIXPKGS_REPO_URL=https://github.com/pipex/nixpkgs.git -v packages:/nix -v home:/home/me pipex/sweet-home

Here is some extra info on how to get started with home-manager⁠.

⁠Docker compose file

To use this image as part of a larger application, or to deploy to your own balenaCloud⁠ fleet, create a service in your docker-compose.yml as shown below.

version: '2.1'
services:
  home:
    image: pipex/sweet-home:latest
    privileged: true # (optional) use this is you want to have your container have access to the host
    network_mode: host # (optional) use this to add access to the host network interfaces
    command: sleep infinity # allows the container to run as a daemon
    restart: always
    environment:
      # This is to prevent the Balena supervisor from overriding this value to
      # ensure the right one is used. Do not change this as
      # it has no effect on the runtime username
      USER: 'me'
      # Setting the TZ env var allows for the local date
      # to be shown in tmux and as result of the `date` command
      TZ: 'America/Los_Angeles'
    volumes:
      - home:/home/me # Keep home files accross container restarts
      - pkgs:/nix # Keep package configuration accross container restarts

volumes:
  home:
  pkgs:
⁠Environment variables
NameDescriptionDefault Value
NIXPKGS_REPO_URLGit repository url pointing to a valid home manager configuration. The contents of the ~/.config/nixpkgs directory will be replaced by the contents of the repo
NIXPKGS_REPO_BRANCHRepository branch for the home manager configuration.

Tag summary

Content type

Image

Digest

sha256:540452fac…

Size

61.1 MB

Last updated

over 1 year ago

docker pull pipex/sweet-home