Skip to content

Commit

Permalink
flake: Move helper derivations in a separate directory (nix-community…
Browse files Browse the repository at this point in the history
  • Loading branch information
traxys authored Aug 24, 2023
1 parent fd88522 commit 09cefd2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 48 deletions.
55 changes: 7 additions & 48 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,6 @@
inherit system;
config.allowUnfree = true;
};
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 {
Expand Down Expand Up @@ -116,34 +96,13 @@
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
};
packages = {
docs = pkgs-unfree.callPackage (import ./docs) {
modules = nixvimModules;
};
runUpdates =
pkgs.callPackage
({
pkgs,
stdenv,
}:
stdenv.mkDerivation {
pname = "run-updates";
inherit (pkgs.rust-analyzer) version src;

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
'';
})
{};
};
packages =
{
docs = pkgs-unfree.callPackage (import ./docs) {
modules = nixvimModules;
};
}
// (import ./helpers pkgs);
legacyPackages = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules;
makeNixvim = configuration:
Expand Down
16 changes: 16 additions & 0 deletions helpers/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pkgs: rec {
rust-analyzer-config = pkgs.callPackage ./rust-analyzer {};
autogenerated-configs = pkgs.callPackage ({stdenv}:
stdenv.mkDerivation {
pname = "autogenerated-configs";
version = "master";

dontUnpack = true;
dontBuild = true;

installPhase = ''
mkdir -p $out
cp ${rust-analyzer-config}/share/* $out
'';
}) {};
}
39 changes: 39 additions & 0 deletions helpers/rust-analyzer/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
stdenv,
python3,
rust-analyzer,
alejandra,
}: let
extract = stdenv.mkDerivation {
pname = "extract_rust_analyzer";
version = "1";

src = ./extract.py;

dontUnpack = true;
dontBuild = true;

buildInputs = [python3];

installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/extract_rust_analyzer.py
'';
};
in
stdenv.mkDerivation {
pname = "rust-analyzer-config";
inherit (rust-analyzer) version src;

nativeBuildInputs = [alejandra extract];

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
'';
}
File renamed without changes.

0 comments on commit 09cefd2

Please sign in to comment.