diff options
author | Thomas Mühlbacher <tmuehlbacher@posteo.net> | 2024-05-22 21:08:09 +0200 |
---|---|---|
committer | Thomas Mühlbacher <tmuehlbacher@posteo.net> | 2024-05-22 22:35:05 +0200 |
commit | cc16402e4f31a63ab415043da06f0445fe55765c (patch) | |
tree | 078600146ccf3987fbae3e4c2d18fbc498148eb1 | |
parent | 0fcdd67bf0fcd38a61a2eda647b9b7342b558ff2 (diff) |
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>
-rw-r--r-- | flake.lock | 61 | ||||
-rw-r--r-- | flake.nix | 57 |
2 files changed, 66 insertions, 52 deletions
@@ -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" } }, - "root": { - "inputs": { - "flake-compat": "flake-compat", - "nixpkgs": "nixpkgs", - "utils": "utils" - } - }, - "systems": { + "nixpkgs-lib": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" + "lastModified": 1714640452, + "narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" }, "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" } }, - "utils": { + "root": { "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-compat": "flake-compat", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" } } }, @@ -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; - packages.bcachefs-tools = pkgs.callPackage ./build.nix { }; - packages.bcachefs-tools-fuse = packages.bcachefs-tools.override { fuseSupport = true; }; - - formatter = pkgs.nixfmt-rfc-style; - - devShells.default = pkgs.mkShell { - inputsFrom = [ packages.default ]; - - LIBCLANG_PATH = "${pkgs.clang.cc.lib}/lib"; + 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 = config.packages.bcachefs-tools.override { fuseSupport = true; }; + + formatter = pkgs.nixfmt-rfc-style; + + devShells.default = pkgs.mkShell { + inputsFrom = [ config.packages.default ]; + + LIBCLANG_PATH = "${pkgs.clang.cc.lib}/lib"; + }; }; - } - ); + }; } |