Skip to content

Instantly share code, notes, and snippets.

@benley
Created February 11, 2019 23:55
Show Gist options
  • Save benley/a31f0635cca3f5bff4eeccf48c6789a7 to your computer and use it in GitHub Desktop.
Save benley/a31f0635cca3f5bff4eeccf48c6789a7 to your computer and use it in GitHub Desktop.
nix monorepo example layout
{ "url": "https://github.com/nixos/nixpkgs/archive/804c227b83faa017c377eb899d18e5931e0ad936.tar.gz" }
with rec {
versionFile = ./.version;
repoVersion = if builtins.pathExists versionFile
then builtins.readFile versionFile
else "dev";
nixpkgsSrc = fetchTarball (builtins.fromJSON (builtins.readFile ./.nixpkgs.json));
pkgs = import nixpkgsSrc {
config = {};
overlays = [(import ./pkgs_overlay.nix)];
};
};
{ docker_tag ? pkgs.lib.removeSuffix "\n" repoVersion }:
let myPkgs = self:
rec {
inherit (self) lib callPackage;
recurseInto = target: overrides: self.recurseIntoAttrs (lib.callPackagesWith self target overrides);
inherit docker_tag;
local_app_1 = recurseInto ./src/local_app_1 {};
local_app_2 = recurseInto ./src/local_app_2 {};
local_app_3 = recurseInto ./src/local_app_3 {};
};
in
# This calls myPkgs with a combined packageset of itself, our overlay, and
# nixpkgs. Then the part that gets exposed to the "outside" is just the things
# defined in myPkgs. Believe it or not, this does not result in infinite
# recursion.
myPkgs (pkgs // myPkgs pkgs)
self: super:
rec {
inherit (super) fetchFromGitHub callPackage;
python = super.python.override {
packageOverrides = callPackage ./python-packages.nix {};
};
}
{ fetchFromGitHub }: self: super:
{
herp_derp_python_example = self.callPackage ./src/herp_derp_python_example {};
}
#!/bin/sh
set -xe
rev=$(curl -L https://nixos.org/channels/nixpkgs-unstable/git-revision)
url="https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz"
cat > .nixpkgs.json <<EOF
{ "url": "$url" }
EOF
echo "Updated .nixpkgs.json" >&2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment