Skip to content

Commit f75da4a

Browse files
committed
Add Nix flake based build
This commit allows building the project with the Nix package manager.
1 parent b3bed64 commit f75da4a

File tree

4 files changed

+305
-49
lines changed

4 files changed

+305
-49
lines changed

build.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,25 @@ fn main() {
3030
println!("cargo:rerun-if-changed=memory.x");
3131

3232
// Generate a file containing the firmware version
33-
let version_output = std::process::Command::new("git")
33+
let mut output;
34+
if let Ok(version_output) = std::process::Command::new("git")
3435
.current_dir(env::var_os("CARGO_MANIFEST_DIR").unwrap())
3536
.args(["describe", "--tags", "--dirty"])
3637
.output()
37-
.expect("running git-describe");
38-
39-
println!(
40-
"Version is {:?}",
41-
std::str::from_utf8(&version_output.stdout)
42-
);
43-
println!("Error is {:?}", std::str::from_utf8(&version_output.stderr));
44-
assert!(version_output.status.success());
45-
46-
// Remove the trailing newline
47-
let mut output = version_output.stdout;
48-
output.pop();
38+
{
39+
println!(
40+
"Version is {:?}",
41+
std::str::from_utf8(&version_output.stdout)
42+
);
43+
println!("Error is {:?}", std::str::from_utf8(&version_output.stderr));
44+
assert!(version_output.status.success());
45+
46+
// Remove the trailing newline
47+
output = version_output.stdout;
48+
output.pop();
49+
} else {
50+
output = String::from(env!("CARGO_PKG_VERSION")).into_bytes();
51+
}
4952

5053
// Add a null
5154
output.push(0);

flake.lock

Lines changed: 199 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)