diff --git a/default.nix b/default.nix index 58faa2d..1ca66ce 100644 --- a/default.nix +++ b/default.nix @@ -1,5 +1,7 @@ { # Package set to build the Emacs environment from emacsPackages + # Emacs package to use during build +, emacs ? emacsPackages.emacs # You may override to use your version of `straight` , straight ? null # Your `init.el` file to use for discovering and installing packages @@ -8,10 +10,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 emacs; }; epkgs = if straight == null then emacsPackages.overrideScope' (self: super: diff --git a/libstraight.nix b/libstraight.nix index d65e0a3..eb48124 100644 --- a/libstraight.nix +++ b/libstraight.nix @@ -1,8 +1,9 @@ -{ lib, stdenv, epkgs, writeScript }: +{ abortOnNotFound ? true, + lib, stdenv, epkgs, emacs, 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 @@ -23,7 +24,7 @@ let else ln -snf $psrc $REPO/${pkg.ename} fi - ${optionalString (pkg.src.meta ? homepage) '' + ${optionalString ((pkg.src ? meta) && (pkg.src.meta ? homepage)) '' if [[ ! -d $REPO/${baseNameOf pkg.src.meta.homepage} ]]; then ln -snf $psrc $REPO/${baseNameOf pkg.src.meta.homepage} fi @@ -39,11 +40,12 @@ 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"; - buildInputs = [ epkgs.emacs ]; + buildInputs = [ emacs ]; buildPhase = ":"; installPhase = '' runHook preInstall @@ -61,7 +63,7 @@ let emacsEnv = { emacsInitFile, emacsLoadFiles, emacsArgs }: { packages, straightDir }: stdenv.mkDerivation { name = "straight-emacs-env"; buildPhase = ":"; - buildInputs = [ epkgs.emacs ]; + buildInputs = [ emacs ]; installPhase = '' runHook preInstall diff --git a/setup.el b/setup.el index 3b2ff6c..e34c05b 100644 --- a/setup.el +++ b/setup.el @@ -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)