From 19c19d36e9615b7857fa0ec3d486ab4bd1a882d5 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Mon, 1 Jul 2024 10:52:16 +0300 Subject: [PATCH] Nix: init --- flake.lock | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 62 +++++++++++++++++++++++++++++++++ nix/default.nix | 58 +++++++++++++++++++++++++++++++ 3 files changed, 211 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..f1beb2e --- /dev/null +++ b/flake.lock @@ -0,0 +1,91 @@ +{ + "nodes": { + "hyprutils": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "systems": [ + "systems" + ] + }, + "locked": { + "lastModified": 1719593398, + "narHash": "sha256-OC3ciW8JmQwFyWl2v5aCNx1Qtbqzglv2nAqqX0pu0xk=", + "owner": "hyprwm", + "repo": "hyprutils", + "rev": "7e1b6610a21b451ca8aacf5b22c95f4139df43d6", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprutils", + "type": "github" + } + }, + "hyprwayland-scanner": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "systems": [ + "systems" + ] + }, + "locked": { + "lastModified": 1719440676, + "narHash": "sha256-7J5P78kH+Sg7LaKYOqnJtOKOF+NB2z/8bhm622FULPI=", + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "rev": "55c78a56c0f6831a62945f8d3edc62ed827c575c", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1719506693, + "narHash": "sha256-C8e9S7RzshSdHB7L+v9I51af1gDM5unhJ2xO1ywxNH8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b2852eb9365c6de48ffb0dc2c9562591f652242a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "hyprutils": "hyprutils", + "hyprwayland-scanner": "hyprwayland-scanner", + "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..d9f2fdb --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + description = "A very light linux rendering backend library"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default-linux"; + + hyprutils = { + url = "github:hyprwm/hyprutils"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.systems.follows = "systems"; + }; + + hyprwayland-scanner = { + url = "github:hyprwm/hyprwayland-scanner"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.systems.follows = "systems"; + }; + }; + + 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; [aquamarine]; + }); + mkDate = longDate: (lib.concatStringsSep "-" [ + (builtins.substring 0 4 longDate) + (builtins.substring 4 2 longDate) + (builtins.substring 6 2 longDate) + ]); + in { + overlays = { + default = self.overlays.aquamarine; + aquamarine = lib.composeManyExtensions [ + inputs.hyprutils.overlays.default + inputs.hyprwayland-scanner.overlays.default + (final: prev: { + aquamarine = final.callPackage ./nix/default.nix { + stdenv = final.gcc13Stdenv; + version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); + }; + aquamarine-with-tests = final.aquamarine.override {doCheck = true;}; + }) + ]; + }; + + packages = eachSystem (system: { + default = self.packages.${system}.aquamarine; + inherit (pkgsFor.${system}) aquamarine aquamarine-with-tests; + }); + + formatter = eachSystem (system: pkgsFor.${system}.alejandra); + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..fed100c --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,58 @@ +{ + lib, + stdenv, + cmake, + hyprutils, + hyprwayland-scanner, + libdisplay-info, + libdrm, + libffi, + libinput, + libseat, + mesa, + pixman, + pkg-config, + udev, + wayland, + wayland-protocols, + version ? "git", + doCheck ? false, +}: +stdenv.mkDerivation { + pname = "aquamarine"; + inherit version doCheck; + src = ../.; + + nativeBuildInputs = [ + cmake + hyprwayland-scanner + pkg-config + ]; + + buildInputs = [ + hyprutils + libdisplay-info + libdrm + libffi + libinput + libseat + mesa + pixman + udev + wayland + wayland-protocols + ]; + + outputs = ["out" "dev"]; + + cmakeBuildType = "RelWithDebInfo"; + + dontStrip = true; + + meta = { + homepage = "https://github.com/hyprwm/aquamarine"; + description = "A very light linux rendering backend library"; + license = lib.licenses.bsd3; + platforms = lib.platforms.linux; + }; +}