Go to file
Austin Seipp fa36882a73 nix: add nix expressions for development
This adds Nix expressions for bcachefs-tools that are modular, work in
purely sandboxed build environments (e.g. on NixOS itself, or macOS, where
sandboxing is enabled by default), use a fixed copy of Nixpkgs (to avoid hidden,
global state) and uses standard build idioms.

This change uses a fixed version of Nixpkgs, one that will always be used for
every build of bcachefs-tools, for all users, rather than relying on whatever
copy of Nixpkgs the user has available.

This has a major benefit in that it allows the build to work in sandboxed
environments such as NixOS, and it correctly declares all of the necessary
dependencies that bcachefs-tools needs. This is done simply by using
stdenv.mkDerivation in order to write a "normal" Nix expression, where the
previous version used a variant of the stdenv builder, but this isn't needed for
the most part. (Doing this has other knock-on benefits, such as the usage of
standardized options like `enableParallelBuild = true;` -- allowing `nix-build`
to automatically do parallel builds, etc.)

Another major benefit of this change is that anyone can now use `nix-shell` to
develop/hack on bcachefs-tools incrementally; simply running nix-shell will put
you in a Bash shell environment where all of bcachefs-tools' dependencies are
proprerly provided, no matter the state of the outside build environment/host
operating system:

    $ nix-shell

    [nix-shell:~/src/bcachefs-tools]$ make -j4 # works immediately

As mentioned before, with this change, by default, nix-build and
nix-shell run using a prepackaged copy of an upstream Nixpkgs snapshot. This is
done purely to ensure anyone who builds bcachefs-tools using Nix does, in fact,
get a reproducible build. Without this, nix-build defaults to using the the
`<nixpkgs>` NIX_PATH entry in order to fetch dependencies; meaning that two
users on different channels will get different results (for example, if you have
the November 2017 channel but I have the October 2017 channel, the results may
be different).

With this patch, a user running

    $ nix-build

will always use the exact same copy of nixpkgs to bootstrap the build,
regardless of whatever channels the user has. This bootstrap mechanism does not
even depend on an existing copy of Nixpkgs itself; e.g. it can work with a
completely empty `NIX_PATH`.

This is arguably anti-modular, but for end-user applications like
bcachefs-tools, fixing the version of Nixpkgs is not normally a huge deal. Users
who wish to use a different copy of Nixpkgs can provide this with an argument to
nix-build directly, using the `nixpkgs` argument to the expression:

    $ nix-build --pure --arg nixpkgs 'import <nixpkgs> {}'

This uses the `<nixpkgs>` provided inside your `NIX_PATH` environment variable
to acquire dependencies, which by default is managed using `nix-channel`. If you
have a copy of the Nixpkgs source code e.g. from a `git clone`, you may use that
too by simply using `-I` to prepend your Nixpkgs to `NIX_PATH` (see `man
nix-build` for more):

    $ nix-build --pure \
        -I nixpkgs=$HOME/src/nixpkgs \
        --arg nixpkgs 'import <nixpkgs> {}'

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2017-12-10 16:07:33 -06:00
ccan Update for new superblock options; makefile improvements 2017-10-08 10:25:36 -08:00
debian Rename from bcache-tools to bcachefs-tools 2017-03-19 17:31:47 -08:00
include Update bcachefs sources to 9e7ae5219c bcachefs: Make write points more dynamic 2017-11-22 00:50:47 -05:00
libbcachefs Update bcachefs sources to 9e7ae5219c bcachefs: Make write points more dynamic 2017-11-22 00:50:47 -05:00
linux Simple stupid memory reclaim code 2017-11-12 16:48:07 -05:00
nix nix: add nix expressions for development 2017-12-10 16:07:33 -06:00
.bcachefs_revision Update bcachefs sources to 9e7ae5219c bcachefs: Make write points more dynamic 2017-11-22 00:50:47 -05:00
.gitignore nix: add nix expressions for development 2017-12-10 16:07:33 -06:00
bcachefs.8 Rename from bcache-tools to bcachefs-tools 2017-03-19 17:31:47 -08:00
bcachefs.c bcachefs: make usage output more consistent 2017-12-10 16:03:25 -06:00
cmd_assemble.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
cmd_debug.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
cmd_device.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
cmd_format.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
cmd_fs.c Fix some clang warnings 2017-04-04 06:43:08 -08:00
cmd_fsck.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
cmd_key.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
cmd_migrate.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
cmd_run.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
cmds.h Add commands for changing and removing passphrase 2017-11-08 16:06:37 -09:00
config.h Redo lots of stuff 2016-03-11 21:18:42 -09:00
COPYING
crypto.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
crypto.h Add commands for changing and removing passphrase 2017-11-08 16:06:37 -09:00
default.nix nix: add nix expressions for development 2017-12-10 16:07:33 -06:00
fsck.bcachefs Rename from bcache-tools to bcachefs-tools 2017-03-19 17:31:47 -08:00
INSTALL cmd_migrate: fix xattrs 2017-03-10 11:48:39 -09:00
libbcachefs.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
libbcachefs.h build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
Makefile build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
mkfs.bcachefs Rename from bcache-tools to bcachefs-tools 2017-03-19 17:31:47 -08:00
qcow2.c cmd_migrate 2017-03-09 09:14:11 -09:00
qcow2.h cmd_migrate 2017-03-09 09:14:11 -09:00
README Rename from bcache-tools to bcachefs-tools 2017-03-19 17:31:47 -08:00
tools-util.c build: require explicit include paths for libbcachefs/ 2017-12-10 16:06:01 -06:00
tools-util.h Faster crc32c 2017-10-08 10:20:36 -08:00

Userspace tools for bcachefs

This builds the bcachefs tool, which has a number of subcommands for formatting
and managing bcachefs filesystems:

bcachefs format
bcachefs unlock
bcachefs assemble
bcachefs incremental
etc.

Run bcachefs --help for full list of commands.