add examples to flake

This commit is contained in:
Vinzenz Schroeter 2024-11-10 01:06:55 +01:00
parent 3db1fb643f
commit 35f87eeed9
2 changed files with 53 additions and 56 deletions

View file

@ -20,21 +20,6 @@
"type": "github" "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1730963269, "lastModified": 1730963269,
@ -54,7 +39,6 @@
"root": { "root": {
"inputs": { "inputs": {
"naersk": "naersk", "naersk": "naersk",
"nix-filter": "nix-filter",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View file

@ -3,7 +3,6 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nix-filter.url = "github:numtide/nix-filter";
naersk = { naersk = {
url = "github:nix-community/naersk"; url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -15,7 +14,6 @@
self, self,
nixpkgs, nixpkgs,
naersk, naersk,
nix-filter,
}: }:
let let
lib = nixpkgs.lib; lib = nixpkgs.lib;
@ -47,46 +45,61 @@
cargo = rust-toolchain-core; cargo = rust-toolchain-core;
rustc = rust-toolchain-core; rustc = rust-toolchain-core;
}; };
source = nix-filter.lib.filter { nativeBuildInputs = with pkgs; [
root = ./.; pkg-config
include = [ makeWrapper
./Cargo.toml ];
./Cargo.lock buildInputs = with pkgs; [
./crates xe
./Web437_IBM_BIOS.woff lzma
./README.md ];
./LICENSE makeExample =
]; package: example:
}; naersk'.buildPackage {
pname = example;
cargoBuildOptions =
x:
x
++ [
"--package"
package
];
src = ./.;
nativeBuildInputs = nativeBuildInputs;
strictDeps = true;
buildInputs = buildInputs;
overrideMain = old: {
preConfigure = ''
cargo_build_options="$cargo_build_options --example ${example}"
'';
};
};
makePackage =
package:
let
package-param = [
"--package"
package
];
in
naersk'.buildPackage {
pname = package;
cargoBuildOptions = x: x ++ package-param;
cargoTestOptions = x: x ++ package-param;
src = ./.;
doCheck = true;
nativeBuildInputs = nativeBuildInputs;
strictDeps = true;
buildInputs = buildInputs;
};
in in
rec { rec {
servicepoint = naersk'.buildPackage rec { servicepoint = makePackage "servicepoint";
cargoBuildOptions = announce = makeExample "servicepoint" "announce";
x: game-of-life = makeExample "servicepoint" "game_of_life";
x moving-line = makeExample "servicepoint" "moving_line";
++ [ random-brightness = makeExample "servicepoint" "random_brightness";
"-p" wiping-clear = makeExample "servicepoint" "wiping_clear";
"servicepoint"
];
cargoTestOptions =
x:
x
++ [
"-p"
"servicepoint"
];
src = source;
doCheck = true;
nativeBuildInputs = with pkgs; [
pkg-config
makeWrapper
];
strictDeps = true;
buildInputs = with pkgs; [
xe
lzma
];
};
} }
); );