devenv & fingies
This commit is contained in:
parent
2b170dbae4
commit
14b14f7842
9 changed files with 174 additions and 105 deletions
19
extras/fprintclear.py
Executable file
19
extras/fprintclear.py
Executable file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env -S nix-shell -p gobject-introspection libfprint gusb 'python3.withPackages (p: with p; [pygobject3])' --run python3
|
||||||
|
|
||||||
|
import gi
|
||||||
|
gi.require_version('FPrint', '2.0')
|
||||||
|
from gi.repository import FPrint
|
||||||
|
|
||||||
|
ctx = FPrint.Context()
|
||||||
|
|
||||||
|
for dev in ctx.get_devices():
|
||||||
|
print(dev)
|
||||||
|
print(dev.get_driver())
|
||||||
|
print(dev.props.device_id);
|
||||||
|
|
||||||
|
dev.open_sync()
|
||||||
|
|
||||||
|
dev.clear_storage_sync()
|
||||||
|
print("All prints deleted.")
|
||||||
|
|
||||||
|
dev.close_sync()
|
||||||
94
flake.lock
generated
94
flake.lock
generated
|
|
@ -21,21 +21,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"crane": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1727974419,
|
|
||||||
"narHash": "sha256-WD0//20h+2/yPGkO88d2nYbb23WMWYvnRyDQ9Dx4UHg=",
|
|
||||||
"owner": "ipetkov",
|
|
||||||
"repo": "crane",
|
|
||||||
"rev": "37e4f9f0976cb9281cd3f0c70081e5e0ecaee93f",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "ipetkov",
|
|
||||||
"repo": "crane",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"determinate": {
|
"determinate": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"determinate-nixd-aarch64-darwin": "determinate-nixd-aarch64-darwin",
|
"determinate-nixd-aarch64-darwin": "determinate-nixd-aarch64-darwin",
|
||||||
|
|
@ -172,24 +157,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1726560853,
|
|
||||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"git-hooks-nix": {
|
"git-hooks-nix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": [
|
"flake-compat": [
|
||||||
|
|
@ -229,30 +196,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"helix": {
|
|
||||||
"inputs": {
|
|
||||||
"crane": "crane",
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"rust-overlay": "rust-overlay"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1736619243,
|
|
||||||
"narHash": "sha256-o+LmzQToDudSGrB1U7MaYrwt7soc+TLNV7rKtlitgN4=",
|
|
||||||
"owner": "mattwparas",
|
|
||||||
"repo": "helix",
|
|
||||||
"rev": "a9d5557a3b3c11767432bdacd36ccb3bea02bfa5",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "mattwparas",
|
|
||||||
"ref": "steel-event-system",
|
|
||||||
"repo": "helix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"home-manager": {
|
"home-manager": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
|
@ -529,7 +472,6 @@
|
||||||
"agenix": "agenix",
|
"agenix": "agenix",
|
||||||
"determinate": "determinate",
|
"determinate": "determinate",
|
||||||
"disko": "disko",
|
"disko": "disko",
|
||||||
"helix": "helix",
|
|
||||||
"home-manager": "home-manager_2",
|
"home-manager": "home-manager_2",
|
||||||
"nixos": "nixos",
|
"nixos": "nixos",
|
||||||
"nixos-cosmic": "nixos-cosmic",
|
"nixos-cosmic": "nixos-cosmic",
|
||||||
|
|
@ -539,27 +481,6 @@
|
||||||
"zen-browser": "zen-browser"
|
"zen-browser": "zen-browser"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"helix",
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1728268235,
|
|
||||||
"narHash": "sha256-lJMFnMO4maJuNO6PQ5fZesrTmglze3UFTTBuKGwR1Nw=",
|
|
||||||
"owner": "oxalica",
|
|
||||||
"repo": "rust-overlay",
|
|
||||||
"rev": "25685cc2c7054efc31351c172ae77b21814f2d42",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "oxalica",
|
|
||||||
"repo": "rust-overlay",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1681028828,
|
||||||
|
|
@ -575,21 +496,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"zen-browser": {
|
"zen-browser": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@
|
||||||
# url = "github:pjones/plasma-manager";
|
# url = "github:pjones/plasma-manager";
|
||||||
# inputs.nixpkgs.follows = "nixpkgs";
|
# inputs.nixpkgs.follows = "nixpkgs";
|
||||||
# };
|
# };
|
||||||
helix = {
|
# helix = {
|
||||||
url = "github:mattwparas/helix/steel-event-system";
|
# url = "github:mattwparas/helix/steel-event-system";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
# inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
# };
|
||||||
nixos-cosmic = {
|
nixos-cosmic = {
|
||||||
url = "github:lilyinstarlight/nixos-cosmic";
|
url = "github:lilyinstarlight/nixos-cosmic";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
|
||||||
|
|
@ -180,9 +180,6 @@
|
||||||
};
|
};
|
||||||
nixpkgs.config = {allowUnfree = true;};
|
nixpkgs.config = {allowUnfree = true;};
|
||||||
nix.nixPath = ["nixpkgs=${pkgs.path}"];
|
nix.nixPath = ["nixpkgs=${pkgs.path}"];
|
||||||
nix.extraOptions = ''
|
|
||||||
trusted-users = root tao
|
|
||||||
'';
|
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
system.stateVersion = lib.mkDefault "23.05";
|
system.stateVersion = lib.mkDefault "23.05";
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ in {
|
||||||
source = ./autostart;
|
source = ./autostart;
|
||||||
recursive = true;
|
recursive = true;
|
||||||
};
|
};
|
||||||
home.file.".config/direnv/lib/uv.sh".source = ./uv.sh;
|
home.file.".config/direnv/lib/uv.sh".source = ./direnv/uv.sh;
|
||||||
|
home.file.".config/direnv/lib/devenv.sh".source = ./direnv/devenv.sh;
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
bacon = {
|
bacon = {
|
||||||
|
|
|
||||||
146
users/tao/direnv/devenv.sh
Normal file
146
users/tao/direnv/devenv.sh
Normal file
|
|
@ -0,0 +1,146 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
# adapted from https://github.com/nix-community/nix-direnv/blob/master/direnvrc
|
||||||
|
|
||||||
|
REQUIRED_DIRENV_VERSION="2.21.3"
|
||||||
|
|
||||||
|
_nix_direnv_preflight () {
|
||||||
|
if [[ -z "$direnv" ]]; then
|
||||||
|
printf '%s\n' "\$direnv environment variable was not defined. Was this script run inside direnv?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z ${DEVENV_BIN:-} ]]; then
|
||||||
|
DEVENV_BIN=$(command -v devenv)
|
||||||
|
if [[ -z "${DEVENV_BIN}" ]]; then
|
||||||
|
log_error "command not found: devenv, see https://devenv.sh/getting-started/"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! has direnv_version || ! direnv_version "$REQUIRED_DIRENV_VERSION" 2>/dev/null; then
|
||||||
|
log_error "base direnv version is older than the required v$REQUIRED_DIRENV_VERSION."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local layout_dir
|
||||||
|
layout_dir=$(direnv_layout_dir)
|
||||||
|
|
||||||
|
if [[ ! -d "$layout_dir" ]]; then
|
||||||
|
mkdir -p "$layout_dir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export DEVENV_DIRENVRC_VERSION=1
|
||||||
|
export DEVENV_DIRENVRC_ROLLING_UPGRADE=1
|
||||||
|
}
|
||||||
|
|
||||||
|
_nix_export_or_unset() {
|
||||||
|
local key=$1 value=$2
|
||||||
|
if [[ "$value" == __UNSET__ ]]; then
|
||||||
|
unset "$key"
|
||||||
|
else
|
||||||
|
export "$key=$value"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_nix_import_env() {
|
||||||
|
local env=$1
|
||||||
|
|
||||||
|
# Note which environments are active, but make sure we don't repeat them
|
||||||
|
if [[ ! "''${DIRENV_ACTIVE-}" =~ (^|:)"$PWD"(:|$) ]]; then
|
||||||
|
export DIRENV_ACTIVE="$PWD:''${DIRENV_ACTIVE-}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local old_nix_build_top=${NIX_BUILD_TOP:-__UNSET__}
|
||||||
|
local old_tmp=${TMP:-__UNSET__}
|
||||||
|
local old_tmpdir=${TMPDIR:-__UNSET__}
|
||||||
|
local old_temp=${TEMP:-__UNSET__}
|
||||||
|
local old_tempdir=${TEMPDIR:-__UNSET__}
|
||||||
|
local old_xdg_data_dirs=${XDG_DATA_DIRS:-}
|
||||||
|
eval "$env"
|
||||||
|
# `nix print-dev-env` will create a temporary directory and use it as TMPDIR
|
||||||
|
# We cannot rely on this directory being available at all times,
|
||||||
|
# as it may be garbage collected.
|
||||||
|
# Instead - just remove it immediately.
|
||||||
|
# Use recursive & force as it may not be empty.
|
||||||
|
if [[ -n "${NIX_BUILD_TOP+x}" && "$NIX_BUILD_TOP" == */nix-shell.* && -d "$NIX_BUILD_TOP" ]]; then
|
||||||
|
rm -rf "$NIX_BUILD_TOP"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_nix_export_or_unset NIX_BUILD_TOP "$old_nix_build_top"
|
||||||
|
_nix_export_or_unset TMP "$old_tmp"
|
||||||
|
_nix_export_or_unset TMPDIR "$old_tmpdir"
|
||||||
|
_nix_export_or_unset TEMP "$old_temp"
|
||||||
|
_nix_export_or_unset TEMPDIR "$old_tempdir"
|
||||||
|
local new_xdg_data_dirs=${XDG_DATA_DIRS:-}
|
||||||
|
export XDG_DATA_DIRS=
|
||||||
|
local IFS=:
|
||||||
|
for dir in $new_xdg_data_dirs${old_xdg_data_dirs:+:}$old_xdg_data_dirs; do
|
||||||
|
dir="${dir%/}" # remove trailing slashes
|
||||||
|
if [[ :$XDG_DATA_DIRS: = *:$dir:* ]]; then
|
||||||
|
continue # already present, skip
|
||||||
|
fi
|
||||||
|
XDG_DATA_DIRS="$XDG_DATA_DIRS${XDG_DATA_DIRS:+:}$dir"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
nix_direnv_watch_file() {
|
||||||
|
log_error "nix_direnv_watch_file is deprecated. Use watch_file instead."
|
||||||
|
watch_file "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_devenv_watches() {
|
||||||
|
local path=$1
|
||||||
|
local -n _watches=$2
|
||||||
|
if [[ -f "$path" ]]; then
|
||||||
|
while IFS= read -r file; do
|
||||||
|
file=$(printf "$file")
|
||||||
|
_watches+=("$file")
|
||||||
|
done < "$path"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
use_devenv() {
|
||||||
|
_nix_direnv_preflight
|
||||||
|
|
||||||
|
flake_expr="${1:-.}"
|
||||||
|
flake_dir="${flake_expr%#*}"
|
||||||
|
env_deps_path="$flake_dir/.devenv/input-paths.txt"
|
||||||
|
|
||||||
|
local default_watches
|
||||||
|
default_watches=(".envrc" "$HOME/.direnvrc" "$HOME/.config/direnv/direnvrc")
|
||||||
|
|
||||||
|
if [[ -d "$flake_dir" ]]; then
|
||||||
|
default_watches+=("$flake_dir/devenv.nix" "$flake_dir/devenv.lock" "$flake_dir/devenv.yaml" "$flake_dir/devenv.local.nix")
|
||||||
|
|
||||||
|
if [[ -f "$flake_dir/devenv.yaml" ]]; then
|
||||||
|
if ! devenv assemble; then
|
||||||
|
log_error "$(devenv version) failed to parse devenv.yaml, make sure to use version 0.6 or newer and fix the errors above."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Watch the default files.
|
||||||
|
# Even if evaluation fails, these files should still trigger a reload.
|
||||||
|
watch_file "${default_watches[@]}"
|
||||||
|
|
||||||
|
# Fetch and watch files that affect the env
|
||||||
|
local env_watches
|
||||||
|
_devenv_watches "$env_deps_path" env_watches
|
||||||
|
watch_file "${env_watches[@]}"
|
||||||
|
|
||||||
|
# Build the environment
|
||||||
|
local env
|
||||||
|
if ! env=$("${DEVENV_BIN}" print-dev-env); then
|
||||||
|
log_error "failed to build the devenv environment. devenv.nix may contain errors. see above."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Re-watch files that affect the env
|
||||||
|
local env_watches
|
||||||
|
_devenv_watches "$env_deps_path" env_watches
|
||||||
|
watch_file "${env_watches[@]}"
|
||||||
|
|
||||||
|
# Import the environment
|
||||||
|
_nix_import_env "$env"
|
||||||
|
}
|
||||||
|
|
@ -242,6 +242,6 @@
|
||||||
};
|
};
|
||||||
enable = true;
|
enable = true;
|
||||||
defaultEditor = true;
|
defaultEditor = true;
|
||||||
package = inputs.helix.packages.${pkgs.system}.default;
|
# package = inputs.helix.packages.${pkgs.system}.default;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,9 +76,9 @@ def nr [package] {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($builders == "") {
|
if ($builders == "") {
|
||||||
sudo systemd-inhibit nice -n19 nixos-rebuild $subcommand --flake /home/tao/projects/NOflake/ --impure --verbose --builders ""
|
sudo systemd-inhibit nice -n19 nixos-rebuild $subcommand --flake . --impure --verbose --builders ""
|
||||||
} else {
|
} else {
|
||||||
sudo systemd-inhibit nice -n19 nixos-rebuild $subcommand --flake /home/tao/projects/NOflake/ --impure --verbose ...$rest
|
sudo systemd-inhibit nice -n19 nixos-rebuild $subcommand --flake . --impure --verbose ...$rest
|
||||||
}
|
}
|
||||||
toastify send rebuild done!
|
toastify send rebuild done!
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue