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
headphones: init at 0.5.19 #46514
headphones: init at 0.5.19 #46514
Conversation
You can do that in here, it just needs to be a separate commit. Also I was really tempted to improve your package so I went right ahead and did it for you 🤣 diff --git a/pkgs/servers/headphones/default.nix b/pkgs/servers/headphones/default.nix
index 37ddcd03a94..3d428a5ac58 100644
--- a/pkgs/servers/headphones/default.nix
+++ b/pkgs/servers/headphones/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchFromGitHub, python2 }:
+{ stdenv, fetchFromGitHub, python2, makeWrapper }:
-stdenv.mkDerivation rec {
+python2.pkgs.buildPythonApplication rec {
name = "headphones-${version}";
version = "0.5.19";
@@ -11,15 +11,18 @@ stdenv.mkDerivation rec {
sha256 = "0z39gyan3ksdhnjxxs7byamrzmrk8cn15g300iqigzvgidff1lq0";
};
+ dontBuild = true;
+ doCheck = false;
+
+ nativeBuildInputs = [ makeWrapper ];
buildInputs = [ python2 ];
installPhase = ''
mkdir -p $out
cp -R * $out/
- mkdir $out/bin
- echo -e "#!/usr/bin/env sh\n${python2}/bin/python $out/Headphones.py \$*" > $out/bin/headphones
- chmod +x $out/bin/headphones
- echo "v${version}" >> $out/version.txt
+
+ mkdir -p $out/bin
+ makeWrapper $out/Headphones.py $out/bin/headphones
'';
meta = with stdenv.lib; { Using |
Awesome, thanks! I was originally just copying I think the one from couchpotato. I made those changes and also added myself as a maintainer in separate commits |
I made those changes |
mkdir -p $out/bin | ||
cp -R {data,headphones,lib,Headphones.py} $out/ | ||
|
||
makeWrapper $out/Headphones.py $out/bin/headphones |
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.
Isn't this almost the same as just copying Headphones.py
to bin/headphones
? Except without polluting top-level $out
and in a way that is convenient for patchShebangs
.
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.
No - that doesn't seem to work because it breaks the imports. Unless I'm doing something wrong? I just changed the makeWrapper line to cp $out/Headphones.py $out/bin/headphones
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.
Because the imports are relative to where the main script is called - so it's no longer the case if the main file is being copied to and run from another location
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.
Ahh so Headphones.py
needs to be at that location. That was my assumption at first.
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.
Hm. As the lib/
layout is not for importing this as a library package anyway, in such cases I do something like $out/lib/headphones
, copy the entire source-directory there, then wrap the scripts from there.
Moved the module from services/networking to services/misc |
@GrahamcOfBorg build headphones |
description = "Host to listen on."; | ||
}; | ||
port = mkOption { | ||
type = types.ints.u16; |
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.
Btw, there's types.port
for the future
Motivation for this change
Add headphones package and service for NixOS. I can add myself as a maintainer - I just wasn't sure if I should do that with this pull request or separately.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)