-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nix: Fix Nix build, add more Nix usage docs, more relaxed Rust build …
…artifacts discovery (#28) * docs(nix): more usage info * feat(nix): build Rust workspace with crane * fix: even more relaxed sg-cody and libsg_nvim discovery * feat(nix): .envrc for nix-direnv ergonomics * fix(nix): plugin derivation should not trigger `make` * ref+bump: cleaner syntax from flakes-part and bumpb nixpkgs * fix: add PATH onto sg-cody vim.loop.spawn, solves the case cmd is 'sg-cody' * fix(ci): update cachix/install-nix-action - ref: cachix/install-nix-action#183 * ref: move .nix artifacts to contrib/ * bump deps
- Loading branch information
Showing
13 changed files
with
395 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# If nix-shell available, then nix is installed. We're going to use nix-direnv. | ||
# for automatic devshell injection after opt-in `direnv allow` | ||
if command -v nix-shell &> /dev/null | ||
then | ||
use flake | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
.direnv | ||
.envrc | ||
.env | ||
.pre-commit-config.yaml | ||
# nix build artifact | ||
result | ||
|
||
### Rust ### | ||
debug/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
pkgs, | ||
symlinkJoin, | ||
sg-workspace ? (pkgs.callPackage (import ./workspace-drv.nix)), | ||
sg-plugin ? (pkgs.callPackage (import ./plugin-drv.nix)), | ||
meta ? (pkgs.callPackage (import ./meta.nix)), | ||
... | ||
}: | ||
symlinkJoin { | ||
name = "sg.nvim"; | ||
paths = [sg-workspace sg-plugin]; | ||
inherit meta; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{lib, ...}: { | ||
description = "A plugin focused on bringing many features of sourcegraph.com onto Neovim"; | ||
homepage = "https://github.com/sourcegraph/sg.nvim"; | ||
license = lib.licenses.unlicense; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
pkgs, | ||
stdenv, | ||
proj_root ? ./., | ||
meta ? (pkgs.callPackage (import ./meta.nix)), | ||
... | ||
}: | ||
stdenv.mkDerivation { | ||
name = "sg.nvim-plugin"; | ||
src = proj_root; | ||
phases = ["installPhase"]; | ||
installPhase = '' | ||
mkdir -p $out | ||
cp -r $src/{lua,plugin} $out | ||
''; | ||
inherit meta; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
pkgs, | ||
lib, | ||
craneLib, # TODO: Make this flakes-free | ||
pkg-config, | ||
openssl, | ||
stdenv, | ||
darwin, | ||
proj_root ? ./., | ||
meta ? (pkgs.callPackage (import ./meta.nix)), | ||
... | ||
}: let | ||
# PURPOSE: if you modify non-code like github workflows, nix should not trigger a rebuild. | ||
# cleanCargoSource keeps only `.rs`, `.toml`, and files listed below as build source | ||
# NOTE: if you use `include!(<file>)` in Rust code. You'll have to opt-in the file | ||
# using a custom filter. See https://github.com/ipetkov/crane/blob/master/lib/filterCargoSources.nix | ||
code_artifacts = | ||
lib.cleanSourceWith | ||
{ | ||
src = lib.cleanSource proj_root; | ||
filter = orig_path: type: let | ||
path = toString orig_path; | ||
base = baseNameOf path; | ||
parentDir = baseNameOf (dirOf path); | ||
|
||
matchesSuffix = lib.any (suffix: lib.hasSuffix suffix base) [ | ||
# Keep rust sources | ||
".rs" | ||
|
||
# Rust configs | ||
"Cargo.toml" | ||
"config.toml" | ||
|
||
".gql" | ||
".graphql" | ||
]; | ||
|
||
# Cargo.toml already captured above | ||
isCargoFile = base == "Cargo.lock"; | ||
|
||
# .cargo/config.toml already captured above | ||
isCargoConfig = parentDir == ".cargo" && base == "config"; | ||
in | ||
type == "directory" || matchesSuffix || isCargoFile || isCargoConfig; | ||
}; | ||
|
||
crane-args = { | ||
pname = "sg.nvim-workspace"; | ||
version = (with builtins; fromTOML (readFile "${proj_root}/Cargo.toml")).package.version or "unknown"; | ||
src = code_artifacts; | ||
|
||
nativeBuildInputs = [pkg-config]; | ||
|
||
# openssl: required by reqwest (-> hyper-tls -> native-tls) | ||
buildInputs = | ||
[openssl] | ||
++ (lib.optional stdenv.isDarwin [ | ||
darwin.apple_sdk.frameworks.Security | ||
]); | ||
|
||
cargoExtraArgs = "--workspace"; | ||
inherit meta; | ||
}; | ||
|
||
# build a version with only deps to reuse as build cache | ||
workspace-deps = craneLib.buildDepsOnly crane-args; | ||
|
||
workspace-all = craneLib.buildPackage (crane-args | ||
// { | ||
# PURPOSE: This attempts to reuse build cache to skip having to build dependencies | ||
cargoArtifacts = workspace-deps; | ||
}); | ||
in | ||
workspace-all |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.