Skip to content

Commit

Permalink
+ nur compat
Browse files Browse the repository at this point in the history
  • Loading branch information
oluceps committed Feb 18, 2024
1 parent bb9b83b commit 2c89e8d
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
60 changes: 60 additions & 0 deletions .github/workflows/nur-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "Build and populate cache"
on:
pull_request:
workflow_dispatch:
push:
branches:
- master
schedule:
# rebuild everyday at 2:51
# TIP: Choose a random time here so not all repositories are build at once:
# https://www.random.org/clock-times/?num=1&earliest=01%3A00&latest=08%3A00&interval=5&format=html&rnd=new
- cron: '13 10 * * *'
jobs:
tests:
strategy:
matrix:
nurRepo:
- oluceps
cachixName:
- nur-pkgs
nixPath:
- nixpkgs=channel:nixos-unstable
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install nix
uses: cachix/install-nix-action@v25
with:
nix_path: "${{ matrix.nixPath }}"
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Show nixpkgs version
run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
- name: Setup cachix
uses: cachix/cachix-action@v14
# Don't replace <YOUR_CACHIX_NAME> here!
if: ${{ matrix.cachixName != '<YOUR_CACHIX_NAME>' }}
with:
name: ${{ matrix.cachixName }}
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Check evaluation
run: |
nix-env -f . -qa \* --meta --xml \
--allowed-uris https://static.rust-lang.org \
--option restrict-eval true \
--option allow-import-from-derivation true \
--drv-path --show-trace \
-I nixpkgs=$(nix-instantiate --find-file nixpkgs) \
-I $PWD
- name: Build nix packages
run: nix shell -f '<nixpkgs>' nix-build-uncached -c nix-build-uncached ci.nix -A cacheOutputs
- name: Trigger NUR update
# Don't replace <YOUR_REPO_NAME> here!
if: ${{ matrix.nurRepo != '<YOUR_REPO_NAME>' }}
run: curl -XPOST "https://nur-update.herokuapp.com/update?repo=${{ matrix.nurRepo }}"
23 changes: 23 additions & 0 deletions .github/workflows/sync-trival.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
workflow_dispatch:
push:
branches: [ master ]
schedule:
# same as build ci
- cron: '13 10 * * *'


jobs:
repo-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: repo-sync
uses: repo-sync/github-sync@v2
if: github.repository == 'oluceps/nur-pkgs'
with:
source_repo: "https://github.com/oluceps/nixos-config"
source_branch: "trival"
destination_branch: "master"
42 changes: 42 additions & 0 deletions ci.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ 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;
}
30 changes: 29 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
{ pkgs ? import <nixpkgs> }: (builtins.getFlake (toString ./.)).packages.x86_64-linux
{ pkgs ? import <nixpkgs> { } }:
let
# ugly redefine
genFilteredDirAttrsV2 = dir: excludes:
with pkgs.lib; genAttrs
(with builtins; filter
(n: !elem n excludes)
(map (removeSuffix ".nix")
(attrNames
(readDir dir))));

shadowedPkgs = [
"tcp-brutal"
"shufflecake"

# use things from flake that not pass strict eval
"arch-run"
"guix-run"
"lunar-run"
"opulr-a-run"
"runbkworm"
"runwin"
"ubt-rv-run"

"restls"
"shadow-tls"
];
in
(genFilteredDirAttrsV2 ./pkgs shadowedPkgs
(name: pkgs.callPackage (./pkgs + "/${name}.nix") { }))

0 comments on commit 2c89e8d

Please sign in to comment.