Skip to content

Commit

Permalink
Nix & CI: init
Browse files Browse the repository at this point in the history
  • Loading branch information
fufexan committed Feb 18, 2024
1 parent e957c74 commit 0098212
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build

on: [push, pull_request, workflow_dispatch]
jobs:
nix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

# not needed (yet)
# - uses: cachix/cachix-action@v12
# with:
# name: hyprland
# authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

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

48 changes: 48 additions & 0 deletions flake.lock

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

42 changes: 42 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
description = "Hyprland's GPU-accelerated screen locking utility";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

hyprlang = {
url = "github:hyprwm/hyprlang";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs: let
inherit (inputs.nixpkgs) lib;
genSystems = lib.genAttrs [
# Add more systems if they are supported
"x86_64-linux"
"aarch64-linux"
];
pkgsFor = genSystems (system:
import inputs.nixpkgs {
overlays = [inputs.self.overlays.default];
inherit system;
});
in {
overlays = import ./nix/overlays.nix {inherit inputs lib;};

packages = genSystems (system: {
inherit (pkgsFor.${system}) hyprlock;
default = inputs.self.packages.${system}.hyprlock;
});

homeManagerModules = {
hyprlock = import ./nix/hm-module.nix inputs.self;
default = inputs.self.homeManagerModules.hyprlock;
};

checks = genSystems (system: inputs.self.packages.${system});

formatter = genSystems (system: pkgsFor.${system}.alejandra);
};
}
44 changes: 44 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
lib,
stdenv,
cmake,
pkg-config,
cairo,
libGL,
libxkbcommon,
hyprlang,
pam,
pango,
wayland,
wayland-protocols,
version ? "git",
}:
stdenv.mkDerivation {
pname = "hyprlock";
inherit version;
src = ../.;

nativeBuildInputs = [
cmake
pkg-config
];

buildInputs = [
cairo
libGL
libxkbcommon
hyprlang
pam
pango
wayland
wayland-protocols
];

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";
};
}
118 changes: 118 additions & 0 deletions nix/hm-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
self: {
config,
pkgs,
lib,
...
}: let
inherit (builtins) toString;
inherit (lib.types) int listOf package str submodule;
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption;

cfg = config.services.hyprlock;
in {
options.services.hyprlock = {
enable = mkEnableOption "Hyprlock, Hyprland's GPU-accelerated lock screen utility";

package = mkOption {
description = "The hyprlock package";
type = package;
default = self.packages.${pkgs.stdenv.hostPlatform.system}.hyprlock;
};

backgrounds = mkOption {
description = "Monitor configurations";
type = listOf (submodule {
options = {
monitor = mkOption {
description = "The monitor to apply the given wallpaper to";
type = str;
default = "";
};

path = mkOption {
description = "The path to the wallpaper";
type = str;
default = "echo 'timeout reached'";
};
};
});
};

general.disable_loading_bar =
mkEnableOption ""
// {
description = "Whether to disable loading bar";
};

input_field = submodule {
options = {
monitor = mkOption {
description = "The monitor to place the input field on";
type = str;
default = "";
};

size = mkOption {
description = "The size of the input field";
type = submodule {
options = {
width = mkOption {
description = "Width of the input field";
type = int;
default = 200;
};
height = mkOption {
description = "Height of the input field";
type = int;
default = 50;
};
};
};
};

outline_thickness = mkOption {
description = "The outline thickness of the input field";
type = int;
default = 3;
};

outer_color = mkOption {
description = "The outer color of the input field";
type = str;
default = "rgb(151515)";
};

inner_color = mkOption {
description = "The inner color of the input field";
type = str;
default = "rgb(200, 200, 200)";
};
};
};
};

config = mkIf cfg.enable {
xdg.configFile."hypr/hyprlock.conf".text = ''
general {
disable_loading_bar = ${cfg.general.disable_loading_bar}
}
input_field {
monitor = ${cfg.input_field.monitor}
size = ${toString cfg.input_field.size.width} ${toString cfg.input_field.size.height}
outline_thickness = ${toString cfg.input_field.outline_thickness}
outer_color = ${cfg.input_field.outer_color}
inner_color = ${cfg.input_field.inner_color}
}
${builtins.concatStringsSep "\n" (map (background: ''
background {
monitor = ${background.monitor}
path = ${background.path}
}
'')
cfg.backgrounds)}
'';
};
}
21 changes: 21 additions & 0 deletions nix/overlays.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
lib,
inputs,
}: let
mkDate = longDate: (lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
in {
default = lib.composeManyExtensions [
inputs.hyprlang.overlays.default
(final: prev: {
hyprlock = prev.callPackage ./default.nix {
stdenv = prev.gcc13Stdenv;
version = "0.pre" + "+date=" + (mkDate (inputs.self.lastModifiedDate or "19700101")) + "_" + (inputs.self.shortRev or "dirty");
inherit (final) hyprlang;
};
})
];
}

0 comments on commit 0098212

Please sign in to comment.