Skip to content

Instantly share code, notes, and snippets.

@phaer
Last active April 12, 2023 11:54
Show Gist options
  • Save phaer/144940a70b4a0a60e96269007a2e4202 to your computer and use it in GitHub Desktop.
Save phaer/144940a70b4a0a60e96269007a2e4202 to your computer and use it in GitHub Desktop.
dream2nix v1 api without flakes
$(nix-build -A packages.odoo.config.lock.refresh --no-out-link)/bin/refresh
nix-build -A packages.odoo
{pkgs ? import <nixpkgs> {}}: let
dream2nix = import ../..;
drv-parts = dream2nix.inputs.drv-parts;
system = builtins.currentSystem;
# A module imported into every package setting up the eval cache
setup = {config, ...}: {
lock.lockFileRel = "/v1/nix/modules/drvs/${config.name}/lock-${system}.json";
lock.repoRoot = dream2nix;
eval-cache.cacheFileRel = "/v1/nix/modules/drvs/${config.name}/cache-${system}.json";
eval-cache.repoRoot = dream2nix;
eval-cache.enable = true;
};
# evalautes the package behind a given module
makeDrv = module: let
evaled = dream2nix.lib.evalModules {
modules = [
drv-parts.modules.drv-parts.core
drv-parts.modules.drv-parts.docs
module
dream2nix.modules.drv-parts.eval-cache
dream2nix.modules.drv-parts.lock
setup
];
packageSets = {
nixpkgs = pkgs;
};
specialArgs.drv-parts = drv-parts;
specialArgs.dream2nix = dream2nix;
};
in
evaled.config.public;
packages = builtins.mapAttrs (_: drvModule: makeDrv drvModule) dream2nix.modules.drvs;
in {
inherit packages;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment