mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
flake: formatting (#342)
This commit is contained in:
parent
3ad504ed49
commit
52120a891d
1 changed files with 153 additions and 161 deletions
314
flake.nix
314
flake.nix
|
@ -10,168 +10,162 @@
|
|||
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
|
||||
inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
outputs =
|
||||
{ self
|
||||
, nixpkgs
|
||||
, flake-utils
|
||||
, pre-commit-hooks
|
||||
, ...
|
||||
} @ inputs:
|
||||
with nixpkgs.lib;
|
||||
with builtins; let
|
||||
# TODO: Support nesting
|
||||
nixvimModules = map (f: ./modules + "/${f}") (attrNames (builtins.readDir ./modules));
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
pre-commit-hooks,
|
||||
...
|
||||
} @ inputs:
|
||||
with nixpkgs.lib;
|
||||
with builtins; let
|
||||
# TODO: Support nesting
|
||||
nixvimModules = map (f: ./modules + "/${f}") (attrNames (builtins.readDir ./modules));
|
||||
|
||||
modules = pkgs:
|
||||
nixvimModules
|
||||
++ [
|
||||
rec {
|
||||
_file = ./flake.nix;
|
||||
key = _file;
|
||||
config = {
|
||||
_module.args = {
|
||||
pkgs = mkForce pkgs;
|
||||
inherit (pkgs) lib;
|
||||
helpers = import ./plugins/helpers.nix { inherit (pkgs) lib; };
|
||||
inputs = inputs;
|
||||
modules = pkgs:
|
||||
nixvimModules
|
||||
++ [
|
||||
rec {
|
||||
_file = ./flake.nix;
|
||||
key = _file;
|
||||
config = {
|
||||
_module.args = {
|
||||
pkgs = mkForce pkgs;
|
||||
inherit (pkgs) lib;
|
||||
helpers = import ./plugins/helpers.nix {inherit (pkgs) lib;};
|
||||
inputs = inputs;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# ./plugins/default.nix
|
||||
];
|
||||
|
||||
flakeOutput =
|
||||
flake-utils.lib.eachDefaultSystem
|
||||
(system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
extractRustAnalyzer = {
|
||||
stdenv,
|
||||
pkgs,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "extract_rust_analyzer";
|
||||
version = "master";
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
buildInputs = [pkgs.python3];
|
||||
|
||||
installPhase = ''
|
||||
ls -la
|
||||
mkdir -p $out/bin
|
||||
cp ${./helpers/extract_rust_analyzer.py} $out/bin/extract_rust_analyzer.py
|
||||
'';
|
||||
};
|
||||
extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer {};
|
||||
in {
|
||||
checks =
|
||||
(import ./tests {
|
||||
inherit pkgs;
|
||||
inherit (pkgs) lib;
|
||||
makeNixvim = self.legacyPackages."${system}".makeNixvim;
|
||||
})
|
||||
// {
|
||||
lib-tests = import ./tests/lib-tests.nix {
|
||||
inherit (pkgs) pkgs lib;
|
||||
};
|
||||
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
alejandra = {
|
||||
enable = true;
|
||||
excludes = ["plugins/_sources"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
devShells = {
|
||||
default = pkgs.mkShell {
|
||||
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
||||
};
|
||||
};
|
||||
packages = {
|
||||
docs = pkgs.callPackage (import ./docs.nix) {
|
||||
modules = nixvimModules;
|
||||
};
|
||||
runUpdates =
|
||||
pkgs.callPackage
|
||||
({
|
||||
pkgs,
|
||||
stdenv,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "run-updates";
|
||||
version = pkgs.rust-analyzer.version;
|
||||
|
||||
# ./plugins/default.nix
|
||||
];
|
||||
src = pkgs.rust-analyzer.src;
|
||||
|
||||
flakeOutput =
|
||||
flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
extractRustAnalyzer =
|
||||
{ stdenv
|
||||
, pkgs
|
||||
,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "extract_rust_analyzer";
|
||||
version = "master";
|
||||
nativeBuildInputs = with pkgs; [extractRustAnalyzerPkg alejandra];
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
buildPhase = ''
|
||||
extract_rust_analyzer.py editors/code/package.json |
|
||||
alejandra --quiet > rust-analyzer-config.nix
|
||||
'';
|
||||
|
||||
buildInputs = [ pkgs.python3 ];
|
||||
|
||||
installPhase = ''
|
||||
ls -la
|
||||
mkdir -p $out/bin
|
||||
cp ${./helpers/extract_rust_analyzer.py} $out/bin/extract_rust_analyzer.py
|
||||
'';
|
||||
};
|
||||
extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer { };
|
||||
in
|
||||
{
|
||||
checks =
|
||||
(import ./tests {
|
||||
inherit pkgs;
|
||||
inherit (pkgs) lib;
|
||||
makeNixvim = self.legacyPackages."${system}".makeNixvim;
|
||||
})
|
||||
// {
|
||||
lib-tests = import ./tests/lib-tests.nix {
|
||||
inherit (pkgs) pkgs lib;
|
||||
};
|
||||
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
alejandra = {
|
||||
enable = true;
|
||||
excludes = [ "plugins/_sources" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
devShells = {
|
||||
default = pkgs.mkShell {
|
||||
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/share
|
||||
cp rust-analyzer-config.nix $out/share
|
||||
'';
|
||||
})
|
||||
{};
|
||||
# Used to updates plugins, launch 'nix run .#nvfetcher' in the 'plugins' directory
|
||||
nvfetcher = pkgs.nvfetcher;
|
||||
};
|
||||
legacyPackages = rec {
|
||||
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules;
|
||||
makeNixvim = configuration:
|
||||
makeNixvimWithModule {
|
||||
module = {
|
||||
config = configuration;
|
||||
};
|
||||
packages = {
|
||||
docs = pkgs.callPackage (import ./docs.nix) {
|
||||
modules = nixvimModules;
|
||||
};
|
||||
runUpdates =
|
||||
pkgs.callPackage
|
||||
({ pkgs
|
||||
, stdenv
|
||||
,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "run-updates";
|
||||
version = pkgs.rust-analyzer.version;
|
||||
};
|
||||
};
|
||||
formatter = let
|
||||
# We need to exclude the plugins/_sources/* files as they are autogenerated
|
||||
# nix formatter only takes a derivation so we need to make a proxy that passes
|
||||
# the correct flags
|
||||
excludeWrapper = {
|
||||
stdenv,
|
||||
alejandra,
|
||||
writeShellScript,
|
||||
...
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "alejandra-excludes";
|
||||
version = alejandra.version;
|
||||
|
||||
src = pkgs.rust-analyzer.src;
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
installPhase = let
|
||||
script = writeShellScript "alejandra-excludes.sh" ''
|
||||
${alejandra}/bin/alejandra --exclude ./plugins/_sources "$@"
|
||||
'';
|
||||
in ''
|
||||
mkdir -p $out/bin
|
||||
cp ${script} $out/bin/alejandra-excludes
|
||||
'';
|
||||
};
|
||||
in
|
||||
pkgs.callPackage excludeWrapper {};
|
||||
|
||||
nativeBuildInputs = with pkgs; [ extractRustAnalyzerPkg alejandra ];
|
||||
|
||||
buildPhase = ''
|
||||
extract_rust_analyzer.py editors/code/package.json |
|
||||
alejandra --quiet > rust-analyzer-config.nix
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/share
|
||||
cp rust-analyzer-config.nix $out/share
|
||||
'';
|
||||
})
|
||||
{ };
|
||||
# Used to updates plugins, launch 'nix run .#nvfetcher' in the 'plugins' directory
|
||||
nvfetcher = pkgs.nvfetcher;
|
||||
};
|
||||
legacyPackages = rec {
|
||||
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules;
|
||||
makeNixvim = configuration:
|
||||
makeNixvimWithModule {
|
||||
module = {
|
||||
config = configuration;
|
||||
};
|
||||
};
|
||||
};
|
||||
formatter =
|
||||
let
|
||||
# We need to exclude the plugins/_sources/* files as they are autogenerated
|
||||
# nix formatter only takes a derivation so we need to make a proxy that passes
|
||||
# the correct flags
|
||||
excludeWrapper =
|
||||
{ stdenv
|
||||
, alejandra
|
||||
, writeShellScript
|
||||
, ...
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "alejandra-excludes";
|
||||
version = alejandra.version;
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
installPhase =
|
||||
let
|
||||
script = writeShellScript "alejandra-excludes.sh" ''
|
||||
${alejandra}/bin/alejandra --exclude ./plugins/_sources "$@"
|
||||
'';
|
||||
in
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
cp ${script} $out/bin/alejandra-excludes
|
||||
'';
|
||||
};
|
||||
in
|
||||
pkgs.callPackage excludeWrapper { };
|
||||
|
||||
lib = import ./lib {
|
||||
inherit pkgs;
|
||||
inherit (pkgs) lib;
|
||||
};
|
||||
});
|
||||
in
|
||||
lib = import ./lib {
|
||||
inherit pkgs;
|
||||
inherit (pkgs) lib;
|
||||
};
|
||||
});
|
||||
in
|
||||
flakeOutput
|
||||
// {
|
||||
nixosModules.nixvim = import ./wrappers/nixos.nix modules;
|
||||
|
@ -179,15 +173,13 @@
|
|||
nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules;
|
||||
rawModules.nixvim = nixvimModules;
|
||||
|
||||
templates =
|
||||
let
|
||||
simple = {
|
||||
path = ./templates/simple;
|
||||
description = "A simple nix flake template for getting started with nixvim";
|
||||
};
|
||||
in
|
||||
{
|
||||
default = simple;
|
||||
templates = let
|
||||
simple = {
|
||||
path = ./templates/simple;
|
||||
description = "A simple nix flake template for getting started with nixvim";
|
||||
};
|
||||
in {
|
||||
default = simple;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue