New option to fail build on unknown package

This commit is contained in:
László Vaskó
2019-11-21 08:55:05 +01:00
parent d6c09f9415
commit a449ef5f9a
3 changed files with 15 additions and 6 deletions

View File

@ -8,10 +8,13 @@
, emacsArgs ? [] , emacsArgs ? []
# Additional files you wish to load prior to executing package discovery # Additional files you wish to load prior to executing package discovery
# Good place to place to call `advice-add` from # 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 let
libstraight = epkgs.callPackage ./libstraight.nix { inherit epkgs; }; libstraight = epkgs.callPackage ./libstraight.nix { inherit abortOnNotFound epkgs; };
epkgs = epkgs =
if straight == null then if straight == null then
emacsPackages.overrideScope' (self: super: emacsPackages.overrideScope' (self: super:

View File

@ -1,8 +1,9 @@
{ lib, stdenv, epkgs, writeScript }: { abortOnNotFound ? true,
lib, stdenv, epkgs, writeScript }:
let let
inherit (builtins) filter trace; inherit (builtins) filter trace;
inherit (lib) concatMapStringsSep escapeShellArgs importJSON flatten unique optionalString; inherit (lib) concatMapStringsSep escapeShellArgs importJSON flatten unique optionalString warn;
expandDependencies = packages: expandDependencies = packages:
let let
@ -39,7 +40,8 @@ let
list = importJSON json; list = importJSON json;
in map (x: in map (x:
if epkgs ? "${x}" then epkgs.${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 { packagesJSON = { emacsInitFile, emacsLoadFiles, emacsArgs }: stdenv.mkDerivation {
name = "emacs-straight-packages.json"; name = "emacs-straight-packages.json";

View File

@ -9,11 +9,15 @@
(let ((pkg (if (listp recipe) (let ((pkg (if (listp recipe)
(car recipe) (car recipe)
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)))) (add-to-list 'nix-straight--packages pkg))))
(advice-add 'straight-recipes-retrieve (advice-add 'straight-recipes-retrieve
:override (lambda (pkg) :override (lambda (pkg)
(list))) (list)))
(advice-add 'straight-use-recipes
:override (lambda (&rest r)
(message "straight-use-recipes %s" r)
))
(load init-file nil nil t) (load init-file nil nil t)
(princ (if (null nix-straight--packages) (princ (if (null nix-straight--packages)