diff --git a/build.nix b/build.nix index 4a4b7b06..4927519c 100644 --- a/build.nix +++ b/build.nix @@ -1,12 +1,31 @@ -{ lib, stdenv, pkg-config, attr, libuuid, libsodium, keyutils, liburcu, zlib -, libaio, udev, zstd, lz4, nix-gitignore, rustPlatform, rustc, cargo, fuse3 -, fuseSupport ? false, }: +{ + lib, + stdenv, + pkg-config, + attr, + libuuid, + libsodium, + keyutils, + liburcu, + zlib, + libaio, + udev, + zstd, + lz4, + nix-gitignore, + rustPlatform, + rustc, + cargo, + fuse3, + fuseSupport ? false, +}: let src = nix-gitignore.gitignoreSource [ ] ./.; commit = lib.strings.substring 0 7 (builtins.readFile ./.bcachefs_revision); version = "git-${commit}"; -in stdenv.mkDerivation { +in +stdenv.mkDerivation { inherit src version; pname = "bcachefs-tools"; @@ -39,11 +58,13 @@ in stdenv.mkDerivation { # when git-based crates are updated, run: # nix run github:Mic92/nix-update -- --version=skip --flake default # to update the hashes - cargoDeps = rustPlatform.importCargoLock { - lockFile = "${src}/Cargo.lock"; - }; + cargoDeps = rustPlatform.importCargoLock { lockFile = "${src}/Cargo.lock"; }; - makeFlags = [ "DESTDIR=${placeholder "out"}" "PREFIX=" "VERSION=${commit}" ]; + makeFlags = [ + "DESTDIR=${placeholder "out"}" + "PREFIX=" + "VERSION=${commit}" + ]; dontStrip = true; checkPhase = "./target/release/bcachefs version"; diff --git a/default.nix b/default.nix index 80aeb433..6466507b 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,9 @@ -(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock); -in fetchTarball { - url = - "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; -}) { src = ./.; }).defaultNix +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } +) { src = ./.; }).defaultNix diff --git a/flake.nix b/flake.nix index 01a79e7c..aeef1392 100644 --- a/flake.nix +++ b/flake.nix @@ -9,18 +9,25 @@ flake = false; }; - outputs = { self, nixpkgs, utils, ... }: + outputs = { - overlays.default = final: prev: { - bcachefs = final.callPackage ./build.nix { }; - }; - } // utils.lib.eachDefaultSystem (system: + self, + nixpkgs, + utils, + ... + }: + { + overlays.default = final: prev: { bcachefs = final.callPackage ./build.nix { }; }; + } + // utils.lib.eachDefaultSystem ( + system: let pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }; - in { + in + { packages = { inherit (pkgs) bcachefs; bcachefs-fuse = pkgs.bcachefs.override { fuseSupport = true; }; @@ -29,12 +36,31 @@ formatter = pkgs.nixfmt-rfc-style; - devShells.default = pkgs.callPackage ({ mkShell, rustc, cargo, gnumake - , gcc, clang, pkg-config, libuuid, libsodium, keyutils, liburcu, zlib - , libaio, zstd, lz4, udev, bcachefs }: + devShells.default = pkgs.callPackage ( + { + mkShell, + rustc, + cargo, + gnumake, + gcc, + clang, + pkg-config, + libuuid, + libsodium, + keyutils, + liburcu, + zlib, + libaio, + zstd, + lz4, + udev, + bcachefs, + }: mkShell { LIBCLANG_PATH = "${clang.cc.lib}/lib"; inherit (bcachefs) nativeBuildInputs buildInputs; - }) { }; - }); + } + ) { }; + } + ); }