Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getexe warning #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cowsay-yasunori/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
writeShellApplication {
name = "${cowsay.pname}-yasunori";
text = ''
${yasunori-cli} | ${lib.getExe cowsay}
${lib.getExe yasunori-cli} | ${lib.getExe cowsay};
'';
}
6 changes: 5 additions & 1 deletion packages/kuusay/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
cowsay,
}:

stdenv.mkDerivation (finalAttrs: {
let
pname = "kuusay";
in
stdenv.mkDerivation (finalAttrs: {
inherit pname;
version = "1.0.0";

src = lib.cleanSource ./.;
Expand All @@ -26,4 +29,5 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';


})
7 changes: 6 additions & 1 deletion packages/nikuussay/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
cowsay,
}:

stdenv.mkDerivation (finalAttrs: {
let
pname = "nikuussay";
in
stdenv.mkDerivation (finalAttrs: {
inherit pname;
version = "1.0.0";
Comment on lines +8 to 13
Copy link
Collaborator

@natsukium natsukium Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stdenv.mkDerivation は不動点コンビネータを使って再帰していくことができるのですが、変数を let で束縛してしまうとオーバーライドした際に他で使われている箇所の変更ができません。
なので stdenv.mkDerivation の引数には self: { a = 1; b = self.a + 1; } のような関数を渡すのが望ましいです。

nix-repl> pname = "kuusay"
nix-repl> ((stdenv.mkDerivation {
    inherit pname;
    version = "1.0.0";
    passthru.pname = pname;
  }).overrideAttrs (_: { pname = "nikuussay"; })).pname
"kuusay"
nix-repl> ((stdenv.mkDerivation (finalAttrs: {
    pname = "kuusay";
    version = "1.0.0";
    passthru.pname = finalAttrs.pname;
  })).overrideAttrs (_: { pname = "nikuussay"; })).pname
"nikuussay"


src = lib.cleanSource ./.;
Expand All @@ -26,4 +29,6 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';

meta.mainProgram = pname;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上の説明に従うと finalAttrs.pname と書くべきですが、実はここは変更されたくありません。
今回の場合はパッケージの名前とコマンドの名前がたまたま一致したケースであり、一般に mainProgrampname の間には関連がないのでやや冗長にはなりますが

meta.mainProgram = "nikuussay";

とするのが良いです。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほど、共通性あるもんだと誤解していました


})
8 changes: 6 additions & 2 deletions packages/yousay/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
cowsay,
}:

stdenv.mkDerivation (finalAttrs: {
let
pname = "yousay";
in
stdenv.mkDerivation (finalAttrs: {
inherit pname;
version = "1.0.0";

src = lib.cleanSource ./.;
Expand All @@ -26,5 +29,6 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';

})
meta.mainProgram = pname;

})