Skip to content

Frontear/nix-wrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nix Wrap

A powerful wrapping alternative for Nix/OS.

The main goal of this is to provide isolated filesystems powered by Bubblewrap that keep program configurations. This provides a cleaner home alongside a more pure and isolated approach to configuration.

Table Of Contents

Installing

  1. Add nix-wrap to your flake inputs and nix-wrap.nixosModules.default to your configuration(s):
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  inputs.nix-wrap.url = "github:Frontear/nix-wrap";

  outputs = { nixpkgs, nix-wrap, ... } @ inputs: {
    nixosConfigurations."my-host123" = nixpkgs.lib.nixosSystem {
      modules = [
        nix-wrap.nixosModules.default

        ./configuration.nix
      ];
    };
  };
}

Usage

  1. Declare a new wrapper.<name> block in your configuration, following the provided format:
{
  config,
  pkgs,
  ...
}:
{
  wrappers.my-app = {
    # This app will be immediately run when accessing the drv.
    program = pkgs.my-app;

    # Paths are of format { src = ...; dest = ...; }, where
    #   - src is a relative path to your config file
    #   - dest is a string path that is bind mounted to the bwrap.
    paths = [
      {
        src = ./config.json;
        dest = ".config/my-app/config.json";
      }
    ];
  };

  environment.systemPackages = [
    # Adds the final wrapped package to your environment
    config.wrappers.my-app.package
  ];
}
  1. Run your program via <name>-wrapper. The above example would be run via my-app-wrapper, which will drop you into a bwrap that exists immediately when the program closes.

Note

For testing purposes this flake exposes a few wrapped applications. Check them out and run them using nix run .#wrapped-<name>!

License

All code in this project is licensed under the MIT License. This was an intentional choice to hopefully ease integration into nixpkgs.

About

A powerful wrapping alternative for Nix/OS that isolates programs and contains configuration within isolated environments, powered by Bubblewrap.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors