Skip to content

Commit

Permalink
Merge pull request #8 from emacs-twist/lib-function
Browse files Browse the repository at this point in the history
Add a function that returns a list of builtin libraries of a given Emacs version
  • Loading branch information
akirak authored Oct 21, 2023
2 parents a3f9673 + 29b0ee6 commit c2e59cb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check

on:
workflow_dispatch:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v23
with:
extra_nix_config: |
accept-flake-config = true
- name: Smoke-test the library function
run: nix develop -c just check-function
13 changes: 13 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
outputs = {
systems,
nixpkgs,
self,
...
} @ inputs: let
inherit (nixpkgs) lib;
Expand All @@ -33,6 +34,18 @@
in {
data = import ./generated;

lib.builtinLibrariesOfEmacsVersion = targetVersion: let
xs =
builtins.map ({libraries, ...}: libraries)
(
builtins.filter ({version, ...}: version == targetVersion)
(builtins.attrValues self.data)
);
in
if builtins.length xs > 0
then builtins.head xs
else null;

devShells = eachSystem (pkgs: {
default = pkgs.mkShell {buildInputs = [pkgs.just];};
});
Expand Down
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ update:
mkdir -p generated
rm -f generated/*.nix
install -m 644 $(nix build . --print-out-paths)/*.nix generated/

check-function:
nix eval .\#lib.builtinLibrariesOfEmacsVersion --apply 'f: f "29.1"'

0 comments on commit c2e59cb

Please sign in to comment.