nix: fix build add overlay and formatter to flake

Adds overlay flake output to expose the bcachefs package
and add and run a nix formatter.

Co-authored-by: Leona Maroni <dev@leona.is>
Signed-off-by: Leona Maroni <dev@leona.is>
Signed-off-by: Finn Behrens <me@kloenk.de>
This commit is contained in:
Finn Behrens 2023-11-04 09:40:16 +01:00 committed by Finn Behrens
parent 81352a29bc
commit 813310c343
4 changed files with 37 additions and 48 deletions

View File

@ -1,28 +1,10 @@
{ lib
, stdenv
, pkg-config
, attr
, libuuid
, libsodium
, keyutils
, liburcu
, zlib
, libaio
, udev
, zstd
, lz4
, nix-gitignore
, rustPlatform
, rustc
, cargo
}:
{ lib, stdenv, pkg-config, attr, libuuid, libsodium, keyutils, liburcu, zlib
, libaio, udev, zstd, lz4, nix-gitignore, rustPlatform, rustc, cargo, }:
let
src = nix-gitignore.gitignoreSource [ ] ./.;
commit = lib.strings.substring 0 7 (builtins.readFile ./.bcachefs_revision);
version = "git-${commit}";
in stdenv.mkDerivation {
inherit src version;
@ -61,12 +43,14 @@ in stdenv.mkDerivation {
};
};
makeFlags = [
"PREFIX=${placeholder "out"}"
"VERSION=${commit}"
];
makeFlags = [ "DESTDIR=${placeholder "out"}" "PREFIX=" "VERSION=${commit}" ];
dontStrip = true;
checkPhase = "./bcachefs version";
doCheck = true;
meta = {
mainProgram = "bcachefs";
license = lib.licenses.gpl2Only;
};
}

View File

@ -1,10 +1,6 @@
(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

@ -3,11 +3,11 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
@ -18,11 +18,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1686592866,
"narHash": "sha256-riGg89eWhXJcPNrQGcSwTEEm7CGxWC06oSX44hajeMw=",
"lastModified": 1698924604,
"narHash": "sha256-GCFbkl2tj8fEZBZCw3Tc0AkGo0v+YrQlohhEGJ/X4s0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0eeebd64de89e4163f4d3cf34ffe925a5cf67a05",
"rev": "fa804edfb7869c9fb230e174182a8a1a7e512c40",
"type": "github"
},
"original": {
@ -59,11 +59,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {

View File

@ -10,13 +10,22 @@
};
outputs = { self, nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (system:
{
overlays.default = final: prev: {
bcachefs = final.callPackage ./build.nix { };
};
} // utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
bcachefs = pkgs.callPackage ./build.nix {};
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
in {
packages = {
default = bcachefs;
inherit (pkgs) bcachefs;
default = pkgs.bcachefs;
};
formatter = pkgs.nixfmt;
});
}