Skip to content

Commit

Permalink
Add missing plugins section
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella committed Nov 21, 2023
1 parent 28d8234 commit e543177
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,21 @@ functions:
For more information on how to structure a plugin, see the [Python
plugin](plugins/python).

TODO: Workaround for missing plugins
### Missing Plugins

This section describes some workarounds for scenarios in which an asdf2nix
plugin for a specific tool is still unavailable. Here are some possible
workarounds:

- **Pull an existing package from nixpkgs** - This method makes use of the Nix
binary cache by retrieving a pre-built package from it; however, the package
version may be slightly out-of-date. Take a look at the following
[example](templates/nodejs-from-nixpkgs).
- **Override the version of an existing package** - This approach provides more
flexibility because it allows users to select the version of a package that
they want at the expense of more computational power if the package is not
available in a binary cache because it would be built from scratch. Take a
look at the following [example](templates/nodejs-override-version).

## License

Expand Down
1 change: 1 addition & 0 deletions templates/nodejs-from-nixpkgs/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.5.1
29 changes: 29 additions & 0 deletions templates/nodejs-from-nixpkgs/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{

inputs = {
asdf2nix.url = "github:sestrella/asdf2nix";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
};

outputs = { self, asdf2nix, flake-utils, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
packages = asdf2nix.lib.packagesFromVersionsFile {
inherit system;
versionsFile = ./.tool-versions;
plugins = {
nodejs = {
hasVersion = { version, ... }: pkgs.nodejs_20.version == version;
packageFromVersion = _: pkgs.nodejs_20;
};
};
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = [ packages.nodejs ];
};
});
}
1 change: 1 addition & 0 deletions templates/nodejs-override-version/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.9.0
36 changes: 36 additions & 0 deletions templates/nodejs-override-version/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{

inputs = {
asdf2nix.url = "github:sestrella/asdf2nix";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
};

outputs = { self, asdf2nix, flake-utils, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
packages = asdf2nix.lib.packagesFromVersionsFile {
inherit system;
versionsFile = ./.tool-versions;
plugins = {
nodejs = {
hasVersion = { version, ... }: version == "20.9.0";
packageFromVersion = { version, ... }:
pkgs.nodejs_20.overrideAttrs (_: {
inherit version;
src = builtins.fetchurl {
url = "https://nodejs.org/dist/v${version}/node-v${version}.tar.xz";
sha256 = "sha256:06a578f4h3sirjwp21dwnyak1wqhag74g79ldd15a15z1a0rcgd2";
};
});
};
};
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = [ packages.nodejs ];
};
});
}

0 comments on commit e543177

Please sign in to comment.