Skip to content

Commit

Permalink
nix: Make default.nix extensible
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dbaynard committed Apr 20, 2024
1 parent 80f83f0 commit 53c9df3
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
{ 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 ? builtins.fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${nixpkgsVersion.rev}.tar.gz";
sha256 = nixpkgsVersion.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
Expand All @@ -16,18 +26,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;

Expand Down

0 comments on commit 53c9df3

Please sign in to comment.