Merge pull request #272 from tmuehlbacher/flake-overhaul

Flake overhaul
This commit is contained in:
koverstreet 2024-05-22 16:58:18 -04:00 committed by GitHub
commit 764031a4aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 176 additions and 73 deletions

View File

@ -1,6 +1,26 @@
indent_style = tab
root = true
[*]
charset = utf-8
end_of_line = lf
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]
indent_style = space
indent_size = 2
[Cargo.toml]
indent_style = space
indent_size = 4
[*.rs]
indent_style = space
indent_size = 4

View File

@ -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";

View File

@ -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";
(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
}
) { src = ./.; }).defaultNix

View File

@ -16,13 +16,31 @@
"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": {
"locked": {
"lastModified": 1698924604,
"narHash": "sha256-GCFbkl2tj8fEZBZCw3Tc0AkGo0v+YrQlohhEGJ/X4s0=",
"lastModified": 1716293225,
"narHash": "sha256-pU9ViBVE3XYb70xZx+jK6SEVphvt7xMTbm6yDIF4xPs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "fa804edfb7869c9fb230e174182a8a1a7e512c40",
"rev": "3eaeaeb6b1e08a016380c279f8846e0bd8808916",
"type": "github"
},
"original": {
@ -32,43 +50,43 @@
"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": {
"inputs": {
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"utils": "utils"
"treefmt-nix": "treefmt-nix"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"treefmt-nix": {
"inputs": {
"systems": "systems"
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"lastModified": 1715940852,
"narHash": "sha256-wJqHMg/K6X3JGAE9YLM0LsuKrKb4XiBeVaoeMNlReZg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"repo": "treefmt-nix",
"rev": "2fba33a182602b9d49f0b2440513e5ee091d838b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"repo": "treefmt-nix",
"type": "github"
}
}

View File

@ -1,40 +1,81 @@
{
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.flake-compat = {
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
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@{
self,
nixpkgs,
flake-parts,
treefmt-nix,
flake-compat,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ inputs.treefmt-nix.flakeModule ];
# can be extended, but these have proper binary cache support in nixpkgs
# as of writing.
systems = [
"aarch64-linux"
"x86_64-linux"
];
perSystem =
{
overlays.default = final: prev: {
bcachefs = final.callPackage ./build.nix { };
};
} // utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
in {
packages = {
inherit (pkgs) bcachefs;
bcachefs-fuse = pkgs.bcachefs.override { fuseSupport = true; };
default = pkgs.bcachefs;
self',
config,
pkgs,
...
}:
{
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
];
};
formatter = pkgs.nixfmt;
treefmt.config = {
projectRootFile = "flake.nix";
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;
}) { };
});
programs = {
nixfmt-rfc-style.enable = true;
};
};
};
};
}