Skip to content

Commit

Permalink
feat: Add localPackages to exclude certain packages from flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
akirak committed Nov 25, 2023
1 parent da5b397 commit b53f4f1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkgs/emacs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
if builtins.compareVersions emacsPackage.version "29" > 0
then []
else ["use-package"],
# List of package names that are supposed to be reside in the same repository.
# These packages won't be declared in the generated flake.nix to not produce
# meaningless diffs in flake.lock.
localPackages ? [],
# User-provided list of Emacs built-in libraries as a string list
initialLibraries ? null,
addSystemPackages ? true,
Expand Down Expand Up @@ -43,6 +47,7 @@
isList
isAttrs
elem
removeAttrs
;
in
lib.makeScope pkgs.newScope (self: let
Expand Down Expand Up @@ -125,6 +130,8 @@ in
generateLockFiles = self.callPackage ./lock {
inherit flakeLockFile;
};

excludeLocalPackages = lib.flip (removeAttrs localPackages);
in {
inherit lib;
emacs = emacsPackage;
Expand Down Expand Up @@ -206,7 +213,8 @@ in
# and write lock files to it
generateLockDir =
(generateLockFiles {
packageInputs = enumerateConcretePackageSet "update" explicitPackages;
packageInputs =
excludeLocalPackages (enumerateConcretePackageSet "update" explicitPackages);
flakeNix = true;
archiveLock = true;
})
Expand All @@ -219,7 +227,8 @@ in
lock =
(generateLockFiles
{
packageInputs = enumerateConcretePackageSet "lock" explicitPackages;
packageInputs =
excludeLocalPackages (enumerateConcretePackageSet "lock" explicitPackages);
flakeNix = true;
archiveLock = true;
postCommand = "nix flake lock";
Expand All @@ -231,7 +240,8 @@ in
update =
(generateLockFiles
{
packageInputs = enumerateConcretePackageSet "update" explicitPackages;
packageInputs =
excludeLocalPackages (enumerateConcretePackageSet "update" explicitPackages);
archiveLock = true;
})
.asAppWritingToRelativeDir
Expand Down

0 comments on commit b53f4f1

Please sign in to comment.