From ff594625a13f06859187437408b524798bd6a220 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Thu, 28 Dec 2023 23:11:34 +0200 Subject: [PATCH] Nix: init --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 37 +++++++++++++++++++++++++++++++++++++ nix/default.nix | 22 ++++++++++++++++++++++ 3 files changed, 86 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..02daa5b --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "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": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ac9e479 --- /dev/null +++ b/flake.nix @@ -0,0 +1,37 @@ +{ + description = "The official implementation library for the hypr config language"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = { + self, + nixpkgs, + ... + }: let + inherit (nixpkgs) lib; + genSystems = lib.genAttrs [ + # Add more systems if they are supported + "x86_64-linux" + "aarch64-linux" + ]; + pkgsFor = nixpkgs.legacyPackages; + mkDate = longDate: (lib.concatStringsSep "-" [ + (builtins.substring 0 4 longDate) + (builtins.substring 4 2 longDate) + (builtins.substring 6 2 longDate) + ]); + in { + overlays.default = _: prev: { + hyprlang = prev.callPackage ./nix/default.nix { + stdenv = prev.gcc13Stdenv; + version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); + }; + }; + + packages = genSystems (system: + (self.overlays.default null pkgsFor.${system}) + // {default = self.packages.${system}.hyprlang;}); + + formatter = genSystems (system: pkgsFor.${system}.alejandra); + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..0204828 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,22 @@ +{ + lib, + stdenv, + cmake, + version ? "git", +}: +stdenv.mkDerivation { + pname = "hyprlang"; + inherit version; + src = ../.; + + nativeBuildInputs = [cmake]; + + doCheck = true; + + meta = with lib; { + homepage = "https://github.com/hyprwm/hyprlang"; + description = "The official implementation library for the hypr config language"; + license = licenses.gpl3Plus; + platforms = platforms.linux; + }; +}