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

spacevim: init at v1.5.0 #93365

Merged
merged 1 commit into from Dec 8, 2020
Merged

spacevim: init at v1.5.0 #93365

merged 1 commit into from Dec 8, 2020

Conversation

fzakaria
Copy link
Contributor

Spacevim is a fully loaded vim/neovim installation in the spirit
of https://www.spacemacs.org/

It's configured with a TOML file rather than vimscript and includes
a wide array of configuration found at https://spacevim.org/.

I tested this by running:

 nix-build --no-out-link -E 'with import <nixpkgs> {}; callPackage ./pkgs/applications/editors/spacevim {}'

/nix/store/nbxjak1cll8m1rm90cbkld5qpahx3gb2-spacevim/bin/spacevim
Motivation for this change

I hate configuring my vim & neovim files with plugins or vimrc files.
I like a very curated & hyper opinionated experience which is what spacevim brings to the table.

It's extremely sensible & has a lot of "layers" for almost anything.
I decided to rename the binary "spacevim" so that it doesn't conflict with other installations of vim.

I will say that at the moment this is one of my first few derivations & it's not fully nix compliant.
I would appreciate help to get it over the finish line.

  1. SpaceVim downloads any missing plugins via the specific TOML file to ~/.cache/vimfiles
    I would like to make use of vimPlugins instead

  2. It would be better to have users customize the spacevim installation via a nix attrset that gets converted to TOML.

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.

Copy link
Contributor

@skykanin skykanin left a comment

Choose a reason for hiding this comment

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

I don't use vim so I can't comment on that aspect, but I've left some comments regarding the nix expression

pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
src = fetchFromGitHub {
owner = "SpaceVim";
repo = "SpaceVim";
rev = "c937c0e2fd37207c36c8c5e53b36c41d7222fee6";
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be using the latest release of spacevim (1.4.0 of writing this) and not a random commit. You would also need to add the version field, switch from name to pname and update the PR to match the version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@skykanin their install script installs it off of master.
I don't think they are making releases that often.

What's guidance here ?
Looks like the commit SHA is more appropriate.

I tried setting pname but it didn't work (maybe only works when version present?)

Copy link
Contributor

@skykanin skykanin Jul 17, 2020

Choose a reason for hiding this comment

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

I'm not completely sure what the standard practice is for versioning, but personally I would use the latest official release and if you want the bleeding edge version from the master branch override the package build locally. Indeed pname does require a version because it combines them into "${pname}-${version}", from the manual.

Copy link
Contributor

Choose a reason for hiding this comment

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

name should indeed not be used anymore. When using a commit (rather than a release tag), there are still diverging conventions, but they all seem to share that the version should contain the commit date in the form YYYY-MM-DD and that unstable should be used somewhere. My preferred flavor:

pname = "spacevim";
version = "unstable-YYYY-MM-DD"

(where you fill YYYY-MM-DD).

I also agree with @skykanin that, unless the latest release is very old, using a tagged version is highly preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks -- I've changed to match your suggestions.
The tagged version is really old; so i've opted to change to unstable methodology you've prescribed.

Copy link
Member

Choose a reason for hiding this comment

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

@fzakaria @danieldk the -unstable suffix belongs to pname. See #68518.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like it hasn't been decided yet @Ma27 ; hoping we can just come back to this afterwards.
It will be a small fixup.

Copy link
Contributor

Choose a reason for hiding this comment

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

my argument was that changing the pname essentially "changes the package" as far as repology is concerned, which is weird to have packages move in and out of unique categorization. Having the version contain unstable at least keeps the package name the same.

Then again, this convention was first used when name = "pkg-${version}"; was still very common, and there wasn't a clear delineation between pname and version established.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As an outsider: I'm in favor as a user of having pname be the package name; unstable feels itself like a version moniker.

pkgs/applications/editors/spacevim/default.nix Outdated Show resolved Hide resolved
@skykanin
Copy link
Contributor

skykanin commented Jul 17, 2020

There should only be one commit for the spacevim files spacevim: init at ... as detailed here also since this is your first PR you don't yet exist in the maintainers list so you need a separate commit for adding yourself to the maintainers list, example.

@fzakaria
Copy link
Contributor Author

Thanks -- I rebased & added a commit for the maintainers list

Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!

Apart from the comments below, a few more notes:

  • Your second commit doesn't match our contribution guidelines. You may want to rename it to e.g. maintainers: add fzakaria
  • When pressing <C-p> in Vim, I get the error that fzf is not found when testing this in a pure shell-env. It would make sense IMHO to add those external dependencies as a wrapper to the package.

sha256 = "141fl5g6i2h72dk5121v3mc0bwb812hd8qa5qw83jyz9q20jcsgn";
};

