Skip to content

Commit

Permalink
refactor: Prepare for adding an alternative lock API
Browse files Browse the repository at this point in the history
  • Loading branch information
akirak committed Nov 25, 2023
1 parent 9c3c6ba commit c95335c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
23 changes: 12 additions & 11 deletions pkgs/emacs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,14 @@ in
# have to run `nix flake lock`` in the target directory to update
# flake.lock.
lock =
generateLockFiles
{
packageInputs = enumerateConcretePackageSet "lock" explicitPackages;
flakeNix = true;
archiveLock = true;
postCommand = "nix flake lock";
}
(generateLockFiles
{
packageInputs = enumerateConcretePackageSet "lock" explicitPackages;
flakeNix = true;
archiveLock = true;
postCommand = "nix flake lock";
})
.asAppWritingToRelativeDir
lockDirName;

# Generate flake.lock with the current revisions
Expand All @@ -223,12 +224,12 @@ in
# };

# Generate archive.lock with latest packages from ELPA package archives
update =
generateLockFiles
update = (generateLockFiles
{
packageInputs = enumerateConcretePackageSet "update" explicitPackages;
archiveLock = true;
}
lockDirName;
})
.asAppWritingToRelativeDir
lockDirName;
};
})
15 changes: 8 additions & 7 deletions pkgs/emacs/lock/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
flakeLock ? false,
archiveLock ? false,
postCommand ? null,
}: outDir:
}:
assert (flakeNix || flakeLock || archiveLock); let
inherit (builtins) toJSON attrNames mapAttrs;

Expand Down Expand Up @@ -108,10 +108,11 @@ assert (flakeNix || flakeLock || archiveLock); let
${postCommand}
''}
'';
in
# This is an app, and not a derivation. See
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-run.html#apps
{
in {
asAppWritingToRelativeDir = outDir: {
# This is an app, and not a derivation. See
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-run.html#apps
type = "app";
program = writeToDir.outPath;
}
program = (writeToDir outDir).outPath;
};
}

0 comments on commit c95335c

Please sign in to comment.