From ebd3c47d3fed996e39ebe1a22046eaddcb10e498 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sun, 9 Jun 2024 00:13:58 +0300 Subject: [PATCH] Nix: init --- flake.lock | 43 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 45 +++++++++++++++++++++++++++++++++++++++++++++ nix/default.nix | 23 +++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/default.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..62b5934 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1717602782, + "narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8ef8886 --- /dev/null +++ b/flake.nix @@ -0,0 +1,45 @@ +{ + description = "Small C++ library for utilities used across the Hypr* ecosystem"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default-linux"; + }; + + outputs = { + self, + nixpkgs, + systems, + }: let + inherit (nixpkgs) lib; + eachSystem = lib.genAttrs (import systems); + pkgsFor = eachSystem (system: + import nixpkgs { + localSystem.system = system; + overlays = with self.overlays; [hyprutils]; + }); + mkDate = longDate: (lib.concatStringsSep "-" [ + (builtins.substring 0 4 longDate) + (builtins.substring 4 2 longDate) + (builtins.substring 6 2 longDate) + ]); + in { + overlays = { + default = self.overlays.hyprutils; + hyprutils = final: prev: { + hyprutils = final.callPackage ./nix/default.nix { + stdenv = final.gcc13Stdenv; + version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); + }; + hyprutils-with-tests = final.hyprutils.override {doCheck = true;}; + }; + }; + + packages = eachSystem (system: { + default = self.packages.${system}.hyprutils; + inherit (pkgsFor.${system}) hyprutils hyprutils-with-tests; + }); + + formatter = eachSystem (system: pkgsFor.${system}.alejandra); + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..4ada2d9 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,23 @@ +{ + lib, + stdenv, + cmake, + version ? "git", + doCheck ? false, +}: +stdenv.mkDerivation { + pname = "hyprutils"; + inherit version doCheck; + src = ../.; + + nativeBuildInputs = [cmake]; + + outputs = ["out" "dev"]; + + meta = with lib; { + homepage = "https://github.com/hyprwm/hyprutils"; + description = "Small C++ library for utilities used across the Hypr* ecosystem"; + license = licenses.bsd3; + platforms = platforms.linux; + }; +}