From 82b0838f5cdda8d802cb29f33f98f926f32cda78 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 19 Jul 2024 11:26:32 +0100 Subject: [PATCH] Add get-notes in home-manager activation script --- .../common/optional/desktop/common/default.nix | 1 + home/common/optional/desktop/common/notes.nix | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 home/common/optional/desktop/common/notes.nix diff --git a/home/common/optional/desktop/common/default.nix b/home/common/optional/desktop/common/default.nix index b989fba..89f8571 100644 --- a/home/common/optional/desktop/common/default.nix +++ b/home/common/optional/desktop/common/default.nix @@ -4,6 +4,7 @@ ./alacritty.nix ./zotero.nix ./fontconfig.nix + ./notes.nix ]; # Global packages for desktop environments diff --git a/home/common/optional/desktop/common/notes.nix b/home/common/optional/desktop/common/notes.nix new file mode 100644 index 0000000..d855881 --- /dev/null +++ b/home/common/optional/desktop/common/notes.nix @@ -0,0 +1,18 @@ +{ pkgs, config, lib, ... }: +let + user = config.home.username; +in +{ + home.activation.get-notes = lib.hm.dag.entryAfter [ "installPackages" ] '' + notes_dir=/home/${user}/.local/share/notes + remote=git@git.bitlab21.com:sam/notes + if [ -d "$notes_dir" ]; + then + cd "$notes_dir" + [ ! -d .git ] && PATH="${pkgs.git}/bin:${pkgs.openssh}/bin:$PATH" git clone "$remote" "$notes_dir" + else + mkdir -p "$notes_dir" && PATH="${pkgs.git}/bin:${pkgs.openssh}/bin:$PATH" git clone "$remote" "$notes_dir" + fi + exit 0 + ''; +}