buildInputs = [ vim-customized makeWrapper ];
Copy link
Member

Choose a reason for hiding this comment

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

At least makeWrapper belongs to nativeBuildInputs. However we should probably disable cross-compilation here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you help me understand the difference ?
Happy to make the change but also willing to learn.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to nativeBuildInputs

Copy link
Member

Choose a reason for hiding this comment

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

Now that I think of it, vim-customized should probably be in nativeBuildInputs as well.

Happy to make the change but also willing to learn.

In nativeBuildInputs are all dependencies that are used during the derivation's build. When performing a cross-build, this is needed to make sure that only packages for the host's architecture are used for the build while all runtime dependencies (e.g. libraries in buildInputs) are built against the target's architecture.

A more detailed explanation is in the link I posted above (https://nixos.org/nixpkgs/manual/#ssec-stdenv-dependencies).

config = if builtins.stringLength spacevim_toml == 0 then
"${builtins.readFile ./init.toml}"
else
spacevim_toml;
Copy link
Member

Choose a reason for hiding this comment

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

How about merging spacevim_toml and init.toml together so that a user doesn't have to rewrite the entire config when having to change a few details.

Also, I'm wondering if it might be better to accept an attr-set and generate TOML-config from that. Bonus points for writing some docs (in doc/builders/packages).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well i'm not sure about a merge since that sounds like making deletes challening.
I would love to use something like nix2toml but I couldn't find a good solution.
(maybe remarshal ?)

Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason against converting init.toml into a Nix attr-set? Then you can merge it together with another attr-set using lib.recursiveUpdate.

In the end you'd only have to render a single attr-set to toml. Sth. like this seem to be implemented in nixos/modules/virtualisation/containers.nix already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in latest rebase

@fzakaria
Copy link
Contributor Author

@Ma27 can you let me know what's the best way to test a derivation in nixpkg in a pure shell?
I have tried the following but it's tedious to remember all the phases to type manually

nix-shell -E 'with import <nixpkgs> {}; callPackage ./pkgs/applications/editors/spacevim {}' --pure

@fzakaria
Copy link
Contributor Author

Thanks for the feedback @Ma27 I ended up hacking with

nix-shell -I nixpkgs=/home/fmzakari/Development/nixpkgs -p spacevim --pure

not sure if that's the best workflow but at least better than going through the builder manually!

I added the additional binaries fzf, git & ripgrep like you've mentioned by running it in pure.

@fzakaria fzakaria closed this Jul 18, 2020
@fzakaria fzakaria requested a review from Ma27 July 18, 2020 20:34
@Ma27 Ma27 reopened this Jul 18, 2020
@fzakaria
Copy link
Contributor Author

Whoops. accidental close thanks.

pkgs/applications/editors/spacevim/init.toml Outdated Show resolved Hide resolved
let &helplang = 'jp'
endif
""
- " generate tags for SpaceVim
Copy link

Choose a reason for hiding this comment

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

Why this patch is needed? the tags should be generate when spacevim is installed.

Copy link
Contributor Author

@fzakaria fzakaria Jul 19, 2020

Choose a reason for hiding this comment

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

@wsdjeg -- The way in which Nix operates is that the applications are stored in /nix/store which is a read-only directory structure that is CAS (content addressable storage).

SpaceVim I found wants to generate the helptags in the same directory as the SpaceVim git directory which is read-only & would fail (_spacevim_root_dir) the way in which it is structured here.

At the moment I've disabled the help tag generation but maybe a better solution would be to generate the helptag docs in global_dir (i.e. SPACEVIM_DIR) which is read+write

Copy link
Member

Choose a reason for hiding this comment

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

are stored in /nix/store which is a read-only directory structure that is CAS (content addressable storage).

While the reasoning about your patch is correct, I'd like to point out that /nix/store is actually not entirely content-addressable: this is true for fixed-output derivations, but not for package-definitions since the hash is generated using the derivation's source.

Efforts towards more content-addressability (i.e. hashing a derivation's output) are proposed here: NixOS/rfcs#62

@Ma27
Copy link
Member

Ma27 commented Jul 20, 2020

I have tried the following but it's tedious to remember all the phases to type manually

nix-shell -I nixpkgs=$(pwd) -p spacevim --pure. (the -p argument ensures that the built package appears in your nix-shell)

Comment on lines 5 to 13
# Once https://github.com/NixOS/nixpkgs/pull/75584 is merged we can use the TOML generator
toTOML = name: value: runCommandNoCC name {
nativeBuildInputs = [ remarshal ];
value = builtins.toJSON value;
passAsFile = [ "value" ];
} ''
mkdir $out
json2toml "$valuePath" "$out/${name}"
'';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Ma27 This generates the TOML from the Nix attrset now.
I default the value in the function definition above.
spacevim_config ? import ./init.nix

@fzakaria fzakaria requested a review from danieldk July 20, 2020 20:52
@fzakaria
Copy link
Contributor Author

fzakaria commented Jul 28, 2020

Ping. Anyone care to approve, comment or update ?
Thanks!

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/192

@fzakaria
Copy link
Contributor Author

@happysalada @SuperSandro2000 i've rebased, fixed merge conflict & used the new TOML stuff

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 93365 run on x86_64-linux 1

1 package built:
  • spacevim

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 93365 run on x86_64-darwin 1

1 package built:
  • spacevim

@rissson
Copy link
Member

rissson commented Dec 2, 2020

The specified SpaceVim commit (c937c0e2fd37207c36c8c5e53b36c41d7222fee6) is from July 2020. Since then they have tagged version 1.5.0. Is the original discussion about versions still relevant? Shouldn't this be updated to be a bit more recent?

@SuperSandro2000
Copy link
Member

But then we finally merge it.

@fzakaria fzakaria changed the title spacevim: init at c937c0e spacevim: init at v1.5.0 Dec 3, 2020
@fzakaria
Copy link
Contributor Author

fzakaria commented Dec 3, 2020

Longest PR to get it in 🥇

pkgs/applications/editors/spacevim/default.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/spacevim/default.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/spacevim/default.nix Outdated Show resolved Hide resolved
@rissson
Copy link
Member

rissson commented Dec 3, 2020

Result of nixpkgs-review pr 93365 1

1 package built:
  • spacevim

Spacevim is a fully loaded vim/neovim installation in the spirit
of https://www.spacemacs.org/

It's configured with a TOML file rather than vimscript and includes
a wide array of configuration found at https://spacevim.org/

Update pkgs/applications/editors/spacevim/default.nix

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

Update pkgs/applications/editors/spacevim/init.nix

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

Update pkgs/applications/editors/spacevim/default.nix

Co-authored-by: risson <18313093+rissson@users.noreply.github.com>
@rissson
Copy link
Member

rissson commented Dec 4, 2020

Result of nixpkgs-review pr 93365 1

1 package built:
  • spacevim

@rissson
Copy link
Member

rissson commented Dec 4, 2020

@SuperSandro2000 I think we can merge this now

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 93365 run on x86_64-linux 1

1 package built:
  • spacevim

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 93365 run on x86_64-darwin 1

1 package built:
  • spacevim

@SuperSandro2000 SuperSandro2000 merged commit 395cfa4 into NixOS:master Dec 8, 2020
@happysalada
Copy link
Contributor

Thank you guys for the hard work!

@happysalada
Copy link
Contributor

Just tried on macos
Spacevim starts initially with no problem, but on first start it asks the question "basic mode" or "dark powered mode"
Upon choosing dark powered mode it says

Error detected while processing function SpaceVim#custom#autoconfig[6]..<SNR>199_menu[39]..<SNR>42_awesome
_mode[4]..<SNR>42_write_to_config:
line   11:
E739: Cannot create directory: /nix/store/ka0166by5ybdin2ibpkqbv10yzipfrlx-init.toml

Just leaving it here for information purpose.

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

10 participants