refactor: Introduce new layout with nixpkgs in third_party

This is not the final layout yet, but makes it so that my top-level
attribute set is no longer overlaid into nixpkgs itself.

This is useful for other people who are importing my monorepo.
This commit is contained in:
Vincent Ambo 2019-12-09 02:40:48 +00:00
parent 688233acac
commit 01bad09eed
10 changed files with 61 additions and 49 deletions

View file

@ -1,5 +1,6 @@
# This file sets up the top-level package set by merging all local packages into # This file sets up the top-level package set by traversing the package tree
# the nixpkgs top-level. # (see read-tree.nix for details) and constructing a matching attribute set
# tree.
# #
# This makes packages accessible via the Nixery instance that is configured to # This makes packages accessible via the Nixery instance that is configured to
# use this repository as its nixpkgs source. # use this repository as its nixpkgs source.
@ -7,14 +8,9 @@
with builtins; with builtins;
let let
# The pinned commit here is identical to the public nixery.dev # This definition of fix is identical to <nixpkgs>.lib.fix, but the global
# version, since popularity data has been generated for that. # package set is not available here.
stableCommit = "80b42e630b23052d9525840a9742100a2ceaaa8f"; fix = f: let x = f x; in x;
stableSrc = fetchTarball {
url = "https://github.com/NixOS/nixpkgs-channels/archive/${stableCommit}.tar.gz";
sha256 = "0243qiivxl3z51biy4f5y5cy81x5bki5dazl9wqwgnmd373gpmxy";
};
readTree = import ./read-tree.nix;
# Derivations that have `meta.enableCI` set to `true` should be # Derivations that have `meta.enableCI` set to `true` should be
# built by the CI system on every commit. This code implements # built by the CI system on every commit. This code implements
@ -25,33 +21,43 @@ let
ciCondition = _: x: (!isDerivation x) || ((x ? meta.enableCI) && (x.meta.enableCI)); ciCondition = _: x: (!isDerivation x) || ((x ? meta.enableCI) && (x.meta.enableCI));
in collect isDerivation (filterAttrsRecursive ciCondition pkgs); in collect isDerivation (filterAttrsRecursive ciCondition pkgs);
repoPkgs = self: super: # Global configuration that all packages are called with.
let config = { config = pkgs: {
pkgs = self; inherit pkgs;
upstream = super;
kms = { kms = {
project = "tazjins-infrastructure"; project = "tazjins-infrastructure";
region = "europe-north1"; region = "europe-north1";
keyring = "tazjins-keys"; keyring = "tazjins-keys";
key = "kontemplate-key"; key = "kontemplate-key";
};
}; };
in { };
services = readTree ./services config;
tools = readTree ./tools config; readTree' = import ./read-tree.nix;
third_party = readTree ./third_party config;
} localPkgs = readTree: {
# Load overrides into the top-level: services = readTree ./services;
// (readTree ./overrides config) tools = readTree ./tools;
# Collect all projects that should be built by CI third_party = readTree ./third_party;
// { };
ciProjects = (filterCI super.lib self.services) in fix(self: {
++ (filterCI super.lib self.tools) config = config self;
++ (filterCI super.lib self.third_party);
}; # Elevate 'lib' from nixpkgs
in { ... } @ args: import stableSrc (args // { lib = self.third_party.nixpkgs.lib;
overlays = [ repoPkgs ];
config.allowUnfree = true; # Collect all projects that should be built by CI
config.allowBroken = true; ciProjects = (filterCI self.lib self.services)
}) ++ (filterCI super.lib self.tools)
++ (filterCI super.lib self.third_party);
}
# Add local packages as structured by readTree
// (localPkgs (readTree' self.config))
# Load overrides into the top-level.
#
# This can be used to move things from third_party into the top-level, too (such
# as `lib`).
// (readTree' self.config) ./overrides
)

View file

