Skip to content

Commit 6b0cbf9

Browse files
bryangoarxanas
authored andcommitted
feat(nix): reuse nixpkgs definition with overrides
Reuse nixpkgs definition for git-branchless, and supply local changes through overrides. This ensures that nixpkgs updates are automatically propagated to the package definition here. In flake.nix we recommend people to contribute to nixpkgs first for it to be the primary source of package definition; and then pull the changes down here by updating flake.lock.
1 parent 0e3d25f commit 6b0cbf9

File tree

1 file changed

+17
-47
lines changed

1 file changed

+17
-47
lines changed

flake.nix

Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,27 @@
1515
in
1616
{
1717
overlays.default = (final: prev: {
18-
git-branchless = final.callPackage
19-
(
20-
{ lib
21-
, git
22-
, libiconv
23-
, ncurses
24-
, openssl
25-
, pkg-config
26-
, rustPlatform
27-
, sqlite
28-
, stdenv
29-
, Security
30-
, SystemConfiguration
31-
}:
32-
33-
rustPlatform.buildRustPackage {
34-
name = "git-branchless";
3518

36-
src = self;
37-
38-
cargoLock = {
39-
lockFile = "${self}/Cargo.lock";
40-
};
41-
42-
nativeBuildInputs = [ pkg-config ];
19+
# reuse the definition from nixpkgs git-branchless
20+
git-branchless = prev.git-branchless.overrideAttrs ({ meta, ... }: {
21+
name = "git-branchless";
22+
src = self;
23+
cargoDeps = final.rustPlatform.importCargoLock {
24+
lockFile = ./Cargo.lock;
25+
};
4326

44-
buildInputs = [
45-
ncurses
46-
openssl
47-
sqlite
48-
] ++ lib.optionals stdenv.isDarwin [
49-
Security
50-
SystemConfiguration
51-
libiconv
52-
];
27+
# for `flake.nix` contributors: put additional local overrides here.
28+
# if the changes are also applicable to the `git-branchless` package
29+
# in nixpkgs, consider first improving the definition there, and then
30+
# update the `flake.lock` here.
5331

54-
preCheck = ''
55-
export TEST_GIT=${git}/bin/git
56-
export TEST_GIT_EXEC_PATH=$(${git}/bin/git --exec-path)
57-
'';
58-
# FIXME: these tests time out when run in the Nix sandbox
59-
checkFlags = [
60-
"--skip=test_switch_pty"
61-
"--skip=test_next_ambiguous_interactive"
62-
"--skip=test_switch_auto_switch_interactive"
63-
];
64-
}
65-
)
66-
{
67-
inherit (final.darwin.apple_sdk.frameworks) Security SystemConfiguration;
32+
# in case local overrides might confuse upstream maintainers,
33+
# we do not list them here:
34+
meta = (removeAttrs meta [ "maintainers" ]) // {
35+
# to correctly generate meta.position for back trace:
36+
inherit (meta) description;
6837
};
38+
});
6939

7040
scm-diff-editor = final.callPackage
7141
(

0 commit comments

Comments
 (0)