From ae1ee8ea7e7e5f0fb5ddb3ee6bcd719f561451fe Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sat, 9 Mar 2024 01:46:16 +0200 Subject: [PATCH] Nix: init --- flake.lock | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 39 +++++++++++++++++++++++ nix/default.nix | 42 +++++++++++++++++++++++++ nix/overlays.nix | 23 ++++++++++++++ 4 files changed, 184 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..599b845 --- /dev/null +++ b/flake.lock @@ -0,0 +1,80 @@ +{ + "nodes": { + "hyprlang": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems" + }, + "locked": { + "lastModified": 1709914708, + "narHash": "sha256-bR4o3mynoTa1Wi4ZTjbnsZ6iqVcPGriXp56bZh5UFTk=", + "owner": "hyprwm", + "repo": "hyprlang", + "rev": "a685493fdbeec01ca8ccdf1f3655c044a8ce2fe2", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprlang", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1708475490, + "narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0e74ca98a74bc7270d28838369593635a5db3260", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "hyprlang": "hyprlang", + "nixpkgs": "nixpkgs", + "systems": "systems_2" + } + }, + "systems": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..bcee089 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + description = "The hyprland cursor format, library and utilities"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default-linux"; + + hyprlang = { + url = "github:hyprwm/hyprlang"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + 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; [default]; + }); + in { + overlays = import ./nix/overlays.nix {inherit inputs lib;}; + + packages = eachSystem (system: { + default = self.packages.${system}.hyprcursor; + inherit (pkgsFor.${system}) hyprcursor; + }); + + checks = eachSystem (system: self.packages.${system}); + + formatter = eachSystem (system: pkgsFor.${system}.alejandra); + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..d771628 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,42 @@ +{ + lib, + stdenv, + cmake, + pkg-config, + cairo, + hyprlang, + librsvg, + libzip, + version ? "git", +}: +stdenv.mkDerivation { + pname = "hyprcursor"; + inherit version; + src = ../.; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ + cairo + hyprlang + librsvg + libzip + ]; + + outputs = [ + "bin" + "dev" + "lib" + ]; + + meta = { + homepage = "https://github.com/hyprwm/hyprcursor"; + description = "The hyprland cursor format, library and utilities"; + license = lib.licenses.bsd3; + platforms = lib.platforms.linux; + mainProgram = "hyprcursor"; + }; +} diff --git a/nix/overlays.nix b/nix/overlays.nix new file mode 100644 index 0000000..0286ba1 --- /dev/null +++ b/nix/overlays.nix @@ -0,0 +1,23 @@ +{ + lib, + inputs, +}: let + mkDate = longDate: (lib.concatStringsSep "-" [ + (builtins.substring 0 4 longDate) + (builtins.substring 4 2 longDate) + (builtins.substring 6 2 longDate) + ]); +in { + default = inputs.self.overlays.hyprcursor; + + hyprcursor = lib.composeManyExtensions [ + inputs.hyprlang.overlays.default + (final: prev: { + hyprcursor = 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; + }; + }) + ]; +}