From a8ab1b1679e639ef23952f1a1d0834859d1c01b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= <123550+andresilva@users.noreply.github.com> Date: Fri, 10 May 2024 23:51:53 +0100 Subject: [PATCH] nix: build improvements (#5952) * scripts: allow using existing variable values in generateVersion.sh * nix: populate versioning variables * nix: remove unused meson input * nix: remove unnecessary hyprland-protocols dependency * Nix: remove nixConfig from flake It's more annoying than helpful. * CI/Nix: fix PR build failure --------- Co-authored-by: Mihai Fufezan --- .github/workflows/nix-ci.yml | 1 + flake.nix | 8 -------- nix/default.nix | 21 ++++----------------- scripts/generateVersion.sh | 14 +++++++------- 4 files changed, 12 insertions(+), 32 deletions(-) diff --git a/.github/workflows/nix-ci.yml b/.github/workflows/nix-ci.yml index 3b017576..a66307c4 100644 --- a/.github/workflows/nix-ci.yml +++ b/.github/workflows/nix-ci.yml @@ -4,6 +4,7 @@ on: [push, pull_request, workflow_dispatch] jobs: update-inputs: + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' uses: ./.github/workflows/nix-update-inputs.yml secrets: inherit diff --git a/flake.nix b/flake.nix index eff2b3cd..82e3e4bb 100644 --- a/flake.nix +++ b/flake.nix @@ -74,9 +74,6 @@ # hyprland-extras xdg-desktop-portal-hyprland - # dependencies - - hyprland-protocols ; }); @@ -97,9 +94,4 @@ nixosModules.default = import ./nix/module.nix inputs; homeManagerModules.default = import ./nix/hm-module.nix self; }; - - nixConfig = { - extra-substituters = ["https://hyprland.cachix.org"]; - extra-trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="]; - }; } diff --git a/nix/default.nix b/nix/default.nix index 4ab9c19d..419b1429 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -5,7 +5,6 @@ pkgconf, makeWrapper, cmake, - meson, ninja, binutils, cairo, @@ -13,7 +12,6 @@ fribidi, git, hyprcursor, - hyprland-protocols, hyprlang, hyprwayland-scanner, jq, @@ -72,22 +70,12 @@ assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been remov postPatch = '' # Fix hardcoded paths to /usr installation sed -i "s#/usr#$out#" src/render/OpenGL.cpp - - # Generate version.h - cp src/version.h.in src/version.h - substituteInPlace src/version.h \ - --replace-warn "@HASH@" '${commit}' \ - --replace-warn "@BRANCH@" "" \ - --replace-warn "@MESSAGE@" "" \ - --replace-warn "@DATE@" "${date}" \ - --replace-warn "@TAG@" "" \ - --replace-warn "@DIRTY@" '${ - if commit == "" - then "dirty" - else "" - }' ''; + DATE = date; + HASH = commit; + DIRTY = if commit == "" then "dirty" else ""; + nativeBuildInputs = lib.concatLists [ [ hyprwayland-scanner @@ -118,7 +106,6 @@ assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been remov fribidi git hyprcursor.dev - hyprland-protocols hyprlang libGL libdrm diff --git a/scripts/generateVersion.sh b/scripts/generateVersion.sh index 6b1afb7b..fdcc4712 100755 --- a/scripts/generateVersion.sh +++ b/scripts/generateVersion.sh @@ -1,13 +1,13 @@ #!/bin/sh cp -fr ./src/version.h.in ./src/version.h -HASH=$(git rev-parse HEAD) -BRANCH=$(git branch --show-current) -MESSAGE=$(git show ${GIT_COMMIT_HASH} | head -n 5 | tail -n 1 | sed -e 's/#//g' -e 's/\"//g') -DATE=$(git show ${GIT_COMMIT_HASH} --no-patch --format=%cd --date=local) -DIRTY=$(git diff-index --quiet HEAD -- || echo dirty) -TAG=$(git describe --tags) -COMMITS=$(git rev-list --count HEAD) +HASH=${HASH-$(git rev-parse HEAD)} +BRANCH=${BRANCH-$(git branch --show-current)} +MESSAGE=${MESSAGE-$(git show | head -n 5 | tail -n 1 | sed -e 's/#//g' -e 's/\"//g')} +DATE=${DATE-$(git show --no-patch --format=%cd --date=local)} +DIRTY=${DIRTY-$(git diff-index --quiet HEAD -- || echo dirty)} +TAG=${TAG-$(git describe --tags)} +COMMITS=${COMMITS-$(git rev-list --count HEAD)} sed -i -e "s#@HASH@#${HASH}#" ./src/version.h sed -i -e "s#@BRANCH@#${BRANCH}#" ./src/version.h