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.
- Add
nix-wrapto your flake inputs andnix-wrap.nixosModules.defaultto 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
];
};
};
}- 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
];
}- Run your program via
<name>-wrapper. The above example would be run viamy-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>!
All code in this project is licensed under the MIT License. This was an intentional choice to hopefully ease integration into nixpkgs.