@ -1,4 +1,6 @@
import "${builtins.fetchGit { { pkgs, ... }:
(import "${builtins.fetchGit {
url = "https://github.com/tazjin/buildGo.nix"; url = "https://github.com/tazjin/buildGo.nix";
rev = "28e587b348a8aaa7af00a004c05286af9d35ca9a"; rev = "28e587b348a8aaa7af00a004c05286af9d35ca9a";
}}/buildGo.nix" }}/buildGo.nix") { pkgs = pkgs.third_party.nixpkgs; }

View file

@ -1,8 +1,8 @@
# One of Gemma's dependencies is missing in nixpkgs' Quicklisp # One of Gemma's dependencies is missing in nixpkgs' Quicklisp
# package set, it is overlaid locally here. # package set, it is overlaid locally here.
{ pkgs, upstream, ... }: { pkgs, ... }:
import ./quicklisp.nix { import ./quicklisp.nix {
inherit (pkgs) lib; inherit (pkgs) lib;
inherit (upstream) lispPackages; inherit (pkgs.third_party.nixpkgs) lispPackages;
} }

View file

@ -1,4 +1,7 @@
initPath: { pkgs, ... } @ args: # TODO(tazjin): if there's a default.nix, keep traversing but don't import .nix files?
# TODO(tazjin): avoid {} by only calling functions *after* checking what they are
args: initPath:
let let
inherit (builtins) inherit (builtins)

View file

@ -1,7 +1,8 @@
{ pkgs, ... }: { pkgs, ... }:
let let
inherit (pkgs) stdenv sbcl lispPackages elmPackages makeWrapper openssl; inherit (pkgs) lispPackages;
inherit (pkgs.third_party.nixpkgs) stdenv sbcl elmPackages makeWrapper openssl;
frontend = stdenv.mkDerivation { frontend = stdenv.mkDerivation {
name = "gemma-frontend"; name = "gemma-frontend";

View file

@ -5,7 +5,7 @@
{ pkgs, ... }: { pkgs, ... }:
let let
inherit (pkgs) writeShellScriptBin haskell; inherit (pkgs.third_party.nixpkgs) writeShellScriptBin haskell;
tazblog = haskell.packages.ghc865.callPackage ./tazblog.nix {}; tazblog = haskell.packages.ghc865.callPackage ./tazblog.nix {};
wrapper = writeShellScriptBin "tazblog" '' wrapper = writeShellScriptBin "tazblog" ''
export PORT=8000 export PORT=8000

View file

@ -1,4 +1,4 @@
{ pkgs ? import ../../default.nix {} }: { pkgs ? (import ../../default.nix {}).third_party.nixpkgs }:
let tazblog = import ./tazblog.nix; let tazblog = import ./tazblog.nix;
depNames = with builtins; filter ( depNames = with builtins; filter (

View file

@ -1,6 +1,6 @@
{ pkgs, ... }: { pkgs, ... }:
let inherit (pkgs) callPackage fetchFromGitHub; let inherit (pkgs.third_party.nixpkgs) callPackage fetchFromGitHub;
in callPackage (fetchFromGitHub { in callPackage (fetchFromGitHub {
owner = "nmattia"; owner = "nmattia";
repo = "naersk"; repo = "naersk";

View file

@ -1,6 +1,6 @@
{ pkgs, ... }: { pkgs, ... }:
pkgs.buildGoPackage { pkgs.third_party.nixpkgs.buildGoPackage {
name = "blog_cli"; name = "blog_cli";
goPackagePath = "github.com/tazjin/personal/blog_cli"; goPackagePath = "github.com/tazjin/personal/blog_cli";
src = ./.; src = ./.;

View file

@ -8,7 +8,7 @@
{ pkgs, kms, ... }: { pkgs, kms, ... }:
let inherit (pkgs) google-cloud-sdk tree writeShellScriptBin; let inherit (pkgs.third_party.nixpkgs) google-cloud-sdk tree writeShellScriptBin;
in (writeShellScriptBin "pass" '' in (writeShellScriptBin "pass" ''
set -eo pipefail set -eo pipefail