Wanted to use agenix to encrypt rclone config. But to diffcult. Ended with a custom-mountkdrive which verifies the existence of the remote before launching

This commit is contained in:
Tomas Rivera
2026-02-27 16:53:50 +01:00
parent 8b1f877dd9
commit 30405baa2d
8 changed files with 45 additions and 78 deletions
Generated
+1 -73
View File
@@ -1,26 +1,5 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1769996383,
"narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "57928607ea566b5db3ad13af0e57e921e6b12381",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@@ -58,61 +37,10 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1770380644,
"narHash": "sha256-P7dWMHRUWG5m4G+06jDyThXO7kwSk46C1kgjEWcybkE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ae67888ff7ef9dff69b3cf0cc0fbfbcd3a722abe",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixvim": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_2",
"systems": "systems"
},
"locked": {
"lastModified": 1771135771,
"narHash": "sha256-wyvBIhDuyCRyjB3yPg77qoyxrlgQtBR1rVW3c9knV3E=",
"owner": "nix-community",
"repo": "nixvim",
"rev": "ed0424f0b08d303a7348f52f7850ad1b2704f9ba",
"type": "github"
},
"original": {
"id": "nixvim",
"type": "indirect"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nixvim": "nixvim"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
"nixpkgs": "nixpkgs"
}
}
},
+4 -4
View File
@@ -8,13 +8,13 @@
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# never got nixvim to wokrs. ):
# nixvim = {
# url = "github:nix-community/nixvim/nixos-25.11";
# };
};
outputs = { self, nixpkgs, home-manager, nixvim, ... }@inputs:
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
@@ -22,8 +22,8 @@
{
nixosConfigurations = {
laptop = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [
specialArgs = { inherit inputs;};
modules = [
./hosts/laptop/configuration.nix
];
};
-1
View File
@@ -9,7 +9,6 @@
[ # Include the results of the hardware scan.
./hardware-configuration.nix
inputs.home-manager.nixosModules.default
# inputs.nixvim.homeModules.default
];
+2
View File
@@ -16,6 +16,7 @@ imports = [
../../modules/home-manager/rofi.nix # launcher and keybindings helper
../../modules/home-manager/swaync.nix # notification daemon
../../modules/home-manager/neovim.nix # dont use nixvim. broken
../../modules/home-manager/rclone.nix
];
@@ -48,6 +49,7 @@ home.packages = [
(pkgs.callPackage ../../modules/scripts/weather.nix {})
(pkgs.callPackage ../../modules/scripts/cowsay.nix {})
(pkgs.callPackage ../../modules/scripts/wallpaper.nix {})
(pkgs.callPackage ../../modules/scripts/mountkdrive.nix {})
# # Adds the 'hello' command to your environment. It prints a friendly
# # "Hello, world!" when run.
# pkgs.hello
+1
View File
@@ -144,6 +144,7 @@ in
"swww img ${wallpaper}"
"swww-daemon"
"sleep 1 && custom-wallpaper"
"custom-mountkdrive"
];
# █░░ ▄▀█ █▄█ █▀█ █░█ ▀█▀ █▀
# █▄▄ █▀█ ░█░ █▄█ █▄█ ░█░ ▄█
+8
View File
@@ -0,0 +1,8 @@
{ config, pkgs, ... }:
{
programs.zoxide = {
enable = true;
enableZshIntegration = true;
};
}
+7
View File
@@ -0,0 +1,7 @@
{ config, pkgs, agenix, ... }:
{
programs.rclone = {
enable = true;
};
}
+22
View File
@@ -0,0 +1,22 @@
{ writeShellApplication, rclone, libnotify, ... }:
writeShellApplication {
name = "custom-mountkdrive";
runtimeInputs = [
rclone
libnotify
];
text = ''
REMOTE_NAME="kdrive"
MOUNT_POINT="$HOME/kdrive"
if rclone listremotes | rg "^''${REMOTE_NAME}:"; then
echo "Mounting ''${REMOTE_NAME}..."
rclone mount "''${REMOTE_NAME}:" "$MOUNT_POINT" --vfs-cache-mode writes &
else
notify-send "rclone mount failed" \
"Remote ''${REMOTE_NAME} not found.\nConfigure rclone and create the dir ~/kdrive/ or comment out the exec line in hyprland.nix."
echo "Remote ''${REMOTE_NAME} not found. Configure rclone or comment out the exec line in hyprland.nix."
fi
'';
}