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 @@ -163,3 +163,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()
12 changes: 6 additions & 6 deletions flake.lock

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

59 changes: 31 additions & 28 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,42 @@
};
};

outputs =
{
self,
nixpkgs,
systems,
...
}@inputs:
let
inherit (nixpkgs) lib;
eachSystem = lib.genAttrs (import systems);
pkgsFor = eachSystem (
system:
outputs = {
self,
nixpkgs,
systems,
...
} @ inputs: let
inherit (nixpkgs) lib;
eachSystem = lib.genAttrs (import systems);
pkgsFor = eachSystem (
system:
import nixpkgs {
localSystem.system = system;
overlays = with self.overlays; [ hyprlock-with-deps ];
overlays = with self.overlays; [hyprlock-with-deps];
}
);
in
{
overlays = import ./nix/overlays.nix { inherit inputs lib self; };

packages = eachSystem (system: {
default = self.packages.${system}.hyprlock;
inherit (pkgsFor.${system}) hyprlock;
);
pkgsDebugFor = eachSystem (system:
import nixpkgs {
localSystem = system;
overlays = with self.overlays; [hyprlock-debug hyprlock-with-deps];
});
in {
overlays = import ./nix/overlays.nix {inherit inputs lib self;};

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});
packages = eachSystem (system: {
default = self.packages.${system}.hyprlock;
inherit (pkgsFor.${system}) hyprlock;
inherit (pkgsDebugFor.${system}) hyprlock-debug hyprlock-test-meta;
});

formatter = eachSystem (system: pkgsFor.${system}.nixfmt-tree);
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} // (import ./nix/tests/default.nix inputs pkgsFor.${system}));

formatter = eachSystem (system: pkgsFor.${system}.nixfmt-tree);
};
}
103 changes: 64 additions & 39 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,49 +20,73 @@
wayland,
wayland-protocols,
wayland-scanner,
debug ? false,
version ? "git",
shortRev ? "",
}:
stdenv.mkDerivation {
pname = "hyprlock";
inherit version;
}: let
inherit (builtins) foldl';
inherit (lib.lists) flatten;
inherit (lib.sources) cleanSourceWith cleanSource;
inherit (lib.strings) hasSuffix optionalString;

src = ../.;

nativeBuildInputs = [
cmake
pkg-config
hyprwayland-scanner
wayland-scanner
adapters = flatten [
stdenvAdapters.useMoldLinker
(lib.optional debug stdenvAdapters.keepDebugInfo)
];

buildInputs = [
cairo
libdrm
libGL
libxkbcommon
libgbm
hyprgraphics
hyprlang
hyprutils
pam
pango
sdbus-cpp_2
systemdLibs
wayland
wayland-protocols
];
customStdenv = foldl' (acc: adapter: adapter acc) stdenv adapters;
in
customStdenv.mkDerivation {
pname = "hyprlock${optionalString debug "-debug"}";
inherit version;

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

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

buildInputs = [
cairo
libdrm
libGL
libxkbcommon
libgbm
hyprgraphics
hyprlang
hyprutils
pam
pango
sdbus-cpp_2
systemdLibs
wayland
wayland-protocols
];

cmakeFlags = lib.mapAttrsToList lib.cmakeFeature {
HYPRLOCK_COMMIT = shortRev;
HYPRLOCK_VERSION_COMMIT = ""; # Intentionally left empty (hyprlock --version will always print the commit)
};

cmakeFlags = lib.mapAttrsToList lib.cmakeFeature {
HYPRLOCK_COMMIT = shortRev;
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";
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
mainProgram = "hyprlock";
};
}
meta = {
homepage = "https://github.com/hyprwm/hyprlock";
description = "A gpu-accelerated screen lock for Hyprland";
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
mainProgram = "hyprlock";
};
}
32 changes: 21 additions & 11 deletions nix/overlays.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
lib,
inputs,
self,
}:
let
mkDate =
longDate:
(lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
}: let
mkDate = longDate: (lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);

version = lib.removeSuffix "\n" (builtins.readFile ../VERSION);
in
{
in {
default = inputs.self.overlays.hyprlock;

hyprlock-with-deps = lib.composeManyExtensions [
Expand All @@ -37,4 +33,18 @@ in
shortRev = self.sourceInfo.shortRev or "dirty";
};
};

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.gcc15Stdenv;
version = version + "+date=" + (mkDate (inputs.self.lastModifiedDate or "19700101")) + "_" + (inputs.self.shortRev or "dirty");
};
})
];
}
Loading
Loading