Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
New option to fail build on unknown package
Browse files Browse the repository at this point in the history
  • Loading branch information
László Vaskó committed Nov 22, 2019
1 parent d6c09f9 commit a449ef5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
, emacsArgs ? []
# Additional files you wish to load prior to executing package discovery
# Good place to place to call `advice-add` from
, emacsLoadFiles ? [] }:
, emacsLoadFiles ? []
# Abort processing if a package not found in `emacsPackages`
# Setting it to false will result in just skipping an unavailable package
, abortOnNotFound ? false }:

let
libstraight = epkgs.callPackage ./libstraight.nix { inherit epkgs; };
libstraight = epkgs.callPackage ./libstraight.nix { inherit abortOnNotFound epkgs; };
epkgs =
if straight == null then
emacsPackages.overrideScope' (self: super:
Expand Down
8 changes: 5 additions & 3 deletions libstraight.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{ lib, stdenv, epkgs, writeScript }:
{ abortOnNotFound ? true,
lib, stdenv, epkgs, writeScript }:

let
inherit (builtins) filter trace;
inherit (lib) concatMapStringsSep escapeShellArgs importJSON flatten unique optionalString;
inherit (lib) concatMapStringsSep escapeShellArgs importJSON flatten unique optionalString warn;

expandDependencies = packages:
let
Expand Down Expand Up @@ -39,7 +40,8 @@ let
list = importJSON json;
in map (x:
if epkgs ? "${x}" then epkgs.${x}
else (trace "XXX no attribute found for use-package ${x}") null) list;
else if abortOnNotFound then abort "Package not available: ${x}"
else (warn "Package not available: ${x}") null) list;

packagesJSON = { emacsInitFile, emacsLoadFiles, emacsArgs }: stdenv.mkDerivation {
name = "emacs-straight-packages.json";
Expand Down
6 changes: 5 additions & 1 deletion setup.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
(let ((pkg (if (listp recipe)
(car recipe)
recipe)))
(message "straight-use-package %s %s; pkg=%s" recipe r pkg)
(message "straight-use-package %s %s" recipe r)
(add-to-list 'nix-straight--packages pkg))))
(advice-add 'straight-recipes-retrieve
:override (lambda (pkg)
(list)))
(advice-add 'straight-use-recipes
:override (lambda (&rest r)
(message "straight-use-recipes %s" r)
))

(load init-file nil nil t)
(princ (if (null nix-straight--packages)
Expand Down

0 comments on commit a449ef5

Please sign in to comment.