convert shell.nix to flake.nix
This commit is contained in:
		
							parent
							
								
									30d74ff07d
								
							
						
					
					
						commit
						3db1fb643f
					
				
					 8 changed files with 196 additions and 29 deletions
				
			
		|  | @ -1 +1 @@ | ||||||
| use nix | use flake | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -5,3 +5,4 @@ bin | ||||||
| obj | obj | ||||||
| .direnv | .direnv | ||||||
| .envrc | .envrc | ||||||
|  | result | ||||||
|  |  | ||||||
|  | @ -1,7 +1,9 @@ | ||||||
| [workspace] | [workspace] | ||||||
| resolver = "2" | resolver = "2" | ||||||
| members = [ | members = [ | ||||||
|     "crates/*", |     "crates/servicepoint", | ||||||
|  |     "crates/servicepoint_binding_c", | ||||||
|  |     "crates/servicepoint_binding_cs", | ||||||
|     "crates/servicepoint_binding_c/examples/lang_c" |     "crates/servicepoint_binding_c/examples/lang_c" | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ servicepoint = "0.10.0" | ||||||
| 
 | 
 | ||||||
| ## Examples | ## Examples | ||||||
| 
 | 
 | ||||||
| ```rust | ```rust should_panic | ||||||
| fn main() { | fn main() { | ||||||
|     // establish connection |     // establish connection | ||||||
|     let connection = servicepoint::Connection::open("172.23.42.29:2342") |     let connection = servicepoint::Connection::open("172.23.42.29:2342") | ||||||
|  |  | ||||||
|  | @ -120,8 +120,7 @@ pub const PIXEL_COUNT: usize = PIXEL_WIDTH * PIXEL_HEIGHT; | ||||||
| /// ```rust
 | /// ```rust
 | ||||||
| /// # use std::time::Instant;
 | /// # use std::time::Instant;
 | ||||||
| /// # use servicepoint::{Command, CompressionCode, FRAME_PACING, Origin, Bitmap};
 | /// # use servicepoint::{Command, CompressionCode, FRAME_PACING, Origin, Bitmap};
 | ||||||
| /// # let connection = servicepoint::Connection::open("172.23.42.29:2342")
 | /// # let connection = servicepoint::Connection::Fake;
 | ||||||
| /// #     .expect("connection failed");
 |  | ||||||
| /// # let pixels = Bitmap::max_sized();
 | /// # let pixels = Bitmap::max_sized();
 | ||||||
| /// loop {
 | /// loop {
 | ||||||
| ///    let start = Instant::now();
 | ///    let start = Instant::now();
 | ||||||
|  |  | ||||||
							
								
								
									
										64
									
								
								flake.lock
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								flake.lock
									
										
									
										generated
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,64 @@ | ||||||
|  | { | ||||||
|  |   "nodes": { | ||||||
|  |     "naersk": { | ||||||
|  |       "inputs": { | ||||||
|  |         "nixpkgs": [ | ||||||
|  |           "nixpkgs" | ||||||
|  |         ] | ||||||
|  |       }, | ||||||
|  |       "locked": { | ||||||
|  |         "lastModified": 1721727458, | ||||||
|  |         "narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=", | ||||||
|  |         "owner": "nix-community", | ||||||
|  |         "repo": "naersk", | ||||||
|  |         "rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11", | ||||||
|  |         "type": "github" | ||||||
|  |       }, | ||||||
|  |       "original": { | ||||||
|  |         "owner": "nix-community", | ||||||
|  |         "repo": "naersk", | ||||||
|  |         "type": "github" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "nix-filter": { | ||||||
|  |       "locked": { | ||||||
|  |         "lastModified": 1730207686, | ||||||
|  |         "narHash": "sha256-SCHiL+1f7q9TAnxpasriP6fMarWE5H43t25F5/9e28I=", | ||||||
|  |         "owner": "numtide", | ||||||
|  |         "repo": "nix-filter", | ||||||
|  |         "rev": "776e68c1d014c3adde193a18db9d738458cd2ba4", | ||||||
|  |         "type": "github" | ||||||
|  |       }, | ||||||
|  |       "original": { | ||||||
|  |         "owner": "numtide", | ||||||
|  |         "repo": "nix-filter", | ||||||
|  |         "type": "github" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "nixpkgs": { | ||||||
|  |       "locked": { | ||||||
|  |         "lastModified": 1730963269, | ||||||
|  |         "narHash": "sha256-rz30HrFYCHiWEBCKHMffHbMdWJ35hEkcRVU0h7ms3x0=", | ||||||
|  |         "owner": "nixos", | ||||||
|  |         "repo": "nixpkgs", | ||||||
|  |         "rev": "83fb6c028368e465cd19bb127b86f971a5e41ebc", | ||||||
|  |         "type": "github" | ||||||
|  |       }, | ||||||
|  |       "original": { | ||||||
|  |         "owner": "nixos", | ||||||
|  |         "ref": "nixos-24.05", | ||||||
|  |         "repo": "nixpkgs", | ||||||
|  |         "type": "github" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "root": { | ||||||
|  |       "inputs": { | ||||||
|  |         "naersk": "naersk", | ||||||
|  |         "nix-filter": "nix-filter", | ||||||
|  |         "nixpkgs": "nixpkgs" | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   "root": "root", | ||||||
|  |   "version": 7 | ||||||
|  | } | ||||||
							
								
								
									
										125
									
								
								flake.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								flake.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,125 @@ | ||||||
|  | { | ||||||
|  |   description = "Flake for servicepoint-simulator"; | ||||||
|  | 
 | ||||||
|  |   inputs = { | ||||||
|  |     nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; | ||||||
|  |     nix-filter.url = "github:numtide/nix-filter"; | ||||||
|  |     naersk = { | ||||||
|  |       url = "github:nix-community/naersk"; | ||||||
|  |       inputs.nixpkgs.follows = "nixpkgs"; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   outputs = | ||||||
|  |     inputs@{ | ||||||
|  |       self, | ||||||
|  |       nixpkgs, | ||||||
|  |       naersk, | ||||||
|  |       nix-filter, | ||||||
|  |     }: | ||||||
|  |     let | ||||||
|  |       lib = nixpkgs.lib; | ||||||
|  |       supported-systems = [ | ||||||
|  |         "x86_64-linux" | ||||||
|  |         "aarch64-linux" | ||||||
|  |         "aarch64-darwin" | ||||||
|  |         "x86_64-darwin" | ||||||
|  |       ]; | ||||||
|  |       forAllSystems = lib.genAttrs supported-systems; | ||||||
|  |       make-rust-toolchain-core = | ||||||
|  |         pkgs: | ||||||
|  |         pkgs.symlinkJoin { | ||||||
|  |           name = "rust-toolchain-core"; | ||||||
|  |           paths = with pkgs; [ | ||||||
|  |             rustc | ||||||
|  |             cargo | ||||||
|  |             rustPlatform.rustcSrc | ||||||
|  |           ]; | ||||||
|  |         }; | ||||||
|  |     in | ||||||
|  |     rec { | ||||||
|  |       packages = forAllSystems ( | ||||||
|  |         system: | ||||||
|  |         let | ||||||
|  |           pkgs = nixpkgs.legacyPackages."${system}"; | ||||||
|  |           rust-toolchain-core = make-rust-toolchain-core pkgs; | ||||||
|  |           naersk' = pkgs.callPackage naersk { | ||||||
|  |             cargo = rust-toolchain-core; | ||||||
|  |             rustc = rust-toolchain-core; | ||||||
|  |           }; | ||||||
|  |           source = nix-filter.lib.filter { | ||||||
|  |              root = ./.; | ||||||
|  |              include = [ | ||||||
|  |                ./Cargo.toml | ||||||
|  |                ./Cargo.lock | ||||||
|  |                ./crates | ||||||
|  |                ./Web437_IBM_BIOS.woff | ||||||
|  |                ./README.md | ||||||
|  |                ./LICENSE | ||||||
|  |              ]; | ||||||
|  |            }; | ||||||
|  |         in | ||||||
|  |         rec { | ||||||
|  |           servicepoint = naersk'.buildPackage rec { | ||||||
|  |             cargoBuildOptions = | ||||||
|  |               x: | ||||||
|  |               x | ||||||
|  |               ++ [ | ||||||
|  |                 "-p" | ||||||
|  |                 "servicepoint" | ||||||
|  |               ]; | ||||||
|  |             cargoTestOptions = | ||||||
|  |               x: | ||||||
|  |               x | ||||||
|  |               ++ [ | ||||||
|  |                 "-p" | ||||||
|  |                 "servicepoint" | ||||||
|  |               ]; | ||||||
|  |             src = source; | ||||||
|  |             doCheck = true; | ||||||
|  |             nativeBuildInputs = with pkgs; [ | ||||||
|  |               pkg-config | ||||||
|  |               makeWrapper | ||||||
|  |             ]; | ||||||
|  |             strictDeps = true; | ||||||
|  |             buildInputs = with pkgs; [ | ||||||
|  |               xe | ||||||
|  |               lzma | ||||||
|  |             ]; | ||||||
|  |           }; | ||||||
|  |         } | ||||||
|  |       ); | ||||||
|  | 
 | ||||||
|  |       legacyPackages = packages; | ||||||
|  | 
 | ||||||
|  |       devShells = forAllSystems ( | ||||||
|  |         system: | ||||||
|  |         let | ||||||
|  |           pkgs = nixpkgs.legacyPackages."${system}"; | ||||||
|  |           rust-toolchain = pkgs.symlinkJoin { | ||||||
|  |             name = "rust-toolchain"; | ||||||
|  |             paths = with pkgs; [ | ||||||
|  |               (make-rust-toolchain-core pkgs) | ||||||
|  |               rustfmt | ||||||
|  |               clippy | ||||||
|  |               cargo-expand | ||||||
|  |               cargo-tarpaulin | ||||||
|  |               gcc | ||||||
|  |               gnumake | ||||||
|  |               dotnet-sdk_8 | ||||||
|  |             ]; | ||||||
|  |           }; | ||||||
|  |         in | ||||||
|  |         { | ||||||
|  |           default = pkgs.mkShell rec { | ||||||
|  |             inputsFrom = [ self.packages.${system}.servicepoint ]; | ||||||
|  |             packages = [ rust-toolchain ]; | ||||||
|  |             LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (builtins.concatMap (d: d.buildInputs) inputsFrom)}"; | ||||||
|  |             RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; | ||||||
|  |           }; | ||||||
|  |         } | ||||||
|  |       ); | ||||||
|  | 
 | ||||||
|  |       formatter = forAllSystems (system: nixpkgs.legacyPackages."${system}".nixfmt-rfc-style); | ||||||
|  |     }; | ||||||
|  | } | ||||||
							
								
								
									
										24
									
								
								shell.nix
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								shell.nix
									
										
									
									
									
								
							|  | @ -1,24 +0,0 @@ | ||||||
| {pkgs ? import <nixpkgs> {}}: let |  | ||||||
|   rust-toolchain = pkgs.symlinkJoin { |  | ||||||
|     name = "rust-toolchain"; |  | ||||||
|     paths = with pkgs; [rustc cargo rustPlatform.rustcSrc rustfmt clippy]; |  | ||||||
|   }; |  | ||||||
| in |  | ||||||
|   pkgs.mkShell { |  | ||||||
|     nativeBuildInputs = with pkgs.buildPackages; [ |  | ||||||
|       rust-toolchain |  | ||||||
| 
 |  | ||||||
|       pkg-config |  | ||||||
|       xe |  | ||||||
|       lzma |  | ||||||
| 
 |  | ||||||
|       cargo-tarpaulin |  | ||||||
| 
 |  | ||||||
|       gcc |  | ||||||
|       gnumake |  | ||||||
| 
 |  | ||||||
|       # dotnet-sdk_8 |  | ||||||
|     ]; |  | ||||||
| 
 |  | ||||||
|     RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; |  | ||||||
|   } |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter