Initial commit
This commit is contained in:
84
home/editors/nvim/plugins/snippet/default.nix
Normal file
84
home/editors/nvim/plugins/snippet/default.nix
Normal file
@@ -0,0 +1,84 @@
|
||||
{pkgs, ...}: {
|
||||
plugins.luasnip = {
|
||||
enable = true;
|
||||
settings = {
|
||||
enable_autosnippets = true;
|
||||
store_selection_keys = "<Tab>";
|
||||
};
|
||||
fromVscode = [
|
||||
{
|
||||
lazyLoad = true;
|
||||
paths = pkgs.vimPlugins.friendly-snippets;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
extraConfigLua = let
|
||||
snippets = {
|
||||
nix = import ./nix;
|
||||
};
|
||||
|
||||
escape = text: pkgs.lib.generators.toLua {} text;
|
||||
escapeLines = text: pkgs.lib.generators.toLua {} (pkgs.lib.strings.splitString "\n" text);
|
||||
|
||||
escapeLua = pkgs.lib.escape ["\\" "\"" "\n"];
|
||||
|
||||
generateSnippetBody = {
|
||||
template,
|
||||
placeholders ? {},
|
||||
delimiters ? "<>",
|
||||
...
|
||||
}:
|
||||
if placeholders == {}
|
||||
then "t(${escapeLines template})"
|
||||
else let
|
||||
templateStr = escape template;
|
||||
|
||||
generatePlaceholderEntry = index: defaultValue: let
|
||||
node =
|
||||
if defaultValue == null
|
||||
then "i(${index})"
|
||||
else "i(${index}, \"${escapeLua defaultValue}\")";
|
||||
in "[${index}] = ${node}";
|
||||
|
||||
placeholderEntries = pkgs.lib.attrsets.mapAttrsToList generatePlaceholderEntry placeholders;
|
||||
placeholderTable = "{ ${pkgs.lib.strings.concatStringsSep ", " placeholderEntries} }";
|
||||
delimitersTable = "{ delimiters = \"${escapeLua delimiters}\" }";
|
||||
in "fmt(${templateStr}, ${placeholderTable}, ${delimitersTable})";
|
||||
|
||||
generateLanguageSnippets = langSnippets: let
|
||||
snippetEntries =
|
||||
pkgs.lib.attrsets.mapAttrsToList (
|
||||
name: definition: let
|
||||
snippetName = escapeLua name;
|
||||
snippetBody = generateSnippetBody definition;
|
||||
in " s(\"${snippetName}\", ${snippetBody})"
|
||||
)
|
||||
langSnippets;
|
||||
in
|
||||
pkgs.lib.strings.concatStringsSep ",\n" snippetEntries;
|
||||
|
||||
buildLuasnipConfig = snippets: let
|
||||
languageBlocks =
|
||||
pkgs.lib.attrsets.mapAttrsToList (
|
||||
langName: langSnippets: ''
|
||||
ls.add_snippets("${langName}", {
|
||||
${generateLanguageSnippets langSnippets}
|
||||
})
|
||||
''
|
||||
)
|
||||
snippets;
|
||||
|
||||
allLanguageBlocks = pkgs.lib.strings.concatStringsSep "\n\n" languageBlocks;
|
||||
in ''
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local i = ls.insert_node
|
||||
local t = ls.text_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
|
||||
${allLanguageBlocks}
|
||||
'';
|
||||
in
|
||||
buildLuasnipConfig snippets;
|
||||
}
|
||||
84
home/editors/nvim/plugins/snippet/nix/ags.flake.nix
Normal file
84
home/editors/nvim/plugins/snippet/nix/ags.flake.nix
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
ags = {
|
||||
url = "github:aylur/ags";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
ags,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
|
||||
name = "<1>";
|
||||
version = "<2>";
|
||||
entry = "<3>";
|
||||
|
||||
watchScript = pkgs.writeShellScriptBin "watch" ''
|
||||
set -euo pipefail
|
||||
|
||||
export FILES=$(find . -not \( -path "./node_modules*" -o -path "./@girs*" \) -type f -name "*.ts*")
|
||||
echo "$FILES" | ${pkgs.lib.getExe pkgs.entr} -crs 'echo "Change detected, restarting..." && ags run ./main.tsx'
|
||||
'';
|
||||
|
||||
astalPackages = with ags.packages.${system}; [
|
||||
io
|
||||
astal4
|
||||
<0>
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
gjs
|
||||
watchScript
|
||||
];
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
libadwaita
|
||||
libsoup_3
|
||||
];
|
||||
in {
|
||||
packages.default = pkgs.stdenv.mkDerivation {
|
||||
inherit name version;
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
wrapGAppsHook3
|
||||
gobject-introspection
|
||||
ags.packages.${system}.default
|
||||
];
|
||||
|
||||
buildInputs =
|
||||
astalPackages
|
||||
++ buildInputs
|
||||
++ extraPackages;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/share
|
||||
cp -r * $out/share
|
||||
ags bundle ${entry} $out/bin/${name} -d "SRC='$out/share'"
|
||||
'';
|
||||
};
|
||||
|
||||
apps.default = flake-utils.lib.mkApp {
|
||||
drv = self.packages.${system}.default;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs =
|
||||
[
|
||||
(ags.packages.${system}.default.override {
|
||||
extraPackages = astalPackages ++ extraPackages;
|
||||
})
|
||||
]
|
||||
++ buildInputs;
|
||||
};
|
||||
});
|
||||
}
|
||||
116
home/editors/nvim/plugins/snippet/nix/bevy.flake.nix
Normal file
116
home/editors/nvim/plugins/snippet/nix/bevy.flake.nix
Normal file
@@ -0,0 +1,116 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
fenix = {
|
||||
url = "github:nix-community/fenix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
crane.url = "github:ipetkov/crane";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
fenix,
|
||||
crane,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
|
||||
pname = "<1>";
|
||||
version = "<2>";
|
||||
|
||||
rust-toolchain = with fenix.packages.${system};
|
||||
combine [
|
||||
stable.rustc
|
||||
stable.cargo
|
||||
stable.rust-src
|
||||
stable.rust-analyzer
|
||||
];
|
||||
|
||||
bevyDeps = with pkgs; [
|
||||
pkg-config
|
||||
# Audio
|
||||
alsa-lib
|
||||
# Vulkan
|
||||
vulkan-loader
|
||||
vulkan-tools
|
||||
libudev-zero
|
||||
# X11
|
||||
xorg.libX11
|
||||
xorg.libXcursor
|
||||
xorg.libXi
|
||||
xorg.libXrandr
|
||||
# Wayland
|
||||
wayland
|
||||
libxkbcommon
|
||||
# linker
|
||||
lld
|
||||
];
|
||||
runtimeLibs = pkgs.lib.makeLibraryPath bevyDeps;
|
||||
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain rust-toolchain;
|
||||
|
||||
cargoArtifacts = craneLib.buildDepsOnly {
|
||||
pname = "${pname}-deps";
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
nativeBuildInputs = with pkgs; [pkg-config];
|
||||
buildInputs = bevyDeps;
|
||||
};
|
||||
in {
|
||||
packages.default = craneLib.buildPackage {
|
||||
inherit pname version;
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
inherit cargoArtifacts;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
rust-toolchain
|
||||
lld
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
buildInputs = bevyDeps;
|
||||
|
||||
CARGO_PROFILE_RELEASE_LTO = "thin";
|
||||
CARGO_PROFILE_RELEASE_CODEGEN_UNITS = 1;
|
||||
CARGO_PROFILE_RELEASE_STRIP = true;
|
||||
RUSTFLAGS = "-C link-arg=-fuse-ld=lld";
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram "$out/bin/${pname}" \
|
||||
--prefix LD_LIBRARY_PATH : ${runtimeLibs}
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "<3>";
|
||||
license = licenses.mit;
|
||||
};
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
lld
|
||||
];
|
||||
|
||||
packages = with pkgs;
|
||||
[
|
||||
rust-toolchain
|
||||
cargo-watch
|
||||
cargo-edit
|
||||
cargo-tarpaulin
|
||||
]
|
||||
++ bevyDeps;
|
||||
|
||||
shellHook = ''
|
||||
export RUST_SRC_PATH=${fenix.packages.${system}.stable.rust-src}/lib/rustlib/src/rust/library
|
||||
export LD_LIBRARY_PATH=${runtimeLibs}:$LD_LIBRARY_PATH
|
||||
'';
|
||||
};
|
||||
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
});
|
||||
}
|
||||
44
home/editors/nvim/plugins/snippet/nix/default.nix
Normal file
44
home/editors/nvim/plugins/snippet/nix/default.nix
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
flake = {
|
||||
template = builtins.readFile ./flake.nix;
|
||||
placeholders = {
|
||||
"0" = null;
|
||||
};
|
||||
};
|
||||
flaketauri.template = builtins.readFile ./tauri.flake.nix;
|
||||
flakeflutter.template = builtins.readFile ./flutter.flake.nix;
|
||||
flakeags = {
|
||||
template = builtins.readFile ./ags.flake.nix;
|
||||
placeholders = {
|
||||
"1" = "project-name";
|
||||
"2" = "0.1.0";
|
||||
"3" = "main.tsx";
|
||||
"0" = null;
|
||||
};
|
||||
};
|
||||
flakerust = {
|
||||
template = builtins.readFile ./rust.flake.nix;
|
||||
placeholders = {
|
||||
"1" = "rust-app";
|
||||
"2" = "0.1.0";
|
||||
"3" = "A Rust application";
|
||||
"0" = null;
|
||||
};
|
||||
};
|
||||
flakebevy = {
|
||||
template = builtins.readFile ./bevy.flake.nix;
|
||||
placeholders = {
|
||||
"1" = "bevy-app";
|
||||
"2" = "0.1.0";
|
||||
"3" = "A Bevy application";
|
||||
};
|
||||
};
|
||||
flakemaven = {
|
||||
template = builtins.readFile ./maven.flake.nix;
|
||||
placeholders."0" = "25";
|
||||
};
|
||||
flakegradle = {
|
||||
template = builtins.readFile ./gradle.flake.nix;
|
||||
placeholders."0" = "25";
|
||||
};
|
||||
}
|
||||
17
home/editors/nvim/plugins/snippet/nix/flake.nix
Normal file
17
home/editors/nvim/plugins/snippet/nix/flake.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
in {
|
||||
<0>
|
||||
});
|
||||
}
|
||||
46
home/editors/nvim/plugins/snippet/nix/flutter.flake.nix
Normal file
46
home/editors/nvim/plugins/snippet/nix/flutter.flake.nix
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config = {
|
||||
allowUnfree = true;
|
||||
android_sdk.accept_license = true;
|
||||
};
|
||||
};
|
||||
|
||||
buildToolsVersion = "35.0.0";
|
||||
androidComposition = pkgs.androidenv.composeAndroidPackages {
|
||||
buildToolsVersions = [buildToolsVersion "28.0.3"];
|
||||
platformVersions = ["36" "28"];
|
||||
abiVersions = ["armeabi-v7a" "arm64-v8a"];
|
||||
includeNDK = true;
|
||||
ndkVersions = ["27.0.12077973"];
|
||||
cmakeVersions = ["3.22.1"];
|
||||
};
|
||||
androidSdk = androidComposition.androidsdk;
|
||||
jdk = pkgs.jdk17;
|
||||
in {
|
||||
devShells.default = pkgs.mkShell rec {
|
||||
buildImports = with pkgs; [
|
||||
flutter
|
||||
androidSdk
|
||||
jdk
|
||||
];
|
||||
|
||||
ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
|
||||
ANDROID_NDK_ROOT = "${ANDROID_SDK_ROOT}/ndk-bundle";
|
||||
|
||||
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${buildToolsVersion}/aapt2";
|
||||
};
|
||||
});
|
||||
}
|
||||
22
home/editors/nvim/plugins/snippet/nix/gradle.flake.nix
Normal file
22
home/editors/nvim/plugins/snippet/nix/gradle.flake.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
jdk = pkgs.jdk <0>;
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [pkgs.gradle jdk];
|
||||
JAVA_HOME = jdk.home;
|
||||
GRADLE_OPTS = "-Dorg.gradle.java.installations.auto-download=false -Dorg.gradle.java.installations.fromEnv=true";
|
||||
};
|
||||
});
|
||||
}
|
||||
21
home/editors/nvim/plugins/snippet/nix/maven.flake.nix
Normal file
21
home/editors/nvim/plugins/snippet/nix/maven.flake.nix
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
jdk = pkgs.jdk<0>;
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = [pkgs.maven jdk];
|
||||
JAVA_HOME = jdk.home;
|
||||
};
|
||||
});
|
||||
}
|
||||
39
home/editors/nvim/plugins/snippet/nix/npm.flake.nix
Normal file
39
home/editors/nvim/plugins/snippet/nix/npm.flake.nix
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
|
||||
name = "npm-app";
|
||||
version = "0.1.0";
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
nodejs
|
||||
];
|
||||
in {
|
||||
packages.default = pkgs.buildNpmPackage {
|
||||
inherit name version buildInputs;
|
||||
|
||||
npmDeps = pkgs.importNpmLock {
|
||||
npmRoot = ./.;
|
||||
};
|
||||
inherit (pkgs.importNpmLock) npmConfigHook;
|
||||
|
||||
installPhase = ''
|
||||
# ...
|
||||
'';
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = buildInputs;
|
||||
};
|
||||
});
|
||||
}
|
||||
81
home/editors/nvim/plugins/snippet/nix/rust.flake.nix
Normal file
81
home/editors/nvim/plugins/snippet/nix/rust.flake.nix
Normal file
@@ -0,0 +1,81 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
fenix = {
|
||||
url = "github:nix-community/fenix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
crane.url = "github:ipetkov/crane";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
fenix,
|
||||
crane,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
|
||||
pname = "<1>";
|
||||
version = "<2>";
|
||||
|
||||
rust-toolchain = with fenix.packages.${system};
|
||||
combine [
|
||||
stable.rustc
|
||||
stable.cargo
|
||||
stable.rust-src
|
||||
stable.rust-analyzer
|
||||
];
|
||||
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain rust-toolchain;
|
||||
|
||||
cargoArtifacts = craneLib.buildDepsOnly {
|
||||
pname = "${pname}-deps";
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
};
|
||||
in {
|
||||
packages.default = craneLib.buildPackage {
|
||||
inherit pname version;
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
inherit cargoArtifacts;
|
||||
|
||||
nativeBuildInputs = [rust-toolchain pkgs.lld];
|
||||
buildInputs = with pkgs;
|
||||
[
|
||||
<0>
|
||||
]
|
||||
++ lib.optionals stdenv.isDarwin [
|
||||
darwin.apple_sdk.frameworks.Security
|
||||
];
|
||||
|
||||
RUSTFLAGS = "-C link-arg=-fuse-ld=lld";
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "<3>";
|
||||
license = licenses.mit;
|
||||
};
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
lld
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
rust-toolchain
|
||||
cargo-watch
|
||||
cargo-edit
|
||||
cargo-tarpaulin
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export RUST_SRC_PATH=${fenix.packages.${system}.stable.rust-src}/lib/rustlib/src/rust/library
|
||||
'';
|
||||
};
|
||||
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
});
|
||||
}
|
||||
51
home/editors/nvim/plugins/snippet/nix/tauri.flake.nix
Normal file
51
home/editors/nvim/plugins/snippet/nix/tauri.flake.nix
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
overlays = [(import rust-overlay)];
|
||||
pkgs = import nixpkgs {inherit system overlays;};
|
||||
|
||||
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
|
||||
extensions = ["rust-src"];
|
||||
};
|
||||
|
||||
linuxDeps = with pkgs; [
|
||||
webkitgtk_4_1
|
||||
gtk3
|
||||
cairo
|
||||
gdk-pixbuf
|
||||
glib
|
||||
dbus
|
||||
openssl
|
||||
pkg-config
|
||||
librsvg
|
||||
];
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs;
|
||||
[
|
||||
rustToolchain
|
||||
rust-analyzer
|
||||
|
||||
nodejs
|
||||
cargo-tauri
|
||||
]
|
||||
++ linuxDeps;
|
||||
|
||||
shellHook = ''
|
||||
export WEBKIT_DISABLE_COMPOSITING_MODE=1
|
||||
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath linuxDeps}"
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user