Skip to content

Commit 012671b

Browse files
snippets/nix-mode: update/modernization to the new guidelines
Nixpkgs has new, clearer guidelines for contribution, like pre- and post- hooks for the phases and lib independent from stdenv, among others. This commit applies the guidelines to this recent work.
1 parent 491f1b9 commit 012671b

File tree

12 files changed

+106
-59
lines changed

12 files changed

+106
-59
lines changed

snippets.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

snippets/nix-mode/buildPhase

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# key: bp
44
# --
55
buildPhase= ''
6+
runHook preBuild
67
$1
8+
runHook postBuild
79
'';
810
$0

snippets/nix-mode/checkPhase

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# key: ch
44
# --
55
checkPhase= ''
6+
runHook preCheck
67
$1
8+
runHook postCheck
79
'';
810
$0

snippets/nix-mode/configurePhase

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# key: cp
44
# --
55
configurePhase= ''
6+
runHook preConfigure
67
$1
8+
runHook postConfigure
79
'';
810
$0

snippets/nix-mode/distPhase

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# key: dp
44
# --
55
distPhase= ''
6+
runHook preDist
67
$1
8+
runHook postDist
79
'';
810
$0

snippets/nix-mode/fixPhase renamed to snippets/nix-mode/fixupPhase

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# name: fixPhase
33
# key: fp
44
# --
5-
fixPhase= ''
5+
fixupPhase= ''
6+
runHook preFixup
67
$1
8+
runHook postFixup
79
'';
810
$0

snippets/nix-mode/installCheckPhase

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# key: ic
44
# --
55
installCheckPhase= ''
6+
runHook preInstallCheck
67
$1
8+
runHook postInstallCheck
79
'';
810
$0

snippets/nix-mode/installPhase

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
# key: ip
44
# --
55
installPhase= ''
6+
runHook preInstall
67
${1: mkdir -p \$out/bin
78
for f in \$(find . -executable -type f);
89
do
910
cp \$f \$out/bin/
1011
done}
12+
runHook postInstall
1113
'';
1214
$0

snippets/nix-mode/package_github

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
# name: package github
33
# key: pg
44
# --
5-
{ stdenv, fetchFromGitHub$1 }:
5+
{ lib
6+
, stdenv
7+
, fetchFromGitHub
8+
$1
9+
}:
610

711
stdenv.mkDerivation rec {
812
pname = "$2";
@@ -12,56 +16,61 @@ stdenv.mkDerivation rec {
1216
owner = "$4";
1317
repo = "$2";
1418
rev = "${5:v\$\{version\}}";
15-
sha256 = "$6";
19+
sha256 = "${6:\$\{lib.fakeSha256\}}";
1620
};
1721

22+
nativeBuildInputs = [ ];
1823
buildInputs = [ $1 ];
1924

20-
meta = with stdenv.lib; {
21-
description = "$7";
22-
homepage = "https://${8:github.com/$4/$2}";
23-
25+
meta = with lib; {
26+
homepage = "https://${7:github.com/$4/$2}";
27+
description = "$8";
2428
license = licenses.${9:$$
2529
(yas-choose-value '(
26-
"asl20"
27-
"bsd2"
28-
"bsd3"
29-
"free"
30-
"gpl2Only"
31-
"gpl2Plus"
32-
"gpl3Only"
33-
"gpl3Plus"
34-
"isc"
35-
"lgpl21Only"
36-
"lgpl21Plus"
37-
"lgpl2Only"
38-
"lgpl2Plus"
39-
"lgpl3Only"
40-
"mit"
41-
"mpl20"
42-
"ofl"
43-
"unfree"
30+
"agpl3"
31+
"asl20"
32+
"bsd1"
33+
"bsd2"
34+
"bsd3"
35+
"free"
36+
"gpl2"
37+
"gpl2Only"
38+
"gpl2Plus"
39+
"gpl3"
40+
"gpl3Only"
41+
"gpl3Plus"
42+
"isc"
43+
"lgpl21Only"
44+
"lgpl21Plus"
45+
"lgpl2Only"
46+
"lgpl2Plus"
47+
"lgpl3"
48+
"lgpl3Only"
49+
"mit"
50+
"mpl20"
51+
"ofl"
52+
"unfree"
4453
))};
4554
maintainers = with maintainers; [ $10 ];
4655
platforms = platforms.${11:$$
4756
(yas-choose-value '(
48-
"linux"
49-
"unix"
5057
"all"
58+
"allBut"
59+
"arm"
60+
"cygwin"
5161
"darwin"
52-
"gnu"
5362
"freebsd"
54-
"openbsd"
55-
"netbsd"
56-
"cygwin"
63+
"gnu"
64+
"i686"
5765
"illumos"
58-
"none"
59-
"allBut"
66+
"linux"
6067
"mesaPlatforms"
61-
"x86"
62-
"i686"
63-
"arm"
6468
"mips"
69+
"netbsd"
70+
"none"
71+
"openbsd"
72+
"unix"
73+
"x86"
6574
))};
6675
};
6776
}

snippets/nix-mode/package_url

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,73 @@
22
# name: package url
33
# key: pu
44
# --
5-
{ stdenv, fetchurl$1}:
5+
{ lib
6+
, stdenv
7+
, fetchurl
8+
$1
9+
}:
610

711
stdenv.mkDerivation rec {
8-
version = "$2";
9-
name = "$3-\$\{version\}";
12+
pname = "$2";
13+
version = "$3";
1014

1115
src = fetchurl {
1216
url = "$4";
13-
sha256 = "$5";
17+
sha256 = "${5:\$\{lib.fakeSha256\}}";
1418
};
1519

20+
nativeBuildInputs = [ ];
1621
buildInputs = [ $1 ];
1722

18-
meta = {
19-
description = "$6";
20-
homepage = https://$7;
21-
license = stdenv.lib.licenses.${8:$$
23+
meta = with lib; {
24+
homepage = "https://$6";
25+
description = "$7";
26+
license = licenses.${8:$$
2227
(yas-choose-value '(
2328
"agpl3"
2429
"asl20"
30+
"bsd1"
2531
"bsd2"
2632
"bsd3"
33+
"free"
2734
"gpl2"
35+
"gpl2Only"
36+
"gpl2Plus"
2837
"gpl3"
38+
"gpl3Only"
39+
"gpl3Plus"
40+
"isc"
41+
"lgpl21Only"
42+
"lgpl21Plus"
43+
"lgpl2Only"
44+
"lgpl2Plus"
2945
"lgpl3"
46+
"lgpl3Only"
3047
"mit"
48+
"mpl20"
49+
"ofl"
50+
"unfree"
3151
))};
32-
maintainers = [ stdenv.lib.maintainers.$9 ];
33-
platforms = stdenv.lib.platforms.${10:$$
52+
maintainers = with maintainers; [ $9 ];
53+
platforms = platforms.${10:$$
3454
(yas-choose-value '(
35-
"gnu"
36-
"linux"
55+
"all"
56+
"allBut"
57+
"arm"
58+
"cygwin"
3759
"darwin"
3860
"freebsd"
39-
"openbsd"
40-
"netbsd"
41-
"cygwin"
61+
"gnu"
62+
"i686"
4263
"illumos"
43-
"unix"
44-
"all"
45-
"none"
46-
"allBut"
64+
"linux"
4765
"mesaPlatforms"
48-
"x86"
49-
"i686"
50-
"arm"
5166
"mips"
67+
"netbsd"
68+
"none"
69+
"openbsd"
70+
"unix"
71+
"x86"
5272
))};
5373
};
5474
}

0 commit comments

Comments
 (0)