From 2d370eff32574b5a2c63addf616002343a8c0df2 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sat, 17 Feb 2024 23:06:07 +0200 Subject: [PATCH] Nix: init --- flake.lock | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 37 +++++++++++++++++++++++++++++++++++++ nix/default.nix | 33 +++++++++++++++++++++++++++++++++ nix/overlays.nix | 21 +++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/default.nix create mode 100644 nix/overlays.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..cd0f57f --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "hyprlang": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1708197082, + "narHash": "sha256-6jMgmGkZLXUHVSkUQi9NLhFD3KYrG8merm0T9qiUdyA=", + "owner": "hyprwm", + "repo": "hyprlang", + "rev": "65a7f870a682bd313ae978d76e61ebc72fbd64cd", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprlang", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1702645756, + "narHash": "sha256-qKI6OR3TYJYQB3Q8mAZ+DG4o/BR9ptcv9UnRV2hzljc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "40c3c94c241286dd2243ea34d3aef8a488f9e4d0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "hyprlang": "hyprlang", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f95356d --- /dev/null +++ b/flake.nix @@ -0,0 +1,37 @@ +{ + description = "Hyprland's idle daemon"; + + 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}) hypridle; + default = inputs.self.packages.${system}.hypridle; + }); + + checks = genSystems (system: inputs.self.packages.${system}); + + formatter = genSystems (system: pkgsFor.${system}.alejandra); + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..85ac6a0 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,33 @@ +{ + lib, + stdenv, + cmake, + pkg-config, + hyprlang, + wayland, + wayland-protocols, + version ? "git", +}: +stdenv.mkDerivation { + pname = "hypridle"; + inherit version; + src = ../.; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ + hyprlang + wayland + wayland-protocols + ]; + + meta = { + homepage = "https://github.com/hyprwm/hypridle"; + description = "An idle management daemon for Hyprland"; + license = lib.licenses.bsd3; + platforms = lib.platforms.linux; + }; +} diff --git a/nix/overlays.nix b/nix/overlays.nix new file mode 100644 index 0000000..b6544c2 --- /dev/null +++ b/nix/overlays.nix @@ -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: { + hypridle = 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; + }; + }) + ]; +}