This Nix Flake provides the DotBox command line package as well as a development shell and Nix library which allows you to import DotBox files into Nix.
You can try DotBox out without committing to installing it on your system by running the following command.
nix run github:snowfallorg/dotbox
You can install this package imperatively with the following command.
nix profile install github:snowfallorg/dotbox
You can install this package by adding it as an input to your Nix flake.
{
description = "My system flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
# Snowfall Lib is not required, but will make configuration easier for you.
snowfall-lib = {
url = "github:snowfallorg/lib";
inputs.nixpkgs.follows = "nixpkgs";
};
dotbox = {
url = "github:snowfallorg/dotbox";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs:
inputs.snowfall-lib.mkFlake {
inherit inputs;
src = ./.;
overlays = with inputs; [
# Use the overlay provided by this flake.
dotbox.overlay
# There is also a named overlay, though the output is the same.
dotbox.overlays."nixpkgs/snowfallorg"
];
};
}
If you've added the overlay from this flake, then in your system configuration
you can add the snowfallorg.dotbox
package.
{ pkgs }:
{
environment.systemPackages = with pkgs; [
snowfallorg.dotbox
];
}
If you want access to DotBox temporarily, you can enter a development shell available with this flake.
nix develop github:snowfallorg/dotbox
This flake provides a helper library for integrating DotBox with Nix. See the following example for information on using this flake's library.
{
description = "My flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
dotbox = {
url = "github:snowfallorg/dotbox";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, dotbox }:
let
# We require a NixPkgs instance in order to build DotBox files.
pkgs = nixpkgs.legacyPackages.x86_64-linux;
# Access helpers like `mkImporter` from `dotbox.lib`.
importer = dotbox.lib.mkImporter pkgs;
# Integrate your DotBox files with Nix!
my-config = importer.import ./my.box;
some-value = my-config.user.name.first;
in
{};
}
Construct a DotBox importer.
Type: Attrs -> Attrs
Usage:
mkImporter pkgs
Result:
{ import = file: { /* ... */ }; }