diff --git a/.gitignore b/.gitignore index 40c3ccb..41e3248 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ node_modules/ .direnv/ .envrc build/ +result/ diff --git a/flake.lock b/flake.lock index b450a06..cd2b62f 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1747327360, - "narHash": "sha256-LSmTbiq/nqZR9B2t4MRnWG7cb0KVNU70dB7RT4+wYK4=", + "lastModified": 1749285348, + "narHash": "sha256-frdhQvPbmDYaScPFiCnfdh3B/Vh81Uuoo0w5TkWmmjU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e06158e58f3adee28b139e9c2bcfcc41f8625b46", + "rev": "3e3afe5174c561dee0df6f2c2b2236990146329f", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index ff2d70f..0b949bd 100644 --- a/flake.nix +++ b/flake.nix @@ -10,9 +10,62 @@ nixpkgs, }: let inherit (nixpkgs) lib; + systems = lib.systems.flakeExposed; forAllSystems = lib.genAttrs systems; nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); + + date = let + # YYYYMMDD + date' = lib.substring 0 8 self.lastModifiedDate; + year = lib.substring 0 4 date'; + month = lib.substring 4 2 date'; + day = lib.substring 6 2 date'; + in + if (self ? lastModifiedDate) + then lib.concatStringsSep "-" [year month day] + else "unknown"; + + mkClayPackage = { + system, + version, + src, + suffix, + }: + nixpkgsFor.${system}.stdenv.mkDerivation { + pname = "clay"; + version = "${version}${suffix}"; + inherit src; + + dontBuild = true; + + postInstall = '' + mkdir -p $out/include + mkdir -p $out/lib/pkgconfig + + cp clay.h $out/include + + cat <$out/lib/pkgconfig/clay.pc + prefix=$out + includedir=$out/include + Name: Clay + Description: Clay (short for C Layout) is a high performance 2D UI layout library. + Version: ${version} + Cflags: -I$out/include + EOF + ''; + + passthru.tests.pkg-config = nixpkgs.lib.testing.testMetaPkgConfig self.packages.${system}.${version}; + + meta = with lib; { + description = "Clay (short for C Layout) is a high performance 2D UI layout library."; + homepage = "https://github.com/nicbarker/clay"; + license = licenses.zlib; + maintainers = with maintainers; [nicbarker]; + pkgConfigModules = ["clay"]; + platforms = platforms.all; + }; + }; in { checks = forAllSystems ( system: let @@ -26,6 +79,8 @@ statix ]; } '' + cd ${self} + echo "Checking nix formatting" alejandra --check . @@ -34,6 +89,8 @@ echo "Checking statix" statix check . + + touch $out ''; } ); @@ -101,64 +158,31 @@ formatter = forAllSystems (system: nixpkgsFor.${system}.alejandra); - packages = forAllSystems ( - system: let - pkgs = nixpkgsFor.${system}; - git_tag - date = let - # YYYYMMDD - date' = lib.substring 0 8 self.lastModifiedDate; - year = lib.substring 0 4 date'; - month = lib.substring 4 2 date'; - date = lib.substring 6 2 date'; - in - if (self ? "lastModifiedDate") - then - lib.concatStringsSep "-" [ - year - month - date - ] - else "unknown"; - in { - default = pkgs.stdenv.mkDerivation (finalAttrs { - pname = "clay"; - version = "v0.14-master-${date}"; - src = ./.; + packages = forAllSystems (system: let + pkgs = nixpkgsFor.${system}; + inherit (pkgs) fetchFromGitHub; + in { + stable = mkClayPackage { + inherit system; + version = "0.14"; + # To update this use nurl https://github.com/nicbarker/clay {tag} + src = fetchFromGitHub { + owner = "nicbarker"; + repo = "clay"; + rev = "v0.14"; # This will need to be updated when a new version is released + hash = "sha256-6h1aQXqwzPc4oPuid3RfV7W0WzQFUiddjW7OtkKM0P8="; # This too likely + }; + suffix = ""; + }; - dontBuild = true; + unstable = mkClayPackage { + inherit system; + version = "0.14"; + src = ./.; + suffix = "-master-${date}"; + }; - installPhase = '' - mkdir -p $out/include - mkdir -p $out/lib/pkgconfig - - cp clay.h $out/include - - cat <$out/lib/pkgconfig/clay.pc - prefix=$out - includedir=$out/include - Name: Clay - Description: Clay (short for C Layout) is a high performance 2D UI layout library. - Version: $version - Cflags: -I$out/include - EOF - ''; - - passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; - - meta = with lib; { - description = "Clay (short for C Layout) is a high performance 2D UI layout library."; - homepage = "https://github.com/nicbarker/clay"; - license = licenses.zlib; - maintainers = with maintainers; [nicbarker]; - pkgConfigModules = ["clay"]; - # FIXME: I'm not sure what platforms this supports. - platforms = platforms.all; - }; - }); - - defaultPackage = self.packages.${system}.default; - } - ); + default = self.packages.${system}.stable; + }); }; }