From f0499cd8ce8b813835d7ba5558c4f0c3619717ee Mon Sep 17 00:00:00 2001 From: Leon Schumacher Date: Tue, 21 May 2024 15:55:06 +0200 Subject: [PATCH] Add automatic NVIDIA package builder --- .github/workflows/nvidia.yaml | 49 +++++++++++++++++++++++++++++++++++ flake.lock | 25 +++++++++++++++--- flake.nix | 16 +++++++++++- 3 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/nvidia.yaml diff --git a/.github/workflows/nvidia.yaml b/.github/workflows/nvidia.yaml new file mode 100644 index 0000000..3e82f69 --- /dev/null +++ b/.github/workflows/nvidia.yaml @@ -0,0 +1,49 @@ +name: Build NVIDIA stuff every day at 3:00 + +on: + workflow_dispatch: + schedule: + - cron: "0 3 * * *" + +jobs: + main: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout the repo + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Install Nix + uses: cachix/install-nix-action@v25 + with: + extra_nix_config: | + substituters = https://42loco42.cachix.org https://cache.nixos.org + trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= 42loco42.cachix.org-1:6HvWFER3RdTSqEZDznqahkqaoI6QCOiX2gRpMMsThiQ= + + - name: Update, build, push + run: | + set -euo pipefail + + old="$(sha256sum flake.lock)" + nix flake update nixpkgs-new + new="$(sha256sum flake.lock)" + + if [ "$old" != "$new" ]; then + export NIXPKGS_ALLOW_UNFREE=1 + nix build \ + --impure \ + --no-link \ + --print-out-paths \ + .#nvidia \ + | cachix push 42loco42 + fi + env: + CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Commit flake updates + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Automatic update of nixpkgs-new" diff --git a/flake.lock b/flake.lock index 04ce7ec..2ca4b0c 100644 --- a/flake.lock +++ b/flake.lock @@ -10,13 +10,32 @@ "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a0c9e3aee1000ac2bfb0e5b98c94c946a5d180a9", + "type": "github" + } + }, + "nixpkgs-new": { + "locked": { + "lastModified": 1716220750, + "narHash": "sha256-Lhhrd1ZBNXCbUupWGq6gRPIy1qMKEdcAXcjnwgVqe/U=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "641daa314d5bc1bca4b345da8eb08a130b109c79", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-new": "nixpkgs-new" } } }, diff --git a/flake.nix b/flake.nix index 0cc2300..f7b9d01 100644 --- a/flake.nix +++ b/flake.nix @@ -7,9 +7,12 @@ # nsc.url = "github:snowfallorg/nix-software-center"; # nsc.inputs.nixpkgs.follows = "nixpkgs"; + + nixpkgs.url = "github:nixos/nixpkgs/a0c9e3aee1000ac2bfb0e5b98c94c946a5d180a9"; + nixpkgs-new.url = "github:nixos/nixpkgs/nixpkgs-unstable"; }; - outputs = { self, nixpkgs }: + outputs = { self, nixpkgs, nixpkgs-new }: let inherit (nixpkgs.lib) mapAttrsToList pipe recursiveUpdate; @@ -173,6 +176,17 @@ | cachix push 42loco42 ''; }; + + nvidia = + let + targets = with (import nixpkgs-new { inherit (pkgs) system; }); [ + linuxPackages.nvidiaPackages.stable + nvtopPackages.nvidia + linuxPackages.nvidiaPackages.stable.persistenced + linuxPackages.nvidiaPackages.stable.settings + ]; + in + pkgs.linkFarmFromDrvs "nvidia" targets; } ]; }