Compare commits
3 Commits
7f31369e78
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c5c185c5ab | |||
| b7417455aa | |||
| 98aa4691a3 |
7
.sops.yaml
Normal file
7
.sops.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
keys:
|
||||
- &primary age1xwmpq4ydrqmj8c9petpp9q5ujupdkd40puqqgpqvnuw23nckuupshrwcr9
|
||||
creation_rules:
|
||||
- path_regex: deploy.config.toml$
|
||||
key_groups:
|
||||
- age:
|
||||
- *primary
|
||||
43
Cargo.lock
generated
43
Cargo.lock
generated
@@ -2,6 +2,49 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "gpio-cdev"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09831ec59b80be69e75d29cf36e16afbbe5fd1af9c1bf4689ad91c77db5aa6a6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
"nix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.178"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.27.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snooze-pal"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"gpio-cdev",
|
||||
]
|
||||
|
||||
@@ -4,3 +4,4 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
gpio-cdev = "0.6.0"
|
||||
|
||||
15
deploy.config.toml.secret
Normal file
15
deploy.config.toml.secret
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"data": "ENC[AES256_GCM,data:ie0ngMYra78CNOa4uLqgnGRWfWZvKCnxrmz7nezgdi3HN2x2ooMFcW+oIq5aOVUOpBAXHAo9EuuexRWrVgObOXwtWfVw92C+,iv:FBTgA6hI6P8Ls6/zLFBSVb8/ZriqU1BBSMNh5X+4gjc=,tag:9WuvIuXvkGVFHHNZcDkV7w==,type:str]",
|
||||
"sops": {
|
||||
"age": [
|
||||
{
|
||||
"recipient": "age1xwmpq4ydrqmj8c9petpp9q5ujupdkd40puqqgpqvnuw23nckuupshrwcr9",
|
||||
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB6aWhUMUVYRlJRNmRIYmVn\nZjVrMThjblltYWxnRUZvUXQ0VjRFYXJod0dBCnZHelNMWTYxOE9CSEl0MTZ3RnM1\nT2R2U1Y5ZHZhU2NFWHEvU1UrcGc2Sm8KLS0tIForR1J4ZVJXeGRucGo5MWMweVpx\nQkxrOHorZFFJZkY3aTBOQi9YRzRtOVEK5n9IyDyvaXzrUVC8JnNLDM+GoGor3TQe\nQ7938OP9t2+gkrRpOBn+t2Bw5WhX0fSB2cmcq6xgQLuVnIdgLUh4yA==\n-----END AGE ENCRYPTED FILE-----\n"
|
||||
}
|
||||
],
|
||||
"lastmodified": "2025-11-26T20:53:52Z",
|
||||
"mac": "ENC[AES256_GCM,data:txZjdkP/2M92YrngT+nILsar316i0ILTjV9iJuE59mAqIXKsUMS+BEWwTfiwtz4pMvyJ5TEFVhvJ//pwFuoXkRUngZcs9wWy2xzCAGK0SA7TIA8nO1k1Qp1akbZX+dkcDUJRuk64LiR1Mnh0FbA1Eej2Fccve9ZAyKHFD4I57O4=,iv:phcTOg8GUY6mJwqE0WTbP0fUTYZNBgEeqvwilGVgnJY=,tag:U35RSlQ0AMy2T5yixGOAfw==,type:str]",
|
||||
"unencrypted_suffix": "_unencrypted",
|
||||
"version": "3.11.0"
|
||||
}
|
||||
}
|
||||
20
deploy.nu
Executable file
20
deploy.nu
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env nu
|
||||
|
||||
def main [] {
|
||||
main run
|
||||
}
|
||||
|
||||
def "main run" [] {
|
||||
let config = get-config
|
||||
nix build $".#($config | get target_platform)"
|
||||
scp result/bin/snooze-pal ($config | get target_machine):bin/snooze-pal
|
||||
ssh ($config | get target_machine) "chmod +rwx bin/snooze-pal && bin/snooze-pal"
|
||||
}
|
||||
|
||||
def get-config [] {
|
||||
if ('./deploy.config.toml.secret' | path exists) {
|
||||
return (sops decrypt deploy.config.toml.secret | from toml)
|
||||
} else {
|
||||
return (open deploy.config.toml)
|
||||
}
|
||||
}
|
||||
BIN
implohq-alarm
Executable file
BIN
implohq-alarm
Executable file
Binary file not shown.
32
src/main.rs
32
src/main.rs
@@ -1,6 +1,34 @@
|
||||
// This project is licensed under MIT Licese.
|
||||
// See the LICENSE folder for details.
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use std::thread;
|
||||
|
||||
use gpio_cdev::{Chip, LineRequestFlags};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut chip = Chip::new("/dev/gpiochip0")?;
|
||||
alarm(&mut chip)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn alarm(chip: &mut Chip) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let beeper = chip
|
||||
.get_line(17)?
|
||||
.request(LineRequestFlags::OUTPUT, 0, "my-gpio")?;
|
||||
|
||||
for _ in 0..5 {
|
||||
beeper.set_value(1)?;
|
||||
thread::sleep(std::time::Duration::from_secs(1));
|
||||
beeper.set_value(0)?;
|
||||
thread::sleep(std::time::Duration::from_secs(1));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn turn_off_led(chip: &mut Chip) -> Result<(), Box<dyn std::error::Error>> {
|
||||
chip.get_line(17)?
|
||||
.request(LineRequestFlags::OUTPUT, 0, "my-gpio")?
|
||||
.set_value(0)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user