Skip to content

Instantly share code, notes, and snippets.

@LnL7

LnL7/nixpkgs.nix Secret

Created January 14, 2019 21:26
Show Gist options
  • Save LnL7/74a29376b93026876f40db99a457a691 to your computer and use it in GitHub Desktop.
Save LnL7/74a29376b93026876f40db99a457a691 to your computer and use it in GitHub Desktop.
{ ... }@args:
let
mapConfig = defaults: attrs: builtins.mapAttrs (getDefault defaults) (builtins.mapAttrs (n: builtins.getEnv) attrs);
getDefault = defaults: n: v: if v != "" then v else defaults."${n}" or "";
traceInputs = message: x: if builtins.getEnv "NIX_TRACE_INPUTS" == "0" then x else builtins.trace message x;
defaults = {
url = "ssh://git@gitlab.example.org/upstream/nixpkgs.git";
ref = "foo";
};
cfg = mapConfig defaults {
url = "FOO_NIXPKGS_URL";
ref = "FOO_NIXPKGS_BRANCH";
rev = "FOO_NIXPKGS_REVISION";
};
nixpkgs = builtins.fetchGit cfg;
in
traceInputs ''
fetched dynamic inputs
Use these variables to reproduce the current build.
FOO_NIXPKGS_URL=${cfg.url}
FOO_NIXPKGS_BRANCH=${cfg.ref}
FOO_NIXPKGS_REVISION=${nixpkgs.rev}
''
import nixpkgs args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment