dream2nix/modules/flake-parts/apps.update-locks.nix
DavHau 87722db970 feat(paths): init new core module 'paths'
This is to improve package location finding at eval time and script execution time.

Deprecates options lock.{repoRoot,lockFileRel} as well as option eval-cache.{repoRoot, cacheFileRel}

Instead the user must now set:
  - paths.projectRoot: pointing to the repoRoot
  - paths.package: pointing to the package directory

- paths.projectRootFile can be used to define a marker file to find the project root. The default is '.git' but it could be set to 'flake.nix' for example
- lock files are by default put in the same directory as the package definition
2023-09-02 23:34:54 +00:00

54 lines
905 B
Nix

# custom app to update the eval-cache of each exported package.
{
self,
lib,
inputs,
...
}: {
imports = [
./writers.nix
];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: let
l = lib // builtins;
packages = lib.filterAttrs (name: _: lib.hasPrefix "example-package-" name) self'.checks;
scripts =
l.flatten
(l.mapAttrsToList
(name: pkg: pkg.config.lock.refresh or [])
packages);
update-locks =
config.writers.writePureShellScript
(with pkgs; [
coreutils
git
nix
])
(
"set -x\n"
+ (l.concatStringsSep "/bin/refresh\n" scripts)
+ "/bin/refresh"
);
toApp = script: {
type = "app";
program = "${script}";
};
in {
apps = l.mapAttrs (_: toApp) {
inherit
update-locks
;
};
};
}