forked from toon/blackknobs
flake.nix: build package with naersk
This commit is contained in:
parent
30052f54ab
commit
1d150c310a
|
@ -439,6 +439,8 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stm32f1xx-hal"
|
name = "stm32f1xx-hal"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "30845662b9ce46a2ec04da97666a2b32458bee5032bb0452d0caf1536a96a542"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"bxcan",
|
"bxcan",
|
||||||
|
|
|
@ -20,6 +20,5 @@ embedded-midi = "0.1.2"
|
||||||
|
|
||||||
# hardware abstraction layer
|
# hardware abstraction layer
|
||||||
[dependencies.stm32f1xx-hal]
|
[dependencies.stm32f1xx-hal]
|
||||||
path = "../stm32f1xx-hal"
|
version = "0.10.0"
|
||||||
#version = "0.10.0"
|
|
||||||
features = [ "rt", "stm32f103", "medium" ]
|
features = [ "rt", "stm32f103", "medium" ]
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
use std::env;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// Put the linker script somewhere the linker can find it
|
||||||
|
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
|
File::create(out.join("memory.x"))
|
||||||
|
.unwrap()
|
||||||
|
.write_all(include_bytes!("memory.x"))
|
||||||
|
.unwrap();
|
||||||
|
println!("cargo:rustc-link-search={}", out.display());
|
||||||
|
|
||||||
|
// Only re-run the build script when memory.x is changed,
|
||||||
|
// instead of when any part of the source code changes.
|
||||||
|
println!("cargo:rerun-if-changed=memory.x");
|
||||||
|
}
|
38
flake.lock
38
flake.lock
|
@ -18,7 +18,38 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"naersk": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1698420672,
|
||||||
|
"narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "naersk",
|
||||||
|
"rev": "aeb58d5e8faead8980a807c840232697982d47b9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "naersk",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1708440434,
|
||||||
|
"narHash": "sha256-XY+B9mbhL/i+Q6fP6gBQ6P76rv9rWtpjQiUJ+DGtaUg=",
|
||||||
|
"path": "/nix/store/bjjfp9f2342bim734yyy498gvwxi301i-source",
|
||||||
|
"rev": "526d051b128b82ae045a70e5ff1adf8e6dafa560",
|
||||||
|
"type": "path"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1699099776,
|
"lastModified": 1699099776,
|
||||||
"narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=",
|
"narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=",
|
||||||
|
@ -34,7 +65,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681358109,
|
"lastModified": 1681358109,
|
||||||
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
|
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
|
||||||
|
@ -52,7 +83,8 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs",
|
"naersk": "naersk",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
"rust-overlay": "rust-overlay",
|
"rust-overlay": "rust-overlay",
|
||||||
"utils": "utils"
|
"utils": "utils"
|
||||||
}
|
}
|
||||||
|
@ -60,7 +92,7 @@
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_3"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1699323235,
|
"lastModified": 1699323235,
|
||||||
|
|
24
flake.nix
24
flake.nix
|
@ -5,10 +5,11 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
naersk.url = "github:nix-community/naersk";
|
||||||
utils.url = "github:numtide/flake-utils";
|
utils.url = "github:numtide/flake-utils";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, utils, rust-overlay }:
|
outputs = { self, nixpkgs, utils, rust-overlay, naersk }:
|
||||||
let
|
let
|
||||||
name = "stm32-rust-nixos-template";
|
name = "stm32-rust-nixos-template";
|
||||||
in
|
in
|
||||||
|
@ -44,17 +45,28 @@
|
||||||
--add-flags "${pkgs.lib.escapeShellArgs openOcdFlags}"
|
--add-flags "${pkgs.lib.escapeShellArgs openOcdFlags}"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
rustToolchain = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml);
|
||||||
|
naersk' = pkgs.callPackage naersk {
|
||||||
|
cargo = rustToolchain;
|
||||||
|
rustc = rustToolchain;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
devShells.default = with pkgs; mkShell {
|
devShells.default = with pkgs; mkShell {
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
|
rustToolchain
|
||||||
cargo-binutils
|
cargo-binutils
|
||||||
gdb
|
gdb
|
||||||
openocd
|
openocd
|
||||||
openocd-f1
|
openocd-f1
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
packages.blackknobs = naersk'.buildPackage {
|
||||||
|
src = ./.;
|
||||||
|
};
|
||||||
|
|
||||||
|
checks = packages;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue