From a0eea48abba77915ee8127e3fe22eaa9e7f7dc16 Mon Sep 17 00:00:00 2001 From: Assil Ksiksi Date: Tue, 7 Nov 2023 09:41:56 -0500 Subject: [PATCH] use runCommandLocal --- flake.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 51b512d..3d87268 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,8 @@ # References: # https://blog.lenny.ninja/part-1-quickly-packaging-services-using-nix-flakes.html # https://ayats.org/blog/no-flake-utils/ -# https://ryantm.github.io/nixpkgs/builders/trivial-builders/#trivial-builder-runCommand -# https://nixpkgs-manual-sphinx-markedown-example.netlify.app/development/writing-modules.xml.html#structure-of-nixos-modules +# https://nixos.org/manual/nixos/stable/#sec-writing-modules +# https://nixos.org/manual/nixpkgs/stable/#ssec-language-go { description = "minimal configuration for compose2nix"; @@ -44,6 +44,7 @@ # https://nixos.org/manual/nixos/stable/#sec-option-declarations paths = mkOption { type = types.listOf types.path; + default = []; description = lib.mdDoc "One or more paths to Docker Compose files."; }; runtime = mkOption { @@ -87,11 +88,15 @@ description = lib.mdDoc "Auto-start all containers."; }; }; - configs = mkIf (cfg.paths != []) { + config = mkIf (cfg.paths != []) { compose2nix = { - output = pkgs.runCommand "run-compose2nix" { - buildInputs = [ pkgs.compose2nix ]; + # runCommandLocal ensures that we always build this derivation on the local machine. + # This allows us to circumvent the Nix binary cache and minimize the time spent outside + # of building the derivation. + # https://nixos.org/manual/nixpkgs/stable/#trivial-builder-runCommandLocal + output = pkgs.runCommandLocal "run-compose2nix" { env = cfg.env; + buildInputs = [ pkgs.compose2nix ]; } '' ${pkgs.compose2nix}/bin/compose2nix \ -paths='${concatStringsSep "," cfg.paths}' \