4
0
Fork 2
mirror of https://gerrit.hackerspace.pl/hscloud synced 2024-10-18 12:17:46 +00:00
hscloud/default.nix
Serge Bazanski 2efb698d22 *: add default.nix/readTree
This makes all Nix files addressable from root by file path.

For instance, if a file is located in //foo/bar:baz.nix containing:

    { pkgs, ... }:

    pkgs.stdenv.mkDerivation {
      pname = "foo";
      # ...
    }

You can then do:

    nix-build -A foo.bar.baz

All nix files loaded this way must be a function taking a 'config'
attrset - see nix/readTree.nix for more information. Currently the
config attrset contains the following fields:

 - hscloud: the root of the hscloud repository itself, which allows
            for traversal via readTree (eg. hscloud.foo.bar.baz)
 - pkgs: nixpkgs
 - pkgsSrc: nixpkgs souce/channel, useful to load NixOS modules.
 - lib, stdenv: lib and stdenv from pkgs.

Change-Id: Ieaacdcabceec18dd6c670d346928bff08b66cf79
2020-10-03 14:57:34 +00:00

37 lines
807 B
Nix

{ ... }@args:
with builtins;
let
fix = f: let x = f x; in x;
readTree = import ./nix/readtree.nix {};
# Tracking nixos-unstable as of 2020-08-22.
nixpkgsCommit = "c59ea8b8a0e7f927e7291c14ea6cd1bd3a16ff38";
nixpkgsSrc = fetchTarball {
url = "https://github.com/NixOS/nixpkgs-channels/archive/${nixpkgsCommit}.tar.gz";
sha256 = "1ak7jqx94fjhc68xh1lh35kh3w3ndbadprrb762qgvcfb8351x8v";
};
nixpkgs = import nixpkgsSrc {
config.allowUnfree = true;
config.allowBroken = true;
};
in fix (self: rec {
config = {
hscloud = self // {
root = ./.;
};
pkgs = nixpkgs;
pkgsSrc = nixpkgsSrc;
inherit (nixpkgs) lib stdenv;
};
bgpwtf = readTree config ./bgpwtf;
cluster = readTree config ./cluster;
ops = readTree config ./ops;
pkgs = nixpkgs;
})