nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

commit 3c6dd72a4ac1dd66f06ed2b1f2dc2125f0753f96
parent af46d8db4c04b9c7046af0fae1dfb13adb68fb01
Author: Nikolay Korotkiy <sikmir@gmail.com>
Date:   Tue, 24 Dec 2019 00:41:24 +0300

Add stubs and .travis.yml

Diffstat:
A.travis.yml | 34++++++++++++++++++++++++++++++++++
Aci.nix | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdefault.nix | 13+++++++++++++
Alib/default.nix | 8++++++++
Amodules/default.nix | 6++++++
Aoverlay.nix | 15+++++++++++++++
Aoverlays/default.nix | 6++++++
7 files changed, 138 insertions(+), 0 deletions(-)

diff --git a/.travis.yml b/.travis.yml @@ -0,0 +1,34 @@ +language: nix + +sudo: false + +env: + global: + - CACHIX_CACHE= + - NUR_REPO=sikmir + +matrix: + include: + - env: NIX_CHANNEL=https://nixos.org/channels/nixpkgs-unstable + - env: NIX_CHANNEL=https://nixos.org/channels/nixos-unstable + - env: NIX_CHANNEL=https://nixos.org/channels/nixos-19.09 + +install: + - nix --version + - if [ -n "${CACHIX_CACHE}" ]; then travis_retry nix-channel --update; fi + - if [ -n "${CACHIX_CACHE}" ]; then nix-env -iA cachix -f https://cachix.org/api/v1/install; fi + - if [ -n "${CACHIX_CACHE}" ]; then cachix use "${CACHIX_CACHE}"; fi + - nix-channel --add "${NIX_CHANNEL}" nixpkgs + - travis_retry nix-channel --update + +script: + - nix-build ci.nix -A buildOutputs + - nix eval -f default.nix 'lib' + - nix eval -f default.nix 'modules' + - nix eval -f default.nix 'overlays' + +after_success: + - if [ -n "${CACHIX_CACHE}" ]; then nix-build ci.nix -A cacheOutputs | cachix push "${CACHIX_CACHE}"; fi + - if [ "false" = "${TRAVIS_PULL_REQUEST}" -a "master" = "${TRAVIS_BRANCH}" ]; then + curl -XPOST "https://nur-update.herokuapp.com/update?repo=${NUR_REPO}"; fi + diff --git a/ci.nix b/ci.nix @@ -0,0 +1,56 @@ +# This file provides all the buildable and cacheable packages and +# package outputs in you package set. These are what gets built by CI, +# so if you correctly mark packages as +# +# - broken (using `meta.broken`), +# - unfree (using `meta.license.free`), and +# - locally built (using `preferLocalBuild`) +# +# then your CI will be able to build and cache only those packages for +# which this is possible. + +{ pkgs ? import <nixpkgs> {} }: + +with builtins; + +let + + isReserved = n: n == "lib" || n == "overlays" || n == "modules"; + isDerivation = p: isAttrs p && p ? type && p.type == "derivation"; + isBuildable = p: !(p.meta.broken or false) && p.meta.license.free or true; + isCacheable = p: !(p.preferLocalBuild or false); + shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false; + + nameValuePair = n: v: { name = n; value = v; }; + + concatMap = builtins.concatMap or (f: xs: concatLists (map f xs)); + + flattenPkgs = s: + let + f = p: + if shouldRecurseForDerivations p then flattenPkgs p + else if isDerivation p then [p] + else []; + in + concatMap f (attrValues s); + + outputsOf = p: map (o: p.${o}) p.outputs; + + nurAttrs = import ./default.nix { inherit pkgs; }; + + nurPkgs = + flattenPkgs + (listToAttrs + (map (n: nameValuePair n nurAttrs.${n}) + (filter (n: !isReserved n) + (attrNames nurAttrs)))); + +in + +rec { + buildPkgs = filter isBuildable nurPkgs; + cachePkgs = filter isCacheable buildPkgs; + + buildOutputs = concatMap outputsOf buildPkgs; + cacheOutputs = concatMap outputsOf cachePkgs; +} diff --git a/default.nix b/default.nix @@ -1,9 +1,22 @@ +# This file describes your repository contents. +# It should return a set of nix derivations +# and optionally the special attributes `lib`, `modules` and `overlays`. +# It should NOT import <nixpkgs>. Instead, you should take pkgs as an argument. +# Having pkgs default to <nixpkgs> is fine though, and it lets you use short +# commands such as: +# nix-build -A mypackage + { pkgs ? import <nixpkgs> { } }: with pkgs; let sources = import ./nix/sources.nix; in { + # The `lib`, `modules`, and `overlay` names are special + lib = import ./lib { inherit pkgs; }; # functions + modules = import ./modules; # NixOS modules + overlays = import ./overlays; # nixpkgs overlays + csvquote = callPackage ./pkgs/csvquote { inherit (sources) csvquote; }; diff --git a/lib/default.nix 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 @@ -0,0 +1,6 @@ +{ + # Add your NixOS modules here + # + # my-module = ./my-module; +} + diff --git a/overlay.nix b/overlay.nix @@ -0,0 +1,15 @@ +# You can use this file as a nixpkgs overlay. This is useful in the +# case where you don't want to add the whole NUR namespace to your +# configuration. + +self: super: + +let + isReserved = n: n == "lib" || n == "overlays" || n == "modules"; + nameValuePair = n: v: { name = n; value = v; }; + nurAttrs = import ./default.nix { pkgs = super; }; +in + builtins.listToAttrs + (map (n: nameValuePair n nurAttrs.${n}) + (builtins.filter (n: !isReserved n) + (builtins.attrNames nurAttrs))) diff --git a/overlays/default.nix b/overlays/default.nix @@ -0,0 +1,6 @@ +{ + # Add your overlays here + # + # my-overlay = import ./my-overlay; +} +