Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/nix.yml → .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Build
name: Build (Nix)

on:
workflow_call:
secrets:
CACHIX_AUTH_TOKEN:
required: false

on: [push, pull_request, workflow_dispatch]
jobs:
nix:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -42,7 +47,6 @@ jobs:
# with:
# name: hyprland
# authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

#
- name: Build
run: nix flake check --print-build-logs --keep-going

run: nix build 'github:${{ github.repository }}?ref=${{ github.ref }}' -L --extra-substituters "https://hyprland.cachix.org"
15 changes: 15 additions & 0 deletions .github/workflows/nix-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Nix

on: [push, pull_request, workflow_dispatch]

jobs:
hyprlock:
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
uses: ./.github/workflows/nix-build.yml
secrets: inherit

test:
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
needs: hyprlock
uses: ./.github/workflows/nix-test.yml
secrets: inherit
66 changes: 66 additions & 0 deletions .github/workflows/nix-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Test (Nix)

on:
workflow_call:
secrets:
CACHIX_AUTH_TOKEN:
required: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v31
with:
nix_conf: |
keep-env-derivations = true
keep-outputs = true

- name: Restore and save Nix store
uses: nix-community/cache-nix-action@v6
with:
# restore and save a cache using this key
primary-key: nix-${{ runner.os }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: nix-${{ runner.os }}
# collect garbage until the Nix store size (in bytes) is at most this number
# before trying to save a new cache
# 1G = 1073741824
gc-max-store-size-linux: 5G
# do purge caches
purge: true
# purge all versions of the cache
purge-prefixes: nix-${{ runner.os }}
# created more than this number of seconds ago
purge-created: 0
# or, last accessed more than this number of seconds ago
# relative to the start of the `Post Restore and save Nix store` phase
purge-last-accessed: 0
# except any version with the key that is the same as the `primary-key`
purge-primary-key: never

#- uses: cachix/cachix-action@v15
# with:
# name: hyprland
# authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

- name: Run test VM
run: nix build 'github:${{ github.repository }}?ref=${{ github.ref }}#checks.x86_64-linux.tests' -L --extra-substituters "https://hyprland.cachix.org"

- name: Check exit status
run: grep 0 result/exit_status

- name: Upload logs
if: always()
uses: actions/upload-artifact@v4
with:
name: logs
path: result/logs

- name: Upload traces
if: always()
uses: actions/upload-artifact@v4
with:
name: traces
path: result/traces
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,13 @@ install(
FILES ${CMAKE_SOURCE_DIR}/assets/example.conf
DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/hypr
RENAME hyprlock.conf)

if(TESTS)
include(CTest)
message(STATUS "Building hyprlock test meta package")

enable_testing()
add_custom_target(tests)

add_subdirectory(tests)
endif()
29 changes: 15 additions & 14 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,28 @@
pkgsFor = eachSystem (system:
import nixpkgs {
localSystem.system = system;
overlays = with self.overlays; [default];
overlays = [self.overlays.default];
});
pkgsDebugFor = eachSystem (system:
import nixpkgs {
localSystem = system;
overlays = [self.overlays.hyprlock-debug];
});
in {
overlays = import ./nix/overlays.nix {inherit inputs lib self;};

packages = eachSystem (system: {
default = self.packages.${system}.hyprlock;
inherit (pkgsFor.${system}) hyprlock;
inherit (pkgsDebugFor.${system}) hyprlock-debug hyprlock-test-meta;
});

homeManagerModules = {
default = self.homeManagerModules.hyprlock;
hyprlock = builtins.throw "hyprlock: the flake HM module has been removed. Use the module from Home Manager upstream.";
};

checks = eachSystem (system: self.packages.${system});
checks = eachSystem (system: self.packages.${system} // (import ./nix/tests/default.nix inputs pkgsFor.${system}));

formatter = eachSystem (system: pkgsFor.${system}.alejandra);
};
Expand Down
33 changes: 29 additions & 4 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
lib,
stdenv,
stdenvAdapters,
cmake,
pkg-config,
cairo,
Expand All @@ -19,14 +20,33 @@
wayland,
wayland-protocols,
wayland-scanner,
debug ? false,
version ? "git",
shortRev ? "",
}:
stdenv.mkDerivation {
pname = "hyprlock";
}: let
inherit (builtins) foldl';
inherit (lib.lists) flatten;
inherit (lib.sources) cleanSourceWith cleanSource;
inherit (lib.strings) hasSuffix optionalString;

adapters = flatten [
stdenvAdapters.useMoldLinker
(lib.optional debug stdenvAdapters.keepDebugInfo)
];

customStdenv = foldl' (acc: adapter: adapter acc) stdenv adapters;
in
customStdenv.mkDerivation {
pname = "hyprlock${optionalString debug "-debug"}";
inherit version;

src = ../.;
src = cleanSourceWith {
filter = name: _type: let
baseName = baseNameOf (toString name);
in
! (hasSuffix ".nix" baseName);
src = cleanSource ../.;
};

nativeBuildInputs = [
cmake
Expand Down Expand Up @@ -57,6 +77,11 @@ stdenv.mkDerivation {
HYPRLOCK_VERSION_COMMIT = ""; # Intentionally left empty (hyprlock --version will always print the commit)
};

cmakeBuildType =
if debug
then "Debug"
else "Release";

meta = {
homepage = "https://github.com/hyprwm/hyprlock";
description = "A gpu-accelerated screen lock for Hyprland";
Expand Down
16 changes: 16 additions & 0 deletions nix/overlays.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ in {
})
];

hyprlock-debug = lib.composeManyExtensions [
self.overlays.hyprlock
# Dependencies
(final: prev: {
hyprutils = prev.hyprutils.override {debug = true;};
hyprgraphics = prev.hyprgraphics.override {debug = true;};
hyprlock-debug = prev.hyprlock.override {debug = true;};
hyprlock-test-meta = prev.callPackage ./test-meta.nix {
stdenv = prev.gcc14Stdenv;
version = version + "+date=" + (mkDate (inputs.self.lastModifiedDate or "19700101")) + "_" + (inputs.self.shortRev or "dirty");
hyprland-protocols = final.hyprland-protocols;
wayland-scanner = final.wayland-scanner;
};
})
];

sdbuscpp = final: prev: {
sdbus-cpp = prev.sdbus-cpp.overrideAttrs (self: super: {
version = "2.0.0";
Expand Down
45 changes: 45 additions & 0 deletions nix/test-meta.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
cmake,
egl-wayland,
hyprland-protocols,
hyprlock,
hyprwayland-scanner,
lib,
pkg-config,
stdenv,
stdenvAdapters,
wayland-scanner,
version ? "git",
}: let
inherit (lib.sources) cleanSourceWith cleanSource;
inherit (lib.strings) hasSuffix;
in
stdenv.mkDerivation (finalAttrs: {
pname = "hyprlock-test-meta";
inherit version;

src = cleanSourceWith {
filter = name: _type: let
baseName = baseNameOf (toString name);
in
! (hasSuffix ".nix" baseName);
src = cleanSource ../tests;
};

nativeBuildInputs = [
cmake
hyprland-protocols
hyprwayland-scanner
pkg-config
wayland-scanner
];

buildInputs = hyprlock.buildInputs;

meta = {
homepage = "https://github.com/hyprwm/hyprlock";
description = "Hyprlock testing utility";
license = lib.licenses.bsd3;
platforms = hyprlock.meta.platforms;
};
})
Loading