Add custom packages
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Check flake / build-amd64-linux (push) Successful in 2m56s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Check flake / build-amd64-linux (push) Successful in 2m56s
				
			This commit is contained in:
		
							
								
								
									
										12
									
								
								flake.nix
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								flake.nix
									
									
									
									
									
								
							| @@ -53,14 +53,24 @@ | ||||
|  | ||||
|   outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, agenix, deploy-rs, disko, home-manager, nixos-hardware, nixos-mailserver, ... }: | ||||
|     let | ||||
|       inherit (nixpkgs) lib; | ||||
|       forEachSystem = lib.genAttrs [ | ||||
|         "x86_64-linux" | ||||
|         "aarch64-linux" | ||||
|       ]; | ||||
|       mkPkgsForSystem = system: inputs.nixpkgs; | ||||
|       customPkgs = forEachSystem (system: | ||||
|         lib.packagesFromDirectoryRecursive { | ||||
|           callPackage = nixpkgs.legacyPackages.${system}.callPackage; | ||||
|           directory = ./pkgs; | ||||
|         }); | ||||
|       overlays = [ | ||||
|         agenix.overlays.default | ||||
|         (import ./overlays/gnome.nix) | ||||
|         (import ./overlays/default.nix) | ||||
|         ( | ||||
|           final: prev: { | ||||
|             unstable = import inputs.nixpkgs-unstable { system = final.system; }; | ||||
|             custom = self.packages { system = final.system; }; | ||||
|           } | ||||
|         ) | ||||
|       ]; | ||||
|   | ||||
| @@ -59,41 +59,13 @@ | ||||
|     }; | ||||
|   }; | ||||
|  | ||||
|   systemd.services.ustreamer = { | ||||
|     enable = true; | ||||
|     description = "uStreamer service"; | ||||
|     unitConfig = { | ||||
|       Type = "simple"; | ||||
|     }; | ||||
|     serviceConfig = { | ||||
|       ExecStartPre = ''${pkgs.v4l-utils}/bin/v4l2-ctl \ | ||||
|         --device=/dev/video0 \ | ||||
|         --fix-edid-checksums \ | ||||
|         --info-edid | ||||
|       ''; | ||||
|       ExecStart = ''${pkgs.unstable.ustreamer}/bin/ustreamer \ | ||||
|         --device=/dev/video0 \ | ||||
|         --resolution=1280x720 \ | ||||
|         --format=uyvy \ | ||||
|         --encoder=m2m-image \ | ||||
|         --workers=3 \ | ||||
|         --persistent \ | ||||
|         --dv-timings \ | ||||
|         --drop-same-frames=30 \ | ||||
|         --host=0.0.0.0 \ | ||||
|         --port=8080 | ||||
|       ''; | ||||
|     }; | ||||
|     wantedBy = [ "network-online.target" ]; | ||||
|     confinement.mode = "chroot-only"; | ||||
|   }; | ||||
|  | ||||
|   environment.systemPackages = with pkgs; [ | ||||
|     camera-streamer | ||||
|     git | ||||
|     neovim | ||||
|     libcamera | ||||
|     libraspberrypi | ||||
|     raspberrypi-eeprom | ||||
|     rpicam-apps | ||||
|     v4l-utils | ||||
|     unstable.ustreamer | ||||
|   ]; | ||||
|   | ||||
							
								
								
									
										35
									
								
								overlays/default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								overlays/default.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| final: prev: | ||||
