mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-22 00:00:03 +03:00
nix: overhaul build system.
Removed outdated overlay. Simply build tooling using bingenHook and propagated*Inputs Signed-off-by: Daniel Hill <daniel@gluo.nz>
This commit is contained in:
parent
9d6040c8b6
commit
9a44c6d4d0
6
.editorconfig
Normal file
6
.editorconfig
Normal file
@ -0,0 +1,6 @@
|
||||
indent_style = tab
|
||||
indent_size = 8
|
||||
|
||||
[*.nix]
|
||||
indent_style = space
|
||||
indent_size = 2
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -3,18 +3,23 @@ bcachefs
|
||||
bcachefs.5
|
||||
.*
|
||||
*.o
|
||||
*.so
|
||||
*.d
|
||||
*.a
|
||||
/rust-src/mount/result
|
||||
/rust-src/bch_bindgen/result
|
||||
tags
|
||||
TAGS
|
||||
cscope*
|
||||
bcachefs-tools
|
||||
compile_commands.json
|
||||
tests/test_helper
|
||||
tests/__pycache__/
|
||||
|
||||
# dot-files that we don't want to ignore
|
||||
!.gitignore
|
||||
!.travis.yml
|
||||
!.editorconfig
|
||||
|
||||
mount/target
|
||||
mount.bcachefs
|
||||
|
65
base.nix
Normal file
65
base.nix
Normal file
@ -0,0 +1,65 @@
|
||||
{ lib
|
||||
, doCheck ? true
|
||||
, stdenvNoCC
|
||||
, callPackage
|
||||
, nixosTests
|
||||
, autoPatchelfHook
|
||||
, binary
|
||||
, mount
|
||||
, versionString ? "0.1"
|
||||
, inShell ? false
|
||||
, debugMode ? inShell
|
||||
, testWithValgrind ? true
|
||||
, fuseSupport ? false
|
||||
, fuse3 ? null }:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "bcachefs-tools";
|
||||
|
||||
version = "v0.1-flake-${versionString}";
|
||||
|
||||
nativeBuildInputs = [
|
||||
binary
|
||||
mount
|
||||
];
|
||||
|
||||
buildInputs = mount.propagatedBuildInputs;
|
||||
|
||||
phases = [ "installPhase" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
mkdir $out/bin
|
||||
mkdir $out/lib
|
||||
mkdir $out/share
|
||||
mkdir $out/etc
|
||||
cp -pr "${binary}/bin/"* $out/bin
|
||||
cp -pr "${binary}/lib/"* $out/lib
|
||||
cp -pr "${binary}/share/"* $out/share
|
||||
cp -pr "${binary}/etc/"* $out/etc
|
||||
cp -pr "${mount}/bin/"* $out/bin/
|
||||
chmod u+w $out/bin/*
|
||||
patchelf --add-rpath $out/lib $out/bin/bcachefs-mount
|
||||
ln -s "$out/bin/bcachefs-mount" "$out/bin/mount.bcachefs"
|
||||
ln -s "$out/bin" "$out/sbin"
|
||||
'';
|
||||
doCheck = doCheck; # needs bcachefs module loaded on builder
|
||||
|
||||
passthru = {
|
||||
tests = {
|
||||
smoke-test = nixosTests.bcachefs;
|
||||
};
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
meta = with lib; {
|
||||
description = "Userspace tools for bcachefs";
|
||||
homepage = http://bcachefs.org;
|
||||
license = licenses.gpl2;
|
||||
platforms = platforms.linux;
|
||||
maintainers =
|
||||
[ "Kent Overstreet <kent.overstreet@gmail.com>"
|
||||
];
|
||||
|
||||
};
|
||||
}
|
129
binary.nix
Normal file
129
binary.nix
Normal file
@ -0,0 +1,129 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, pkg-config
|
||||
, attr
|
||||
, libuuid
|
||||
, libsodium
|
||||
, keyutils
|
||||
|
||||
, liburcu
|
||||
, zlib
|
||||
, libaio
|
||||
, udev
|
||||
, zstd
|
||||
, lz4
|
||||
|
||||
, python39
|
||||
, python39Packages
|
||||
, docutils
|
||||
, nixosTests
|
||||
|
||||
, versionString ? "0.1"
|
||||
, doCheck ? true
|
||||
, inShell ? false
|
||||
, debugMode ? inShell
|
||||
|
||||
, testWithValgrind ? true
|
||||
, valgrind
|
||||
|
||||
, fuseSupport ? false
|
||||
, fuse3 ? null }:
|
||||
|
||||
assert fuseSupport -> fuse3 != null;
|
||||
assert testWithValgrind -> valgrind != null;
|
||||
stdenv.mkDerivation {
|
||||
pname = "bcachefs-bin";
|
||||
|
||||
version = "v0.1-flake-${versionString}";
|
||||
VERSION = "v0.1-flake-${versionString}";
|
||||
|
||||
src = (lib.cleanSource (builtins.path { name = "bcachefs-tools-src"; path = ./. ;} ));
|
||||
|
||||
postPatch = "patchShebangs --build doc/macro2rst.py";
|
||||
|
||||
propagatedNativeBuildInputs = [
|
||||
# used to find dependencies
|
||||
## see ./INSTALL
|
||||
pkg-config
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
# bcachefs explicit dependencies
|
||||
## see ./INSTALL
|
||||
libaio
|
||||
|
||||
# libblkid
|
||||
keyutils # libkeyutils
|
||||
lz4 # liblz4
|
||||
|
||||
libsodium
|
||||
liburcu
|
||||
libuuid
|
||||
zstd # libzstd
|
||||
zlib # zlib1g
|
||||
|
||||
# unspecified dependencies
|
||||
attr
|
||||
udev
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
# documentation depenedencies
|
||||
docutils
|
||||
python39Packages.pygments
|
||||
] ++ (lib.optional fuseSupport fuse3)
|
||||
++ (lib.optional testWithValgrind valgrind);
|
||||
|
||||
makeFlags = [
|
||||
"PREFIX=${placeholder "out"}"
|
||||
] ++ lib.optional debugMode "EXTRA_CFLAGS=-ggdb";
|
||||
|
||||
installFlags = [
|
||||
"INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools"
|
||||
];
|
||||
|
||||
doCheck = doCheck; # needs bcachefs module loaded on builder
|
||||
|
||||
checkInputs = [
|
||||
python39Packages.pytest
|
||||
python39Packages.pytest-xdist
|
||||
] ++ lib.optional testWithValgrind valgrind;
|
||||
|
||||
checkFlags = [
|
||||
"BCACHEFS_TEST_USE_VALGRIND=${if testWithValgrind then "yes" else "no"}"
|
||||
# cannot escape spaces within make flags, quotes are stripped
|
||||
"PYTEST_CMD=pytest" # "PYTEST_ARGS='-n4 --version'"
|
||||
];
|
||||
|
||||
preCheck =
|
||||
''
|
||||
makeFlagsArray+=(PYTEST_ARGS="--verbose -n2")
|
||||
'' +
|
||||
lib.optionalString fuseSupport ''
|
||||
rm tests/test_fuse.py
|
||||
'';
|
||||
|
||||
dontStrip = debugMode;
|
||||
passthru = {
|
||||
bcachefs_revision = let
|
||||
file = builtins.readFile ./.bcachefs_revision;
|
||||
removeLineFeeds = str: lib.lists.foldr (lib.strings.removeSuffix) str ["\r" "\n"];
|
||||
in removeLineFeeds file;
|
||||
|
||||
tests = {
|
||||
smoke-test = nixosTests.bcachefs;
|
||||
};
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
meta = with lib; {
|
||||
description = "Userspace tools for bcachefs";
|
||||
homepage = http://bcachefs.org;
|
||||
license = licenses.gpl2;
|
||||
platforms = platforms.linux;
|
||||
maintainers =
|
||||
[ "Kent Overstreet <kent.overstreet@gmail.com>"
|
||||
];
|
||||
|
||||
};
|
||||
}
|
138
default.nix
138
default.nix
@ -1,128 +1,10 @@
|
||||
{ lib
|
||||
, doCheck ? true
|
||||
, stdenv
|
||||
, pkg-config
|
||||
, attr
|
||||
, libuuid
|
||||
, libsodium
|
||||
, keyutils
|
||||
|
||||
, liburcu
|
||||
, zlib
|
||||
, libaio
|
||||
, udev
|
||||
, zstd
|
||||
, lz4
|
||||
|
||||
, python39
|
||||
, python39Packages
|
||||
, docutils
|
||||
, nixosTests
|
||||
|
||||
, versionString ? "0.1"
|
||||
|
||||
, inShell ? false
|
||||
, debugMode ? inShell
|
||||
|
||||
, testWithValgrind ? true
|
||||
, valgrind
|
||||
|
||||
, fuseSupport ? false
|
||||
, fuse3 ? null }:
|
||||
|
||||
assert fuseSupport -> fuse3 != null;
|
||||
assert testWithValgrind -> valgrind != null;
|
||||
stdenv.mkDerivation {
|
||||
pname = "bcachefs-tools";
|
||||
|
||||
version = "v0.1-flake-${versionString}";
|
||||
VERSION = "v0.1-flake-${versionString}";
|
||||
|
||||
src = (lib.cleanSource (builtins.path { name = "bcachefs-tools-src"; path = ./. ;} ));
|
||||
|
||||
postPatch = "patchShebangs --build doc/macro2rst.py";
|
||||
|
||||
nativeBuildInputs = [
|
||||
# used to find dependencies
|
||||
## see ./INSTALL
|
||||
pkg-config
|
||||
];
|
||||
buildInputs = [
|
||||
# bcachefs explicit dependencies
|
||||
## see ./INSTALL
|
||||
libaio
|
||||
|
||||
# libblkid
|
||||
keyutils # libkeyutils
|
||||
lz4 # liblz4
|
||||
|
||||
libsodium
|
||||
liburcu
|
||||
libuuid
|
||||
zstd # libzstd
|
||||
zlib # zlib1g
|
||||
valgrind
|
||||
|
||||
# unspecified dependencies
|
||||
attr
|
||||
udev
|
||||
|
||||
# documentation depenedencies
|
||||
docutils
|
||||
python39Packages.pygments
|
||||
] ++ (lib.optional fuseSupport fuse3)
|
||||
++ (lib.optional testWithValgrind valgrind) ;
|
||||
|
||||
makeFlags = [
|
||||
"PREFIX=${placeholder "out"}"
|
||||
] ++ lib.optional debugMode "EXTRA_CFLAGS=-ggdb";
|
||||
|
||||
installFlags = [
|
||||
"INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools"
|
||||
];
|
||||
|
||||
doCheck = doCheck; # needs bcachefs module loaded on builder
|
||||
|
||||
checkInputs = [
|
||||
python39Packages.pytest
|
||||
python39Packages.pytest-xdist
|
||||
] ++ lib.optional testWithValgrind valgrind;
|
||||
|
||||
checkFlags = [
|
||||
"BCACHEFS_TEST_USE_VALGRIND=${if testWithValgrind then "yes" else "no"}"
|
||||
# cannot escape spaces within make flags, quotes are stripped
|
||||
"PYTEST_CMD=pytest" # "PYTEST_ARGS='-n4 --version'"
|
||||
];
|
||||
|
||||
preCheck =
|
||||
''
|
||||
makeFlagsArray+=(PYTEST_ARGS="--verbose -n2")
|
||||
'' +
|
||||
lib.optionalString fuseSupport ''
|
||||
rm tests/test_fuse.py
|
||||
'';
|
||||
|
||||
dontStrip = debugMode;
|
||||
passthru = {
|
||||
bcachefs_revision = let
|
||||
file = builtins.readFile ./.bcachefs_revision;
|
||||
removeLineFeeds = str: lib.lists.foldr (lib.strings.removeSuffix) str ["\r" "\n"];
|
||||
in removeLineFeeds file;
|
||||
|
||||
tests = {
|
||||
smoke-test = nixosTests.bcachefs;
|
||||
};
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
meta = with lib; {
|
||||
description = "Userspace tools for bcachefs";
|
||||
homepage = http://bcachefs.org;
|
||||
license = licenses.gpl2;
|
||||
platforms = platforms.linux;
|
||||
maintainers =
|
||||
[ "Kent Overstreet <kent.overstreet@gmail.com>"
|
||||
];
|
||||
|
||||
};
|
||||
}
|
||||
(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
|
||||
|
31
flake.lock
31
flake.lock
@ -1,27 +1,28 @@
|
||||
{
|
||||
"nodes": {
|
||||
"filter": {
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1620202920,
|
||||
"narHash": "sha256-BOkm3eKT45Dk4NNxJT0xL9NnyYeZcF+t79zPnJkggac=",
|
||||
"owner": "numtide",
|
||||
"repo": "nix-filter",
|
||||
"rev": "3c9e33ed627e009428197b07216613206f06ed80",
|
||||
"lastModified": 1668681692,
|
||||
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "nix-filter",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1633351077,
|
||||
"narHash": "sha256-z38JG4Bb0GtM1aF1pANVdp1dniMP23Yb3HnRoJRy2uU=",
|
||||
"lastModified": 1669320964,
|
||||
"narHash": "sha256-EBFw+ge12Pcr3qCk8If3/eMBAoQLR7ytndXZoRevUtM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "14aef06d9b3ad1d07626bdbb16083b83f92dc6c1",
|
||||
"rev": "27ccd29078f974ddbdd7edc8e38c8c8ae003c877",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -33,18 +34,18 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"filter": "filter",
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1629481132,
|
||||
"narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=",
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "997f7efcb746a9c140ce1f13c72263189225f482",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
116
flake.nix
116
flake.nix
@ -1,96 +1,28 @@
|
||||
{
|
||||
description = "Userspace tools for bcachefs";
|
||||
description = "Userspace tools for bcachefs";
|
||||
|
||||
# Nixpkgs / NixOS version to use.
|
||||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
inputs.utils.url = "github:numtide/flake-utils";
|
||||
inputs.filter.url = "github:numtide/nix-filter";
|
||||
# Nixpkgs / NixOS version to use.
|
||||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
inputs.utils.url = "github:numtide/flake-utils";
|
||||
inputs.flake-compat = {
|
||||
url = "github:edolstra/flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, filter, ... }@inputs:
|
||||
let
|
||||
# System types to support.
|
||||
supportedSystems = [ "x86_64-linux" ];
|
||||
in
|
||||
{
|
||||
version = "${builtins.substring 0 8 self.lastModifiedDate}-${self.shortRev or "dirty"}";
|
||||
|
||||
overlay = import ./nix/overlay.nix inputs;
|
||||
nixosModule = self.nixosModules.bcachefs;
|
||||
nixosModules.bcachefs = import ./rust-src/mount/module.nix;
|
||||
nixosModules.bcachefs-enable-boot = ({config, pkgs, lib, ... }:{
|
||||
# Disable Upstream NixOS Module when this is in use
|
||||
disabledModules = [ "tasks/filesystems/bcachefs.nix" ];
|
||||
# Import needed packages
|
||||
nixpkgs.overlays = [ self.overlay ];
|
||||
|
||||
# Add bcachefs to boot and kernel
|
||||
boot.initrd.supportedFilesystems = [ "bcachefs" ];
|
||||
boot.supportedFilesystems = [ "bcachefs" ];
|
||||
});
|
||||
|
||||
nixosConfigurations.netboot-bcachefs = self.systems.netboot-bcachefs "x86_64-linux";
|
||||
systems.netboot-bcachefs = system: (nixpkgs.lib.nixosSystem {
|
||||
inherit system; modules = [
|
||||
self.nixosModule
|
||||
self.nixosModules.bcachefs-enable-boot
|
||||
("${nixpkgs}/nixos/modules/installer/netboot/netboot-minimal.nix")
|
||||
({ lib, pkgs, config, ... }: {
|
||||
# installation disk autologin
|
||||
services.getty.autologinUser = lib.mkForce "root";
|
||||
users.users.root.initialPassword = "toor";
|
||||
|
||||
# Symlink everything together
|
||||
system.build.netboot = pkgs.symlinkJoin {
|
||||
name = "netboot";
|
||||
paths = with config.system.build; [
|
||||
netbootRamdisk
|
||||
kernel
|
||||
netbootIpxeScript
|
||||
];
|
||||
preferLocalBuild = true;
|
||||
};
|
||||
})
|
||||
];
|
||||
});
|
||||
}
|
||||
// utils.lib.eachSystem supportedSystems (system:
|
||||
let pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlay ];
|
||||
};
|
||||
in rec {
|
||||
|
||||
# A Nixpkgs overlay.
|
||||
|
||||
# Provide some binary packages for selected system types.
|
||||
defaultPackage = pkgs.bcachefs.tools;
|
||||
packages = {
|
||||
inherit (pkgs.bcachefs)
|
||||
tools
|
||||
toolsValgrind
|
||||
toolsDebug
|
||||
mount
|
||||
bch_bindgen
|
||||
kernel;
|
||||
|
||||
tools-musl = pkgs.pkgsMusl.bcachefs.tools;
|
||||
mount-musl = pkgs.pkgsMusl.bcachefs.mount;
|
||||
};
|
||||
|
||||
checks = {
|
||||
kernelSrc = packages.kernel.src;
|
||||
inherit (packages)
|
||||
mount
|
||||
bch_bindgen
|
||||
toolsValgrind;
|
||||
|
||||
# Build and test initrd with bcachefs and bcachefs.mount installed
|
||||
# Disabled Test because it takes a while to build the kernel
|
||||
# bootStage1Module = self.nixosConfigurations.netboot-bcachefs.config.system.build.bootStage1;
|
||||
};
|
||||
|
||||
devShell = devShells.tools;
|
||||
devShells.tools = pkgs.bcachefs.tools.override { inShell = true; };
|
||||
devShells.mount = pkgs.bcachefs.mount.override { inShell = true; };
|
||||
});
|
||||
outputs = { self, nixpkgs, utils, ... }:
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
binary = pkgs.callPackage ./binary.nix { };
|
||||
mount = pkgs.callPackage ./rust-src/mount/default.nix { inherit binary; };
|
||||
bcachefs = pkgs.callPackage ./base.nix {
|
||||
inherit binary mount;
|
||||
testWithValgrind = false;
|
||||
};
|
||||
in {
|
||||
packages = {
|
||||
inherit binary mount;
|
||||
default = bcachefs;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
{ lib
|
||||
, fetchpatch
|
||||
, fetchgit
|
||||
, fetchFromGitHub
|
||||
, buildLinux
|
||||
, commit
|
||||
, sha256 ? lib.fakeSha256
|
||||
, kernelVersion ? "5.13.0"
|
||||
, kernelPatches ? [] # must always be defined in bcachefs' all-packages.nix entry because it's also a top-level attribute supplied by callPackage
|
||||
, argsOverride ? {}
|
||||
, versionString ? (builtins.substring 0 8 commit)
|
||||
, ...
|
||||
} @ args:
|
||||
|
||||
buildLinux {
|
||||
inherit kernelPatches;
|
||||
|
||||
# pname = "linux";
|
||||
version = "${kernelVersion}-bcachefs-${versionString}";
|
||||
|
||||
modDirVersion = kernelVersion;
|
||||
|
||||
|
||||
src = fetchFromGitHub {
|
||||
name = "bcachefs-kernel-src";
|
||||
owner = "koverstreet";
|
||||
repo = "bcachefs";
|
||||
rev = commit;
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
extraConfig = "BCACHEFS_FS m";
|
||||
# NIX_DEBUG=5;
|
||||
}
|
@ -1 +0,0 @@
|
||||
sha256-JsWrbuxrs047YKGES+r7mMfPdDWIMAGrg1fWi8qU4+A=
|
@ -1,48 +0,0 @@
|
||||
# `builtins.fetchTarball` only accepts a `sha256` argument in Nix version 1.12
|
||||
# or later, so here we provide a function that can provide a compatible interface
|
||||
# to Nix 1.11 or Nix 1.12
|
||||
#
|
||||
# TODO FIXME: remove this sometime after Nix 1.12 goes stable
|
||||
|
||||
{ url # URL of the nixpkgs tarball to download
|
||||
, rev # The Git revision of nixpkgs to fetch
|
||||
, sha256 # The SHA256 of the downloaded data
|
||||
, system ? builtins.currentSystem # This is overridable if necessary
|
||||
}:
|
||||
|
||||
with {
|
||||
ifThenElse = { bool, thenValue, elseValue }: (
|
||||
if bool then thenValue else elseValue);
|
||||
};
|
||||
|
||||
ifThenElse {
|
||||
bool = (0 <= builtins.compareVersions builtins.nixVersion "1.12");
|
||||
|
||||
# In Nix 1.12, we can just give a `sha256` to `builtins.fetchTarball`.
|
||||
thenValue = (builtins.fetchTarball { inherit url sha256; });
|
||||
|
||||
# This hack should at least work for Nix 1.11
|
||||
elseValue = (
|
||||
(rec {
|
||||
tarball = import <nix/fetchurl.nix> { inherit url sha256; };
|
||||
builtin-paths = import <nix/config.nix>;
|
||||
|
||||
script = builtins.toFile "nixpkgs-unpacker" ''
|
||||
"$coreutils/mkdir" "$out"
|
||||
cd "$out"
|
||||
"$gzip" --decompress < "$tarball" | "$tar" -x --strip-components=1
|
||||
'';
|
||||
|
||||
nixpkgs = builtins.derivation {
|
||||
name = "nixpkgs-${builtins.substring 0 6 rev}";
|
||||
|
||||
builder = builtins.storePath builtin-paths.shell;
|
||||
args = [ script ];
|
||||
|
||||
inherit tarball system;
|
||||
tar = builtins.storePath builtin-paths.tar;
|
||||
gzip = builtins.storePath builtin-paths.gzip;
|
||||
coreutils = builtins.storePath builtin-paths.coreutils;
|
||||
};
|
||||
}).nixpkgs);
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
"url": "https://github.com/nixos/nixpkgs/archive/5ae883b8c3b04e0c4a9c92a5ab3c7c84b9942943.tar.gz",
|
||||
"rev": "5ae883b8c3b04e0c4a9c92a5ab3c7c84b9942943",
|
||||
"sha256": "1s2nhax586v2fax7r5qd1s3d2gdg25isva7k7r9pf9x9ay630cmb"
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
let
|
||||
# Grab the versions we specified in the JSON file
|
||||
nixpkgs = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
|
||||
|
||||
# Bootstrap a copy of nixpkgs, based on this.
|
||||
src = import ./fetchnix.nix { inherit (nixpkgs) url rev sha256; };
|
||||
|
||||
# We use the default nixpkgs configuration during bootstrap.
|
||||
in import src { config = {}; }
|
@ -1,28 +0,0 @@
|
||||
{ filter, self, ... }:
|
||||
final: prev: {
|
||||
bcachefs = {
|
||||
tools = final.callPackage ../default.nix {
|
||||
testWithValgrind = false;
|
||||
filter = filter.lib;
|
||||
versionString = self.version;
|
||||
};
|
||||
toolsValgrind = final.bcachefs.tools.override {
|
||||
testWithValgrind = true;
|
||||
};
|
||||
toolsDebug = final.bcachefs.toolsValgrind.override {
|
||||
debugMode = true;
|
||||
};
|
||||
|
||||
bch_bindgen = final.callPackage ../rust-src/bch_bindgen {};
|
||||
|
||||
mount = final.callPackage ../rust-src/mount {};
|
||||
|
||||
kernelPackages = final.recurseIntoAttrs (final.linuxPackagesFor final.bcachefs.kernel);
|
||||
kernel = final.callPackage ./bcachefs-kernel.nix {
|
||||
commit = final.bcachefs.tools.bcachefs_revision;
|
||||
# This needs to be recalculated for every revision change
|
||||
sha256 = builtins.readFile ./bcachefs.rev.sha256;
|
||||
kernelPatches = [];
|
||||
};
|
||||
};
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [[ "x$1" == "x" ]]; then
|
||||
echo "Must provide a revision argument"
|
||||
echo "Usage:"
|
||||
echo " ./update-nixpkgs.sh <rev>"
|
||||
echo " ./update-nixpkgs.sh https://github.com/foo/nixpkgs <rev>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "x$2" == "x" ]]; then
|
||||
REV="$1"
|
||||
URL="https://github.com/nixos/nixpkgs"
|
||||
else
|
||||
REV="$2"
|
||||
URL="$1"
|
||||
fi
|
||||
|
||||
DOWNLOAD="$URL/archive/$REV.tar.gz"
|
||||
echo "Updating to nixpkgs revision $REV from $URL"
|
||||
SHA256=$(nix-prefetch-url "$DOWNLOAD")
|
||||
|
||||
cat > nixpkgs.json <<EOF
|
||||
{
|
||||
"url": "$DOWNLOAD",
|
||||
"rev": "$REV",
|
||||
"sha256": "$SHA256"
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "Updated nixpkgs.json"
|
@ -4,73 +4,46 @@
|
||||
, llvmPackages
|
||||
, bcachefs
|
||||
, pkg-config
|
||||
|
||||
, udev
|
||||
, liburcu
|
||||
, zstd
|
||||
, keyutils
|
||||
, libaio
|
||||
|
||||
, lz4 # liblz4
|
||||
, lz4 # liblz4
|
||||
, libsodium
|
||||
, libuuid
|
||||
, zlib # zlib1g
|
||||
, zlib # zlib1g
|
||||
, libscrypt
|
||||
|
||||
, rustfmt
|
||||
|
||||
, glibc
|
||||
, ...
|
||||
}: let
|
||||
include = {
|
||||
glibc = "${glibc.dev}/include";
|
||||
clang = let libc = llvmPackages.libclang; in
|
||||
"${libc.lib}/lib/clang/${libc.version}/include";
|
||||
urcu = "${liburcu}/include";
|
||||
zstd = "${zstd.dev}/include";
|
||||
};
|
||||
cargo = lib.trivial.importTOML ./Cargo.toml;
|
||||
in rustPlatform.buildRustPackage {
|
||||
pname = cargo.package.name;
|
||||
version = cargo.package.version;
|
||||
|
||||
src = builtins.path { path = ./.; name = "bch_bindgen"; };
|
||||
}:
|
||||
let
|
||||
cargo = lib.trivial.importTOML ./Cargo.toml;
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = cargo.package.name;
|
||||
version = cargo.package.version;
|
||||
|
||||
cargoLock = { lockFile = ./Cargo.lock; };
|
||||
src = builtins.path {
|
||||
path = ./.;
|
||||
name = "bch_bindgen";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ rustfmt pkg-config ];
|
||||
buildInputs = [
|
||||
|
||||
# libaio
|
||||
keyutils # libkeyutils
|
||||
lz4 # liblz4
|
||||
libsodium
|
||||
liburcu
|
||||
libuuid
|
||||
zstd # libzstd
|
||||
zlib # zlib1g
|
||||
udev
|
||||
libscrypt
|
||||
libaio
|
||||
];
|
||||
|
||||
LIBBCACHEFS_LIB ="${bcachefs.tools}/lib";
|
||||
LIBBCACHEFS_INCLUDE = bcachefs.tools.src;
|
||||
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
|
||||
BINDGEN_EXTRA_CLANG_ARGS = lib.replaceStrings ["\n" "\t"] [" " ""] ''
|
||||
-std=gnu99
|
||||
-I${include.glibc}
|
||||
-I${include.clang}
|
||||
-I${include.urcu}
|
||||
-I${include.zstd}
|
||||
'';
|
||||
cargoLock = { lockFile = ./Cargo.lock; };
|
||||
|
||||
postPatch = ''
|
||||
cp ${./Cargo.lock} Cargo.lock
|
||||
'';
|
||||
|
||||
propagatedNativeBuildInputs = [ rustPlatform.bindgenHook ];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
# NIX_DEBUG = 4;
|
||||
}
|
||||
propagatedBuildInputs = [
|
||||
bcachefs.tools
|
||||
];
|
||||
|
||||
LIBBCACHEFS_LIB ="${bcachefs.tools}/lib";
|
||||
LIBBCACHEFS_INCLUDE = bcachefs.tools.src;
|
||||
|
||||
postPatch = ''
|
||||
cp ${./Cargo.lock} Cargo.lock
|
||||
'';
|
||||
|
||||
doCheck = true;
|
||||
}
|
||||
|
@ -1,41 +1,27 @@
|
||||
{ lib
|
||||
|
||||
, stdenv
|
||||
, glibc
|
||||
, udev
|
||||
, llvmPackages
|
||||
, rustPlatform
|
||||
|
||||
, bcachefs
|
||||
|
||||
, binary
|
||||
, ...
|
||||
}: rustPlatform.buildRustPackage ( let
|
||||
cargo = lib.trivial.importTOML ./Cargo.toml;
|
||||
cargo = lib.trivial.importTOML ./Cargo.toml;
|
||||
in {
|
||||
pname = "mount.bcachefs";
|
||||
version = cargo.package.version;
|
||||
|
||||
src = builtins.path { path = ../.; name = "rust-src"; };
|
||||
sourceRoot = "rust-src/mount";
|
||||
pname = "mount.bcachefs";
|
||||
version = cargo.package.version;
|
||||
|
||||
cargoLock = { lockFile = ./Cargo.lock; };
|
||||
src = builtins.path { path = ../.; name = "rust-src"; };
|
||||
sourceRoot = "rust-src/mount";
|
||||
|
||||
nativeBuildInputs = bcachefs.bch_bindgen.nativeBuildInputs;
|
||||
buildInputs = bcachefs.bch_bindgen.buildInputs;
|
||||
inherit (bcachefs.bch_bindgen)
|
||||
LIBBCACHEFS_INCLUDE
|
||||
LIBBCACHEFS_LIB
|
||||
LIBCLANG_PATH
|
||||
BINDGEN_EXTRA_CLANG_ARGS;
|
||||
|
||||
postInstall = ''
|
||||
ln $out/bin/${cargo.package.name} $out/bin/mount.bcachefs
|
||||
ln -s $out/bin $out/sbin
|
||||
'';
|
||||
# -isystem ${llvmPackages.libclang.lib}/lib/clang/${lib.getVersion llvmPackages.libclang}/include";
|
||||
# CFLAGS = "-I${llvmPackages.libclang.lib}/include";
|
||||
# LDFLAGS = "-L${libcdev}";
|
||||
cargoLock = { lockFile = ./Cargo.lock; };
|
||||
|
||||
doCheck = false;
|
||||
|
||||
# NIX_DEBUG = 4;
|
||||
})
|
||||
nativeBuildInputs = [ binary rustPlatform.bindgenHook ];
|
||||
buildInputs = [ binary ];
|
||||
|
||||
LIBBCACHEFS_LIB ="${binary}/lib";
|
||||
LIBBCACHEFS_INCLUDE = binary.src;
|
||||
|
||||
doCheck = false;
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user