From c95335ca9286388219597934d56c47508a941b59 Mon Sep 17 00:00:00 2001 From: Akira Komamura Date: Sat, 25 Nov 2023 10:08:48 +0900 Subject: [PATCH] refactor: Prepare for adding an alternative lock API --- pkgs/emacs/default.nix | 23 ++++++++++++----------- pkgs/emacs/lock/default.nix | 15 ++++++++------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pkgs/emacs/default.nix b/pkgs/emacs/default.nix index d241d2a..c23b0b8 100644 --- a/pkgs/emacs/default.nix +++ b/pkgs/emacs/default.nix @@ -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 @@ -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; }; }) diff --git a/pkgs/emacs/lock/default.nix b/pkgs/emacs/lock/default.nix index 81f07ae..fd194ad 100644 --- a/pkgs/emacs/lock/default.nix +++ b/pkgs/emacs/lock/default.nix @@ -14,7 +14,7 @@ flakeLock ? false, archiveLock ? false, postCommand ? null, -}: outDir: +}: assert (flakeNix || flakeLock || archiveLock); let inherit (builtins) toJSON attrNames mapAttrs; @@ -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; + }; +}