|  | ||||
| /* | ||||
|   Generate an overlay from `pkgs` by handling the `callPackage` behaviour | ||||
|   ourselves, making exceptions for namespaced package sets. We cannot reuse | ||||
|   the definitions from `self.legacyPackages.${prev.system}`, as that would | ||||
|   evaluate nixpkgs twice here (prev.system does not exist then). | ||||
| */ | ||||
|  | ||||
| let | ||||
|   lib = prev.lib; | ||||
|  | ||||
|   pkgs = lib.packagesFromDirectoryRecursive { | ||||
|     callPackage = path: overrides: path; | ||||
|     directory = ../pkgs; | ||||
|   }; | ||||
| in | ||||
|   lib.mapAttrs | ||||
|     (name: value: | ||||
|       if lib.isAttrs value then | ||||
|         if lib.hasAttrByPath [ name "overrideScope" ] prev then | ||||
|           # Namespaced package sets created with `lib.makeScope pkgs.newScope`. | ||||
|           prev.${name}.overrideScope (final': prev': | ||||
|             lib.mapAttrs (name': value': final'.callPackage value' { }) value) | ||||
|         else if lib.hasAttrByPath [ name "extend" ] prev then | ||||
|           # Namespaced package sets created with `lib.makeExtensible`. | ||||
|           prev.${name}.extend (final': prev': | ||||
|             lib.mapAttrs (name': value': final.callPackage value' { }) value) | ||||
|         else | ||||
|           # Namespaced package sets in regular attrsets. | ||||
|           prev.${name} // value | ||||
|       else | ||||
|         final.callPackage value { }) | ||||
|     pkgs | ||||
|  | ||||
							
								
								
									
										74
									
								
								pkgs/camera-streamer/package.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								pkgs/camera-streamer/package.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,74 @@ | ||||
| { stdenv | ||||
| , fetchFromGitHub | ||||
|  | ||||
| , cmake | ||||
| , gnumake | ||||
| , pkg-config | ||||
| , xxd | ||||
|  | ||||
| , v4l-utils | ||||
| , nlohmann_json | ||||
| , ffmpegSupport ? true | ||||
| , ffmpeg | ||||
| , libcameraSupport ? true | ||||
| , libcamera | ||||
| , rtspSupport ? true | ||||
| , live555 | ||||
| , webrtcSupport ? true | ||||
| , openssl | ||||
|  | ||||
| , lib | ||||
| }: | ||||
|  | ||||
| stdenv.mkDerivation (finalAttrs: { | ||||
|   pname = "camera-streamer"; | ||||
|   version = "0.2.8"; | ||||
|  | ||||
|   src = fetchFromGitHub { | ||||
|     owner = "ayufan"; | ||||
|     repo = "camera-streamer"; | ||||
|     rev = "refs/tags/v${finalAttrs.version}"; | ||||
|     hash = "sha256-8vV8BMFoDeh22I1/qxk6zttJROaD/lrThBxXHZSPpT4="; | ||||
|     fetchSubmodules = true; | ||||
|   }; | ||||
|  | ||||
|   # Second replacement fixes literal newline in generated version.h. | ||||
|   postPatch = '' | ||||
|     substituteInPlace Makefile \ | ||||
|       --replace '/usr/local/bin' '/bin' \ | ||||
|       --replace 'echo "#define' 'echo -e "#define' | ||||
|   ''; | ||||
|  | ||||
|   env.NIX_CFLAGS_COMPILE = builtins.toString [ | ||||
|     "-Wno-error=stringop-overflow" | ||||
|     "-Wno-error=format" | ||||
|     "-Wno-format" | ||||
|     "-Wno-format-security" | ||||
|     "-Wno-error=unused-result" | ||||
|   ]; | ||||
|  | ||||
|   nativeBuildInputs = [ | ||||
|     cmake | ||||
|     gnumake | ||||
|     pkg-config | ||||
|     xxd | ||||
|   ]; | ||||
|  | ||||
|   dontUseCmakeConfigure = true; | ||||
|  | ||||
|   buildInputs = [ nlohmann_json v4l-utils ] | ||||
|     ++ (lib.optional ffmpegSupport ffmpeg) | ||||
|     ++ (lib.optional libcameraSupport libcamera) | ||||
|     ++ (lib.optional rtspSupport live555) | ||||
|     ++ (lib.optional webrtcSupport openssl); | ||||
|  | ||||
|   installFlags = [ "DESTDIR=${builtins.placeholder "out"}" ]; | ||||
|   preInstall = "mkdir -p $out/bin"; | ||||
|  | ||||
|   meta = with lib; { | ||||
|     description = "High-performance low-latency camera streamer for Raspberry Pi's"; | ||||
|     website = "https://github.com/ayufan/camera-streamer"; | ||||
|     license = licenses.gpl3Only; | ||||
|   }; | ||||
| }) | ||||
|  | ||||
							
								
								
									
										58
									
								
								pkgs/rpicam-apps/package.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								pkgs/rpicam-apps/package.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| { stdenv | ||||
| , fetchFromGitHub | ||||
| , meson | ||||
| , ninja | ||||
| , pkg-config | ||||
| , boost | ||||
| , ffmpeg | ||||
| , libcamera | ||||
| , libdrm | ||||
| , libexif | ||||
| , libjpeg | ||||
| , libpng | ||||
| , libtiff | ||||
| , lib | ||||
| }: | ||||
|  | ||||
| stdenv.mkDerivation (finalAttrs: { | ||||
|   pname = "rpicam-apps"; | ||||
|   version = "1.4.1"; | ||||
|  | ||||
|   src = fetchFromGitHub { | ||||
|     owner = "raspberrypi"; | ||||
|     repo = "rpicam-apps"; | ||||
|     rev = "v" + finalAttrs.version; | ||||
|     hash = "sha256-3NG2ZE/Ub3lTbfne0LCXuDgLGTPaAAADRdElEbZwvls="; | ||||
|   }; | ||||
|  | ||||
|   nativeBuildInputs = [ | ||||
|     meson | ||||
|     ninja | ||||
|     pkg-config | ||||
|   ]; | ||||
|  | ||||
|   buildInputs = [ | ||||
|     boost | ||||
|     ffmpeg | ||||
|     libcamera | ||||
|     libdrm | ||||
|     libexif | ||||
|     libjpeg | ||||
|     libpng | ||||
|     libtiff | ||||
|   ]; | ||||
|  | ||||
|   # Meson is no longer able to pick up Boost automatically: | ||||
|   # https://github.com/NixOS/nixpkgs/issues/86131 | ||||
|   BOOST_INCLUDEDIR = "${lib.getDev boost}/include"; | ||||
|   BOOST_LIBRARYDIR = "${lib.getLib boost}/lib"; | ||||
|  | ||||
|   meta = with lib; { | ||||
|     description = '' | ||||
|       libcamera-based applications to drive the cameras on a Raspberry Pi platform | ||||
|     ''; | ||||
|     homepage = "https://github.com/raspberrypi/rpicam-apps"; | ||||
|     license = licenses.bsd2; | ||||
|   }; | ||||
| }) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user