Skip to content

Instantly share code, notes, and snippets.

@benley
Created February 11, 2019 23:55
Show Gist options
  • Select an option

  • Save benley/a31f0635cca3f5bff4eeccf48c6789a7 to your computer and use it in GitHub Desktop.

Select an option

Save benley/a31f0635cca3f5bff4eeccf48c6789a7 to your computer and use it in GitHub Desktop.

Revisions

  1. benley created this gist Feb 11, 2019.
    1 change: 1 addition & 0 deletions .nixpkgs.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    { "url": "https://github.com/nixos/nixpkgs/archive/804c227b83faa017c377eb899d18e5931e0ad936.tar.gz" }
    39 changes: 39 additions & 0 deletions default.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    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)
    9 changes: 9 additions & 0 deletions pkgs_overlay.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    self: super:
    rec {
    inherit (super) fetchFromGitHub callPackage;

    python = super.python.override {
    packageOverrides = callPackage ./python-packages.nix {};
    };

    }
    5 changes: 5 additions & 0 deletions python-packages.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    { fetchFromGitHub }: self: super:

    {
    herp_derp_python_example = self.callPackage ./src/herp_derp_python_example {};
    }
    12 changes: 12 additions & 0 deletions update-nixpkgs.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/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