diff --git a/README.md b/README.md index 8052d4d..f1b2c4e 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ [default.nix](./default.nix) * Remember to mark the broken packages as `broken = true;` in the `meta` attribute, or travis (and consequently caching) will fail! + * Library functions, modules and overlays go in the respective directories 3. Add your NUR repo name and your cachix repo name (optional) to [.travis.yml](./.travis.yml) * If you use cachix you should also add your cache's private key to travis' diff --git a/default.nix b/default.nix index ada0825..46c4090 100644 --- a/default.nix +++ b/default.nix @@ -1,19 +1,21 @@ # This file describes your repository contents. -# It should return a set of nix derivations. -# It should NOT import . Instead, you should take all dependencies as -# arguments. +# It should return a set of nix derivations +# and optionally the special attributes `lib`, `modules` and `overlays`. +# It should NOT import . Instead, you should take pkgs as an argument. +# Having pkgs default to is fine though, and it lets you use short +# commands such as: +# nix-build -A mypackage -{ callPackage -, libsForQt5 -, haskellPackages -, pythonPackages -# , ... -# Add here other callPackage/callApplication/... providers as the need arises -, ... }: +{ pkgs ? import {} }: { - example-package = callPackage ./pkgs/example-package { }; - # some-qt5-package = libsForQt5.callPackage ./pkgs/some-qt5-package { }; + # The `lib`, `modules`, and `overlay` names are special + lib = import ./lib { inherit pkgs; }; # functions + modules = import ./modules; # NixOS modules + overlays = import ./overlays; # nixpkgs overlays + + example-package = pkgs.callPackage ./pkgs/example-package { }; + # some-qt5-package = pkgs.libsForQt5.callPackage ./pkgs/some-qt5-package { }; # ... } diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..53d6abe --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,8 @@ +{ pkgs }: + +with pkgs.lib; { + # Add your library functions here + # + # hexint = x: hexvals.${toLower x}; +} + diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..79e1d17 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,6 @@ +{ + # Add your NixOS modules here + # + # my-module = import ./my-module; +} + diff --git a/non-broken.nix b/non-broken.nix index 18ae8b5..b9a2cf9 100644 --- a/non-broken.nix +++ b/non-broken.nix @@ -2,18 +2,20 @@ # It's what gets built by CI, so if you correctly mark broken packages as # broken your CI will not try to build them and the non-broken packages will # be added to the cache. +{ pkgs ? import {} }: let filterSet = - (f: s: builtins.listToAttrs + (f: g: s: builtins.listToAttrs (map (n: { name = n; value = builtins.getAttr n s; }) (builtins.filter - (n: f (builtins.getAttr n s)) + (n: f n && g (builtins.getAttr n s)) (builtins.attrNames s) ) ) ); in filterSet + (n: !(n=="lib"||n=="overlays"||n=="modules")) # filter out non-packages (p: (builtins.isAttrs p) && !( (builtins.hasAttr "meta" p) @@ -21,5 +23,5 @@ in filterSet && (p.meta.broken) ) ) - (import ./standalone.nix) + (import ./default.nix { inherit pkgs; }) diff --git a/overlay.nix b/overlay.nix index d9f98f8..082b038 100644 --- a/overlay.nix +++ b/overlay.nix @@ -4,12 +4,18 @@ self: super: -import ./default.nix { - callPackage = super.callPackage; - libsForQt5 = super.libsForQt5; - haskellPackages = super.haskellPackages; - pythonPackages = super.pythonPackages; - # ... - # Add here other callPackage/callApplication/... providers as the need arises -} +let filterSet = + (f: g: s: builtins.listToAttrs + (map + (n: { name = n; value = builtins.getAttr n s; }) + (builtins.filter + (n: f n && g (builtins.getAttr n s)) + (builtins.attrNames s) + ) + ) + ); +in filterSet + (n: !(n=="lib"||n=="overlays"||n=="modules")) # filter out non-packages + (p: true) # all packages are ok + (import ./default.nix { pkgs = super; }) diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..642fefa --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,6 @@ +{ + # Add your overlays here + # + # my-overlay = import ./my-overlay; +} + diff --git a/standalone.nix b/standalone.nix deleted file mode 100644 index cadb80a..0000000 --- a/standalone.nix +++ /dev/null @@ -1,9 +0,0 @@ -# You can use this file to build packages without adding the NUR namespace -# or the overlay to your configuration. -# It's also useful for testing and working on the packages. -# -# example: -# nix-build ./standalone.nix -A mypackage - -with import {}; callPackage ./default.nix {} -