build(nix): replace flake-utils with flake-parts

it also provides a way for abstracting `system` and provides optional
modules, like treefmt-nix.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
This commit is contained in:
Thomas Mühlbacher 2024-05-22 21:08:09 +02:00
parent 0fcdd67bf0
commit cc16402e4f
2 changed files with 66 additions and 52 deletions

View File

@ -16,6 +16,24 @@
"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": 1716293225,
@ -32,44 +50,23 @@
"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",
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"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": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},

View File

@ -4,7 +4,7 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-compat = {
url = "github:edolstra/flake-compat";
@ -13,24 +13,41 @@
};
outputs =
{ nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
rec {
packages.default = packages.bcachefs-tools;
inputs@{
self,
nixpkgs,
flake-parts,
flake-compat,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
# can be extended, but these have proper binary cache support in nixpkgs
# as of writing.
systems = [
"aarch64-linux"
"x86_64-linux"
];
perSystem =
{
self',
config,
pkgs,
...
}:
{
packages.default = config.packages.bcachefs-tools;
packages.bcachefs-tools = pkgs.callPackage ./build.nix { };
packages.bcachefs-tools-fuse = packages.bcachefs-tools.override { fuseSupport = true; };
packages.bcachefs-tools-fuse = config.packages.bcachefs-tools.override { fuseSupport = true; };
formatter = pkgs.nixfmt-rfc-style;
devShells.default = pkgs.mkShell {
inputsFrom = [ packages.default ];
inputsFrom = [ config.packages.default ];
LIBCLANG_PATH = "${pkgs.clang.cc.lib}/lib";
};
}
);
};
};
}