-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
reSnap: init at 2.5.2 #334700
base: master
Are you sure you want to change the base?
reSnap: init at 2.5.2 #334700
Conversation
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/4426 |
pkgs/by-name/re/resnap/package.nix
Outdated
meta = with lib; { | ||
description = " Take screnshots of your reMarkable tablet over SSH"; | ||
homepage = "https://github.com/cloudsftp/reSnap"; | ||
license = with licenses; [mit]; | ||
maintainers = with maintainers; [_404wolf]; | ||
mainProgram = "reSnap"; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meta = with lib; { | |
description = " Take screnshots of your reMarkable tablet over SSH"; | |
homepage = "https://github.com/cloudsftp/reSnap"; | |
license = with licenses; [mit]; | |
maintainers = with maintainers; [_404wolf]; | |
mainProgram = "reSnap"; | |
}; | |
meta = { | |
description = " Take screnshots of your reMarkable tablet over SSH"; | |
homepage = "https://github.com/cloudsftp/reSnap"; | |
license = with lib.licenses; [ mit ]; | |
maintainers = with lib.maintainers; [ _404wolf ]; | |
mainProgram = "reSnap"; | |
}; |
pkgs/by-name/re/resnap/package.nix
Outdated
runtimeInputs = with pkgs; [ | ||
ffmpeg | ||
feh | ||
imagemagick_light | ||
lz4 | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use pkgs
inside the derivation. Instead, add the dependencies to the inputs.
runtimeInputs = with pkgs; [ | |
ffmpeg | |
feh | |
imagemagick_light | |
lz4 | |
]; | |
runtimeInputs = [ | |
ffmpeg | |
feh | |
imagemagick_light | |
lz4 | |
]; |
pkgs/by-name/re/resnap/package.nix
Outdated
lib, | ||
pkgs, | ||
fetchFromGitHub, | ||
writeShellApplication, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use pkgs
inside the derivation. Instead, add the dependencies to the inputs.
lib, | |
pkgs, | |
fetchFromGitHub, | |
writeShellApplication, | |
lib, | |
fetchFromGitHub, | |
writeShellApplication, | |
ffmpeg, | |
feh, | |
imagemagick_light, | |
lz4, |
pkgs/by-name/re/resnap/package.nix
Outdated
lz4 | ||
]; | ||
|
||
text = "${fetchFromGitHub { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File should be formatted with nixfmt
pkgs/by-name/re/resnap/package.nix
Outdated
fetchFromGitHub, | ||
writeShellApplication, | ||
}: | ||
writeShellApplication { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're using writeShellApplication
, we don't have a version
or src
attributes, but they're pretty useful to have, so we can do something like this:
writeShellApplication { | |
let | |
name = "reSnap"; | |
version = "2.5.2"; | |
src = fetchFromGitHub { | |
owner = "cloudsftp"; | |
repo = "reSnap"; | |
rev = "v${version}"; | |
hash = "sha256-P+q5NMGtXE2XCcGGHZJGw8RoOqJSHSv7oyMLkn/ltfY="; | |
}; | |
in | |
writeShellApplication { | |
inherit name; | |
runtimeInputs = [ | |
feh | |
ffmpeg | |
imagemagick_light | |
lz4 | |
]; | |
text = "${src}/reSnap.sh"; | |
meta = { | |
description = " Take screnshots of your reMarkable tablet over SSH"; | |
homepage = "https://github.com/cloudsftp/reSnap"; | |
license = with lib.licenses; [ mit ]; | |
maintainers = with lib.maintainers; [ _404wolf ]; | |
mainProgram = "reSnap"; | |
}; | |
} |
Also, the latest git revision seems to be the same as the latest tagged release (2.5.2), so we should use that, instead.
Can you update the commit message and the PR title to reflect this?
7e9084e
to
72a9e5a
Compare
Cool, I've made all the changes, but I rebased the wrong things and am fixing a git issue now. This should be ready to merge soon |
I think it's all fixed and ready! Thanks again for all the great feedback! |
pkgs/by-name/re/resnap/package.nix
Outdated
name = "reSnap"; | ||
version = "2.5.2"; | ||
|
||
src = stdenv.mkDerivation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you're using mkDerivation
to patch the script name. However, we should use stdenvNoCC
since we're not compiling anything.
src = stdenv.mkDerivation { | |
src = stdenvNoCC.mkDerivation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, super cool, thanks for showing me this!
da1552a
to
62c1dcf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
maintainers/maintainer-list.nix
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase
pkgs/by-name/re/resnap/package.nix
Outdated
phases = [ | ||
"unpackPhase" | ||
"patchPhase" | ||
"installPhase" | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phases = [ | |
"unpackPhase" | |
"patchPhase" | |
"installPhase" | |
]; |
pkgs/by-name/re/resnap/package.nix
Outdated
''; | ||
}; | ||
in | ||
writeShellApplication { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not copy the code from src to a subdirectory in out and have a proper application with pname, version, etc?
pkgs/by-name/re/resnap/package.nix
Outdated
"installPhase" | ||
]; | ||
postPatch = '' | ||
substituteInPlace ./reSnap.sh --replace-quiet "\$0" "reSnap" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
substituteInPlace ./reSnap.sh --replace-quiet "\$0" "reSnap" | |
substituteInPlace ./reSnap.sh --replace-fail "\$0" "reSnap" |
4771e0d
to
bbed8c0
Compare
Hey @SuperSandro2000, good call about wrapping with mkDerivation, I've made the change. If I'm reading right you want to remove explicit phases -- why is this? And how does the current state look? Thanks! |
@SuperSandro2000 not to be annoying, but have you had a chance to look this over again? |
Hey @404Wolf, I think you're doing great so far, but I believe the package can still be improved further:
As such, here is what I think the derivation should look like: package.nix{
lib,
stdenvNoCC,
fetchFromGitHub,
ffmpeg,
feh,
imagemagick_light,
lz4,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "resnap";
version = "2.5.2";
src = fetchFromGitHub {
owner = "cloudsftp";
repo = "reSnap";
rev = "v${finalAttrs.version}";
hash = "sha256-thVyf1gTDPLQVtZKoWL7SGiWI++ICWqmF/Ar57I3WP8=";
};
buildInputs = [
ffmpeg
feh
imagemagick_light
lz4
];
installPhase = ''
runHook preInstall
install -D ./reSnap.sh $out/bin/reSnap
runHook postInstall
'';
postFixup = ''
substituteInPlace $out/bin/reSnap \
--replace-fail "\$0" "reSnap"
'';
meta = {
description = "Take screnshots of your reMarkable tablet over SSH";
homepage = "https://github.com/cloudsftp/reSnap";
license = with lib.licenses; [ mit ];
maintainers = with lib.maintainers; [ _404wolf ];
mainProgram = "reSnap";
};
}) Let me know what you think and if you have any questions regarding this, don't hesitate to ask. |
2f7d629
to
7ebf0f2
Compare
I could be wrong, but I don't think that buildInputs are available at runtime; it didn't seem to work. I cleaned it up a bit by only using one |
I believe nativeBuildInputs = [ makeWrapper ];
runtimeInputs = [
ffmpeg
feh
imagemagick_light
lz4
];
postFixup = ''
substituteInPlace $out/bin/reSnap \
--replace-fail "\$0" "reSnap"
wrapProgram $out/bin/reSnap \
--set PATH "${lib.makeBinPath finalAttrs.runtimeInputs}"
''; |
pkgs/by-name/re/resnap/package.nix
Outdated
homepage = "https://github.com/cloudsftp/reSnap"; | ||
license = with lib.licenses; [ mit ]; | ||
maintainers = with lib.maintainers; [ _404wolf ]; | ||
mainProgram = name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes to meta
should not cause a rebuild, which would happen if name
changes. We should explicitly set this.
mainProgram = name; | |
mainProgram = "reSnap"; |
pkgs/by-name/re/resnap/package.nix
Outdated
installPhase = '' | ||
runHook preInstall | ||
|
||
mkdir -p $out/bin | ||
echo PATH="\$PATH:${ | ||
lib.strings.makeBinPath [ | ||
ffmpeg | ||
feh | ||
imagemagick_light | ||
lz4 | ||
] | ||
}" > $out/bin/reSnap | ||
cat ./reSnap.sh >> $out/bin/reSnap | ||
chmod +x $out/bin/reSnap | ||
|
||
runHook postInstall | ||
''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use runtimeInputs
or wrap the executable instead of doing this.
installPhase = '' | |
runHook preInstall | |
mkdir -p $out/bin | |
echo PATH="\$PATH:${ | |
lib.strings.makeBinPath [ | |
ffmpeg | |
feh | |
imagemagick_light | |
lz4 | |
] | |
}" > $out/bin/reSnap | |
cat ./reSnap.sh >> $out/bin/reSnap | |
chmod +x $out/bin/reSnap | |
runHook postInstall | |
''; | |
installPhase = '' | |
runHook preInstall | |
install -D ./reSnap.sh $out/bin/reSnap | |
runHook postInstall | |
''; |
pkgs/by-name/re/resnap/package.nix
Outdated
|
||
postFixup = '' | ||
substituteInPlace $out/bin/reSnap \ | ||
--replace-fail "\$0" ${name} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--replace-fail "\$0" ${name} | |
--replace-fail "\$0" reSnap |
pkgs/by-name/re/resnap/package.nix
Outdated
pname = lib.strings.toLower name; | ||
version = "2.5.2"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "cloudsftp"; | ||
repo = name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pname = lib.strings.toLower name; | |
version = "2.5.2"; | |
src = fetchFromGitHub { | |
owner = "cloudsftp"; | |
repo = name; | |
pname = "resnap; | |
version = "2.5.2"; | |
src = fetchFromGitHub { | |
owner = "cloudsftp"; | |
repo = "reSnap"; |
pkgs/by-name/re/resnap/package.nix
Outdated
let | ||
name = "reSnap"; | ||
in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let | |
name = "reSnap"; | |
in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hey @SuperSandro2000, any chance you could look this over at some point? I think it's ready to merge. Thanks! |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/4607 |
postFixup = '' | ||
substituteInPlace $out/bin/reSnap \ | ||
--replace-fail "\$0" reSnap | ||
|
||
wrapProgram $out/bin/reSnap \ | ||
--suffix PATH : "${lib.makeBinPath finalAttrs.runtimeInputs}" | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
|
||
install -D reSnap.sh $out/bin/reSnap | ||
|
||
runHook postInstall | ||
''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
postFixup = '' | |
substituteInPlace $out/bin/reSnap \ | |
--replace-fail "\$0" reSnap | |
wrapProgram $out/bin/reSnap \ | |
--suffix PATH : "${lib.makeBinPath finalAttrs.runtimeInputs}" | |
''; | |
installPhase = '' | |
runHook preInstall | |
install -D reSnap.sh $out/bin/reSnap | |
runHook postInstall | |
''; | |
installPhase = '' | |
runHook preInstall | |
install -D reSnap.sh $out/bin/reSnap | |
runHook postInstall | |
''; | |
postFixup = '' | |
substituteInPlace $out/bin/reSnap \ | |
--replace-fail "\$0" reSnap | |
wrapProgram $out/bin/reSnap \ | |
--suffix PATH : "${lib.makeBinPath finalAttrs.runtimeInputs}" | |
''; |
Fixup is executed after install
Description of changes
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.