mirror of
				https://github.com/nicbarker/clay.git
				synced 2025-11-04 00:26:17 +00:00 
			
		
		
		
	refactor: fix flake checks, make package definitions easier
This commit is contained in:
		
							parent
							
								
									e465d05284
								
							
						
					
					
						commit
						e1a4fb9810
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -8,3 +8,4 @@ node_modules/
 | 
			
		|||
.direnv/
 | 
			
		||||
.envrc
 | 
			
		||||
build/
 | 
			
		||||
result/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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": {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										138
									
								
								flake.nix
									
									
									
									
									
								
							
							
						
						
									
										138
									
								
								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 <<EOF >$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 <<EOF >$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;
 | 
			
		||||
    });
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue