mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-24 00:00:19 +03:00
Merge pull request #272 from tmuehlbacher/flake-overhaul
Flake overhaul
This commit is contained in:
commit
764031a4aa
@ -1,6 +1,26 @@
|
|||||||
indent_style = tab
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
indent_size = 8
|
indent_size = 8
|
||||||
|
indent_style = tab
|
||||||
|
insert_final_newline = true
|
||||||
|
max_line_length = 80
|
||||||
|
tab_width = 8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[.git/**]
|
||||||
|
max_line_length = 72
|
||||||
|
|
||||||
[*.nix]
|
[*.nix]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
[Cargo.toml]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.rs]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
37
build.nix
37
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
|
lib,
|
||||||
, fuseSupport ? false, }:
|
stdenv,
|
||||||
|
pkg-config,
|
||||||
|
attr,
|
||||||
|
libuuid,
|
||||||
|
libsodium,
|
||||||
|
keyutils,
|
||||||
|
liburcu,
|
||||||
|
zlib,
|
||||||
|
libaio,
|
||||||
|
udev,
|
||||||
|
zstd,
|
||||||
|
lz4,
|
||||||
|
nix-gitignore,
|
||||||
|
rustPlatform,
|
||||||
|
rustc,
|
||||||
|
cargo,
|
||||||
|
fuse3,
|
||||||
|
fuseSupport ? false,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
src = nix-gitignore.gitignoreSource [ ] ./.;
|
src = nix-gitignore.gitignoreSource [ ] ./.;
|
||||||
|
|
||||||
commit = lib.strings.substring 0 7 (builtins.readFile ./.bcachefs_revision);
|
commit = lib.strings.substring 0 7 (builtins.readFile ./.bcachefs_revision);
|
||||||
version = "git-${commit}";
|
version = "git-${commit}";
|
||||||
in stdenv.mkDerivation {
|
in
|
||||||
|
stdenv.mkDerivation {
|
||||||
inherit src version;
|
inherit src version;
|
||||||
|
|
||||||
pname = "bcachefs-tools";
|
pname = "bcachefs-tools";
|
||||||
@ -39,11 +58,13 @@ in stdenv.mkDerivation {
|
|||||||
# when git-based crates are updated, run:
|
# when git-based crates are updated, run:
|
||||||
# nix run github:Mic92/nix-update -- --version=skip --flake default
|
# nix run github:Mic92/nix-update -- --version=skip --flake default
|
||||||
# to update the hashes
|
# to update the hashes
|
||||||
cargoDeps = rustPlatform.importCargoLock {
|
cargoDeps = rustPlatform.importCargoLock { lockFile = "${src}/Cargo.lock"; };
|
||||||
lockFile = "${src}/Cargo.lock";
|
|
||||||
};
|
|
||||||
|
|
||||||
makeFlags = [ "DESTDIR=${placeholder "out"}" "PREFIX=" "VERSION=${commit}" ];
|
makeFlags = [
|
||||||
|
"DESTDIR=${placeholder "out"}"
|
||||||
|
"PREFIX="
|
||||||
|
"VERSION=${commit}"
|
||||||
|
];
|
||||||
|
|
||||||
dontStrip = true;
|
dontStrip = true;
|
||||||
checkPhase = "./target/release/bcachefs version";
|
checkPhase = "./target/release/bcachefs version";
|
||||||
|
15
default.nix
15
default.nix
@ -1,6 +1,9 @@
|
|||||||
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
(import (
|
||||||
in fetchTarball {
|
let
|
||||||
url =
|
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||||
"https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
in
|
||||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
fetchTarball {
|
||||||
}) { src = ./.; }).defaultNix
|
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
|
||||||
|
70
flake.lock
70
flake.lock
@ -16,13 +16,31 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1715865404,
|
||||||
|
"narHash": "sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "8dc45382d5206bd292f9c2768b8058a8fd8311d9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1698924604,
|
"lastModified": 1716293225,
|
||||||
"narHash": "sha256-GCFbkl2tj8fEZBZCw3Tc0AkGo0v+YrQlohhEGJ/X4s0=",
|
"narHash": "sha256-pU9ViBVE3XYb70xZx+jK6SEVphvt7xMTbm6yDIF4xPs=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "fa804edfb7869c9fb230e174182a8a1a7e512c40",
|
"rev": "3eaeaeb6b1e08a016380c279f8846e0bd8808916",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -32,43 +50,43 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1714640452,
|
||||||
|
"narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz"
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"utils": "utils"
|
"treefmt-nix": "treefmt-nix"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"treefmt-nix": {
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"utils": {
|
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1694529238,
|
"lastModified": 1715940852,
|
||||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
"narHash": "sha256-wJqHMg/K6X3JGAE9YLM0LsuKrKb4XiBeVaoeMNlReZg=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "treefmt-nix",
|
||||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
"rev": "2fba33a182602b9d49f0b2440513e5ee091d838b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "treefmt-nix",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
105
flake.nix
105
flake.nix
@ -1,40 +1,81 @@
|
|||||||
{
|
{
|
||||||
description = "Userspace tools for bcachefs";
|
description = "Userspace tools for bcachefs";
|
||||||
|
|
||||||
# Nixpkgs / NixOS version to use.
|
inputs = {
|
||||||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
inputs.utils.url = "github:numtide/flake-utils";
|
|
||||||
inputs.flake-compat = {
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
url = "github:edolstra/flake-compat";
|
|
||||||
flake = false;
|
treefmt-nix = {
|
||||||
|
url = "github:numtide/treefmt-nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
flake-compat = {
|
||||||
|
url = "github:edolstra/flake-compat";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, utils, ... }:
|
outputs =
|
||||||
{
|
inputs@{
|
||||||
overlays.default = final: prev: {
|
self,
|
||||||
bcachefs = final.callPackage ./build.nix { };
|
nixpkgs,
|
||||||
};
|
flake-parts,
|
||||||
} // utils.lib.eachDefaultSystem (system:
|
treefmt-nix,
|
||||||
let
|
flake-compat,
|
||||||
pkgs = import nixpkgs {
|
...
|
||||||
inherit system;
|
}:
|
||||||
overlays = [ self.overlays.default ];
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
};
|
imports = [ inputs.treefmt-nix.flakeModule ];
|
||||||
in {
|
|
||||||
packages = {
|
|
||||||
inherit (pkgs) bcachefs;
|
|
||||||
bcachefs-fuse = pkgs.bcachefs.override { fuseSupport = true; };
|
|
||||||
default = pkgs.bcachefs;
|
|
||||||
};
|
|
||||||
|
|
||||||
formatter = pkgs.nixfmt;
|
# can be extended, but these have proper binary cache support in nixpkgs
|
||||||
|
# as of writing.
|
||||||
|
systems = [
|
||||||
|
"aarch64-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
|
|
||||||
devShells.default = pkgs.callPackage ({ mkShell, rustc, cargo, gnumake
|
perSystem =
|
||||||
, gcc, clang, pkg-config, libuuid, libsodium, keyutils, liburcu, zlib
|
{
|
||||||
, libaio, zstd, lz4, udev, bcachefs }:
|
self',
|
||||||
mkShell {
|
config,
|
||||||
LIBCLANG_PATH = "${clang.cc.lib}/lib";
|
pkgs,
|
||||||
inherit (bcachefs) nativeBuildInputs buildInputs;
|
...
|
||||||
}) { };
|
}:
|
||||||
});
|
{
|
||||||
|
packages.default = config.packages.bcachefs-tools;
|
||||||
|
packages.bcachefs-tools = pkgs.callPackage ./build.nix { };
|
||||||
|
|
||||||
|
packages.bcachefs-tools-fuse = config.packages.bcachefs-tools.override { fuseSupport = true; };
|
||||||
|
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
inputsFrom = [
|
||||||
|
config.packages.default
|
||||||
|
config.treefmt.build.devShell
|
||||||
|
];
|
||||||
|
|
||||||
|
LIBCLANG_PATH = "${pkgs.clang.cc.lib}/lib";
|
||||||
|
|
||||||
|
# here go packages that aren't required for builds but are used for
|
||||||
|
# development, and might need to be version matched with build
|
||||||
|
# dependencies (e.g. clippy or rust-analyzer).
|
||||||
|
packages = with pkgs; [
|
||||||
|
cargo-audit
|
||||||
|
cargo-outdated
|
||||||
|
clang-tools
|
||||||
|
clippy
|
||||||
|
rust-analyzer
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
treefmt.config = {
|
||||||
|
projectRootFile = "flake.nix";
|
||||||
|
|
||||||
|
programs = {
|
||||||
|
nixfmt-rfc-style.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user