From dd95bed0d850a9fbca2836c861c3fb3610cc1586 Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Mon, 16 Jul 2018 14:14:10 +0200 Subject: [PATCH] Initial commit Extracted the skeleton from https://github.com/fgaz/nur-packages.git --- .gitignore | 3 +++ .travis.yml | 23 +++++++++++++++++++++++ LICENSE | 22 ++++++++++++++++++++++ README.md | 28 ++++++++++++++++++++++++++++ default.nix | 19 +++++++++++++++++++ non-broken.nix | 25 +++++++++++++++++++++++++ overlay.nix | 15 +++++++++++++++ pkgs/example-package/default.nix | 9 +++++++++ standalone.nix | 9 +++++++++ 9 files changed, 153 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 default.nix create mode 100644 non-broken.nix create mode 100644 overlay.nix create mode 100644 pkgs/example-package/default.nix create mode 100644 standalone.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7dc3520 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +result +result-* + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0ff4a69 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: nix + +sudo: false + +env: + global: + - CACHIX_CACHE= + - NUR_REPO= + +install: + - nix --version + - travis_retry nix-channel --update + - if [ -n "${CACHIX_CACHE}" ]; then nix-env -if https://github.com/cachix/cachix/tarball/master --substituters https://cachix.cachix.org --trusted-public-keys cachix.cachix.org-1:eWNHQldwUO7G2VkjpnjDbWwy4KQ/HNxht7H4SSoMckM=; fi + - if [ -n "${CACHIX_CACHE}" ]; then cachix use "${CACHIX_CACHE}"; fi + +script: + - export outs=$(nix-build non-broken.nix) + - echo Produced $outs + +after_success: + - if [ -n "${CACHIX_CACHE}" ]; then cachix push "${CACHIX_CACHE}" $outs; fi + - curl -XPOST "https://nur-update.herokuapp.com/update?repo=${NUR_REPO}" + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..212cbf2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2018 Francesco Gazzetta + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..2aa0ada --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# nur-packages-template + +**A template for [NUR](https://github.com/nix-community/NUR) repositories** + +## Setup + +1. Fork this repo +2. Add your packages to the [pkgs](./pkgs) directory and to + [default.nix](./default.nix) + * Remember to mark the broken packages as `broken = true;` in the `meta` + attribute, or travis (and consequently caching) will fail! +3. Add your NUR repo name and your cachix repo name (optional) to + [.travis.yml](./.travis.yml) +4. Enable travis for your repo +5. Change your travis and cachix names on the README template section and delete + the rest +6. [Add yourself to NUR](https://github.com/nix-community/NUR#how-to-add-your-own-repository) + +## README template + +# nur-packages + +**My personal [NUR](https://github.com/nix-community/NUR) repository** + +[![Build Status](https://travis-ci.com//nur-packages.svg?branch=master)](https://travis-ci.com//nur-packages) +[![Cachix Cache](https://img.shields.io/badge/cachix--blue.svg)](https://.cachix.org) + + diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..ada0825 --- /dev/null +++ b/default.nix @@ -0,0 +1,19 @@ +# 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. + +{ callPackage +, libsForQt5 +, haskellPackages +, pythonPackages +# , ... +# Add here other callPackage/callApplication/... providers as the need arises +, ... }: + +{ + example-package = callPackage ./pkgs/example-package { }; + # some-qt5-package = libsForQt5.callPackage ./pkgs/some-qt5-package { }; + # ... +} + diff --git a/non-broken.nix b/non-broken.nix new file mode 100644 index 0000000..18ae8b5 --- /dev/null +++ b/non-broken.nix @@ -0,0 +1,25 @@ +# This file filters out all the broken packages from your package set. +# 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. + +let filterSet = + (f: s: builtins.listToAttrs + (map + (n: { name = n; value = builtins.getAttr n s; }) + (builtins.filter + (n: f (builtins.getAttr n s)) + (builtins.attrNames s) + ) + ) + ); +in filterSet + (p: (builtins.isAttrs p) + && !( + (builtins.hasAttr "meta" p) + && (builtins.hasAttr "broken" p.meta) + && (p.meta.broken) + ) + ) + (import ./standalone.nix) + diff --git a/overlay.nix b/overlay.nix new file mode 100644 index 0000000..d9f98f8 --- /dev/null +++ b/overlay.nix @@ -0,0 +1,15 @@ +# You can use this file as a nixpkgs overlay. +# It's useful in the case where you don't want to add the whole NUR namespace +# to your configuration. + +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 +} + diff --git a/pkgs/example-package/default.nix b/pkgs/example-package/default.nix new file mode 100644 index 0000000..1427461 --- /dev/null +++ b/pkgs/example-package/default.nix @@ -0,0 +1,9 @@ +{ stdenv }: + +stdenv.mkDerivation rec { + name = "example-package-${version}"; + version = "1.0"; + buildPhase = "echo echo Hello World > example"; + installPhase = "install -Dm755 example $out"; +} + diff --git a/standalone.nix b/standalone.nix new file mode 100644 index 0000000..cadb80a --- /dev/null +++ b/standalone.nix @@ -0,0 +1,9 @@ +# 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 {} +