From 627fd92debd4ee6997255a322180e79a4e2394b5 Mon Sep 17 00:00:00 2001 From: David Baynard Date: Sun, 31 Mar 2024 17:46:07 +0100 Subject: [PATCH] nix: Make default.nix extensible Moving values defined with `let` to the function arguments (with defaults) means other consumers of `default.nix` can customize these values. One example is a `flake.nix`, which can then supply the `nixpkgs` input. --- default.nix | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/default.nix b/default.nix index c94f2e93be..a55011e2aa 100644 --- a/default.nix +++ b/default.nix @@ -1,12 +1,23 @@ -{ system ? builtins.currentSystem }: +{ system ? builtins.currentSystem + +, compiler ? "ghc948" + +, # Commit of the Nixpkgs repository that we want to use. + nixpkgsVersion ? import nix/nixpkgs-version.nix + +, # Nix files that describe the Nixpkgs repository. We evaluate the expression + # using `import` below. + nixpkgs ? let inherit (nixpkgsVersion) owner repo rev tarballHash; in + builtins.fetchTarball { + url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; + sha256 = tarballHash; + } +}: let name = "postgrest"; - compiler = - "ghc948"; - # PostgREST source files, filtered based on the rules in the .gitignore files # and file extensions. We want to include as litte as possible, as the files # added here will increase the space used in the Nix store and trigger the @@ -16,18 +27,6 @@ let (pkgs.gitignoreSource ./.) [ ".cabal" ".hs" ".lhs" "LICENSE" ]; - # Commit of the Nixpkgs repository that we want to use. - nixpkgsVersion = - import nix/nixpkgs-version.nix; - - # Nix files that describe the Nixpkgs repository. We evaluate the expression - # using `import` below. - nixpkgs = with nixpkgsVersion; - builtins.fetchTarball { - url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; - sha256 = tarballHash; - }; - allOverlays = import nix/overlays;