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

nb: init at 5.7.8 #110962

Merged
merged 7 commits into from May 12, 2022
Merged

nb: init at 5.7.8 #110962

merged 7 commits into from May 12, 2022

Conversation

toonn
Copy link
Contributor

@toonn toonn commented Jan 27, 2021

Motivation for this change

Seemed like an interesting note-taking application to package.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

sha256 = "1sw09sgskzsn3dy4ipvl52hwh5k3cwqfhjnm7rmxbzcpfk3jm3sp";
};

buildInputs = [ bash git ];
Copy link
Member

Choose a reason for hiding this comment

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

How is git used here? If it is used to extract version or commit information from the repository this would require patching.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The script uses git to synchronize your notes. So at runtime, not buildtime.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't makeWrapper be used for such things?

@stale
Copy link

stale bot commented Aug 4, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 4, 2021
Copy link
Contributor

@auroraanna auroraanna left a comment

Choose a reason for hiding this comment

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

Are you gonna finish this? I would like to test this program.

, bash, git
}:
stdenv.mkDerivation rec {
version = "5.7.8";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
version = "5.7.8";
version = "6.10.1";

Copy link
Contributor Author

@toonn toonn Apr 22, 2022

Choose a reason for hiding this comment

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

I don't currently have time to. The script is enormous and somewhat messy and this interacts poorly with wrapping. I'm mostly hoping resholve becomes advanced enough to deal with it automatically.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 16, 2022
Comment on lines 1 to 71
{ stdenv, lib, fetchFromGitHub, installShellFiles
, bash, git
}:
stdenv.mkDerivation rec {
version = "5.7.8";
pname = "nb";

src = fetchFromGitHub {
owner = "xwmx";
repo = "nb";
rev = version;
sha256 = "1sw09sgskzsn3dy4ipvl52hwh5k3cwqfhjnm7rmxbzcpfk3jm3sp";
};

buildInputs = [ bash git ];
nativeBuildInputs = [ installShellFiles ];

dontBuild = true;

installPhase = ''
mkdir -p $out/bin/
mv nb $out/bin/
mv bin/bookmark $out/bin/

runHook postInstall
'';

postInstall = ''
installShellCompletion etc/nb-completion.{bash,zsh}
'';

meta = with lib; {
description = "A command line note-taking, bookmarking, archiving, and knowledge base application";
longDescription = ''
`nb` creates notes in text-based formats like Markdown, Emacs Org mode,
and LaTeX, can work with files in any format, can import and export notes
to many document formats, and can create private, password-protected
encrypted notes and bookmarks. With `nb`, you can write notes using Vim,
Emacs, VS Code, Sublime Text, and any other text editor you like. `nb`
works in any standard Linux / Unix environment, including macOS and
Windows via WSL. Optional dependencies can be installed to enhance
functionality, but `nb` works great without them.

`nb` is also a powerful text-based CLI bookmarking system. Page
information is automatically downloaded, compiled, and saved into normal
Markdown documents made for humans, so bookmarks are easy to edit just
like any other note.

`nb` uses Git in the background to automatically record changes and sync
notebooks with remote repositories. `nb` can also be configured to sync
notebooks using a general purpose syncing utility like Dropbox so notes
can be edited in other apps on any device.

`nb` is designed to be portable, future-focused, and vendor independent,
providing a full-featured and intuitive experience within a highly
composable user-centric text interface. The entire program is a single
well-tested shell script that can be installed, copied, or curled almost
anywhere and just work, using progressive enhancement for various
experience improvements in more capable environments. `nb` works great
whether you have one notebook with just a few notes or dozens of
notebooks containing thousands of notes, bookmarks, and other items. `nb`
makes it easy to incorporate other tools, writing apps, and workflows.
`nb` can be used a little, a lot, once in a while, or for just a subset
of features. `nb` is flexible.
'';
homepage = "https://xwmx.github.io/nb/";
license = licenses.agpl3Plus;
maintainers = [ maintainers.toonn ];
platforms = platforms.all;
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{ stdenv, lib, fetchFromGitHub, installShellFiles
, bash, git
}:
stdenv.mkDerivation rec {
version = "5.7.8";
pname = "nb";
src = fetchFromGitHub {
owner = "xwmx";
repo = "nb";
rev = version;
sha256 = "1sw09sgskzsn3dy4ipvl52hwh5k3cwqfhjnm7rmxbzcpfk3jm3sp";
};
buildInputs = [ bash git ];
nativeBuildInputs = [ installShellFiles ];
dontBuild = true;
installPhase = ''
mkdir -p $out/bin/
mv nb $out/bin/
mv bin/bookmark $out/bin/
runHook postInstall
'';
postInstall = ''
installShellCompletion etc/nb-completion.{bash,zsh}
'';
meta = with lib; {
description = "A command line note-taking, bookmarking, archiving, and knowledge base application";
longDescription = ''
`nb` creates notes in text-based formats like Markdown, Emacs Org mode,
and LaTeX, can work with files in any format, can import and export notes
to many document formats, and can create private, password-protected
encrypted notes and bookmarks. With `nb`, you can write notes using Vim,
Emacs, VS Code, Sublime Text, and any other text editor you like. `nb`
works in any standard Linux / Unix environment, including macOS and
Windows via WSL. Optional dependencies can be installed to enhance
functionality, but `nb` works great without them.
`nb` is also a powerful text-based CLI bookmarking system. Page
information is automatically downloaded, compiled, and saved into normal
Markdown documents made for humans, so bookmarks are easy to edit just
like any other note.
`nb` uses Git in the background to automatically record changes and sync
notebooks with remote repositories. `nb` can also be configured to sync
notebooks using a general purpose syncing utility like Dropbox so notes
can be edited in other apps on any device.
`nb` is designed to be portable, future-focused, and vendor independent,
providing a full-featured and intuitive experience within a highly
composable user-centric text interface. The entire program is a single
well-tested shell script that can be installed, copied, or curled almost
anywhere and just work, using progressive enhancement for various
experience improvements in more capable environments. `nb` works great
whether you have one notebook with just a few notes or dozens of
notebooks containing thousands of notes, bookmarks, and other items. `nb`
makes it easy to incorporate other tools, writing apps, and workflows.
`nb` can be used a little, a lot, once in a while, or for just a subset
of features. `nb` is flexible.
'';
homepage = "https://xwmx.github.io/nb/";
license = licenses.agpl3Plus;
maintainers = [ maintainers.toonn ];
platforms = platforms.all;
};
}
{ stdenv
, lib
, fetchFromGitHub
, makeWrapper
, installShellFiles
, bash
, git
}:
stdenv.mkDerivation rec {
version = "6.10.2";
pname = "nb";
src = fetchFromGitHub {
owner = "xwmx";
repo = "nb";
rev = version;
sha256 = "sha256-n87NT+qzBq8J1n0aT2Di7iBEN9inDWXAb8c7Qd2y0TA=";
};
nativeBuildInputs = [ makeWrapper installShellFiles ];
dontBuild = true;
postPatch = ''
patchShebangs ./nb ./bin/bookmark
'';
installPhase = ''
mkdir -p $out/bin
mv nb $out/bin/
mv bin/bookmark $out/bin/
wrapProgram $out/bin/nb --prefix PATH : "${lib.makeBinPath [
bash
git
]}"
runHook postInstall
'';
postInstall = ''
installShellCompletion etc/nb-completion.{bash,zsh}
'';
meta = with lib; {
description = "A command line note-taking, bookmarking, archiving, and knowledge base application";
longDescription = ''
`nb` creates notes in text-based formats like Markdown, Emacs Org mode,
and LaTeX, can work with files in any format, can import and export notes
to many document formats, and can create private, password-protected
encrypted notes and bookmarks. With `nb`, you can write notes using Vim,
Emacs, VS Code, Sublime Text, and any other text editor you like. `nb`
works in any standard Linux / Unix environment, including macOS and
Windows via WSL. Optional dependencies can be installed to enhance
functionality, but `nb` works great without them.
`nb` is also a powerful text-based CLI bookmarking system. Page
information is automatically downloaded, compiled, and saved into normal
Markdown documents made for humans, so bookmarks are easy to edit just
like any other note.
`nb` uses Git in the background to automatically record changes and sync
notebooks with remote repositories. `nb` can also be configured to sync
notebooks using a general purpose syncing utility like Dropbox so notes
can be edited in other apps on any device.
`nb` is designed to be portable, future-focused, and vendor independent,
providing a full-featured and intuitive experience within a highly
composable user-centric text interface. The entire program is a single
well-tested shell script that can be installed, copied, or curled almost
anywhere and just work, using progressive enhancement for various
experience improvements in more capable environments. `nb` works great
whether you have one notebook with just a few notes or dozens of
notebooks containing thousands of notes, bookmarks, and other items. `nb`
makes it easy to incorporate other tools, writing apps, and workflows.
`nb` can be used a little, a lot, once in a while, or for just a subset
of features. `nb` is flexible.
'';
homepage = "https://xwmx.github.io/nb/";
license = licenses.agpl3Plus;
maintainers = with maintainers; [ toonn ];
platforms = platforms.all;
};
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I tried to make the wrapProgram function work for both nb and bookmark with a for statement but that didn't work. Is there another way than just cloning it for bookmark?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, should be optional dependencies be included here or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to wrap it separately? I think you can invoke it as a subcommand and it's a pretty generic name to claim.

I'm not really sure about the optional deps. They were atrociously badly documented when I last looked into this, most weren't actually mentioned anywhere in the docs. They're not build-time dependencies and nb simply picks them up from the environment if they're present so I don't think we should burden ourselves maintaining a potentially volatile list of deps.

Copy link
Contributor

Choose a reason for hiding this comment

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

I removed the optional deps.

@auroraanna
Copy link
Contributor

You also need to add an entry in pkgs/top-level/all-packages.nix.

@SuperSandro2000 SuperSandro2000 merged commit 44414b4 into NixOS:master May 12, 2022
@toonn
Copy link
Contributor Author

toonn commented May 13, 2022

Ah, unfortunate that this was merged. I had picked this back up, figured there was no rush since it's been so long anyway. The current state of the package means it's pretty much unusable.

It's a very annoying script to package because it's supposed to pick things up from the PATH but in my testing that didn't work properly. It doesn't manage to pick up VISUAL nor EDITOR for example so I couldn't add notes. Simply wrapping it isn't straightforward because what editor should we wrap it with? Wrapping also messes up all the help messages because nb tries to be smart about it and use the name it was executed with everywhere, hence getting .nb-wrapped everywhere in the help and that command isn't actually on the PATH so it all becomes a bit confusing.

@auroraanna
Copy link
Contributor

Then we must patch the source code so that it doesn't display .nb-wrapped.

@toonn
Copy link
Contributor Author

toonn commented May 17, 2022

That's an option but also a moving target. I was hoping we could find a way to wrap it such that that's not necessary. I think we could simply embed the PATH that ends up in the wrapper at the top of the script instead. But the problem remains that wrapping means explicitly specifying dependencies and that means we need to figure out all of the dependencies, which aren't actually documented and are not all obvious at first glance when reading/searching the script.

@uninsane uninsane mentioned this pull request Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants