From 56ea48ff7820d0532e8e4acaf6fa59badce4965b Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Tue, 17 Jun 2025 10:59:01 +0300 Subject: Replaced manual mounting in .zshrc with better mounting using systemd --- .zshrc | 5 ---- hosts/configuration.nix | 2 +- modules/systemd.nix | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ modules/timers.nix | 68 -------------------------------------------- 4 files changed, 76 insertions(+), 74 deletions(-) create mode 100644 modules/systemd.nix delete mode 100644 modules/timers.nix diff --git a/.zshrc b/.zshrc index ef3a431..11315e3 100644 --- a/.zshrc +++ b/.zshrc @@ -120,11 +120,6 @@ if [ ! -f "$MARKER_FILE" ]; then # Start linkwarden (pushd $HOME/personal/linkwarden > /dev/null && docker compose up -d > /dev/null && popd) &>/dev/null - # Automatically mount windows drives - sudo mkdir -p /mnt/c /mnt/e - sudo ntfs-3g /dev/nvme1n1p4 /mnt/c - sudo ntfs-3g /dev/sda2 /mnt/e - touch "$MARKER_FILE" fi diff --git a/hosts/configuration.nix b/hosts/configuration.nix index aea0299..60f75bd 100644 --- a/hosts/configuration.nix +++ b/hosts/configuration.nix @@ -9,7 +9,7 @@ ../modules/development.nix ../modules/gaming.nix ../modules/secrets.nix - ../modules/timers.nix + ../modules/systemd.nix inputs.home-manager.nixosModules.default ]; diff --git a/modules/systemd.nix b/modules/systemd.nix new file mode 100644 index 0000000..8ea13db --- /dev/null +++ b/modules/systemd.nix @@ -0,0 +1,75 @@ +{ config, pkgs, ... }: { + + systemd.timers."git-auto-sync" = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnBootSec = "5m"; + OnUnitActiveSec = "5m"; + Unit = "git-auto-sync.service"; + }; + }; + + systemd.services."git-auto-sync" = { + script = "$HOME/scripts/git-auto-sync.sh"; + path = [ + pkgs.git + pkgs.gh + pkgs.keychain + pkgs.openssh + ]; + serviceConfig = { Type = "oneshot"; User = "kyren"; }; + }; + + ########################################################################### + + systemd.timers."k-sleep-tracker" = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnBootSec = "1m"; + OnUnitActiveSec = "1m"; + Unit = "k-sleep-tracker.service"; + }; + }; + + systemd.services."k-sleep-tracker" = { + script = "$HOME/projects/k/bin/k tracker sleep"; + serviceConfig = { Type = "oneshot"; User = "kyren"; }; + }; + + ########################################################################### + + systemd.timers."git-auto-mirror" = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnBootSec = "1m"; + OnUnitActiveSec = "5h"; + Unit = "git-auto-mirror.service"; + }; + }; + + sops.secrets.gitea-sync-token = { owner = "kyren"; }; + sops.secrets.github-mirror-token = { owner = "kyren"; }; + systemd.services."git-auto-mirror" = { + script = "python $HOME/scripts/gitea.py"; + path = [ + (pkgs.python312.withPackages (pypkgs: [ + pypkgs.matplotlib + pypkgs.pandas + pypkgs.pygithub + ])) + ]; + environment = { + GITEA_TOKEN_FILE = config.sops.secrets.gitea-sync-token.path; + GITHUB_TOKEN_FILE = config.sops.secrets.github-mirror-token.path; + }; + serviceConfig = { Type = "oneshot"; User = "kyren"; }; + }; + + ########################################################################### + + systemd.mounts = [ + { what = "/dev/nvme1n1p4"; where = "/mnt/c"; type = "ntfs"; options = "rw,noatime"; wantedBy = ["multi-user.target"]; } + { what = "/dev/sda2"; where = "/mnt/e"; type = "ntfs"; options = "rw,noatime"; wantedBy = ["multi-user.target"]; } + ]; + +} diff --git a/modules/timers.nix b/modules/timers.nix deleted file mode 100644 index 9c6f4a4..0000000 --- a/modules/timers.nix +++ /dev/null @@ -1,68 +0,0 @@ -{ config, pkgs, ... }: { - - systemd.timers."git-auto-sync" = { - wantedBy = [ "timers.target" ]; - timerConfig = { - OnBootSec = "5m"; - OnUnitActiveSec = "5m"; - Unit = "git-auto-sync.service"; - }; - }; - - systemd.services."git-auto-sync" = { - script = "$HOME/scripts/git-auto-sync.sh"; - path = [ - pkgs.git - pkgs.gh - pkgs.keychain - pkgs.openssh - ]; - serviceConfig = { Type = "oneshot"; User = "kyren"; }; - }; - - ########################################################################### - - systemd.timers."k-sleep-tracker" = { - wantedBy = [ "timers.target" ]; - timerConfig = { - OnBootSec = "1m"; - OnUnitActiveSec = "1m"; - Unit = "k-sleep-tracker.service"; - }; - }; - - systemd.services."k-sleep-tracker" = { - script = "$HOME/projects/k/bin/k tracker sleep"; - serviceConfig = { Type = "oneshot"; User = "kyren"; }; - }; - - ########################################################################### - - systemd.timers."git-auto-mirror" = { - wantedBy = [ "timers.target" ]; - timerConfig = { - OnBootSec = "1m"; - OnUnitActiveSec = "5h"; - Unit = "git-auto-mirror.service"; - }; - }; - - sops.secrets.gitea-sync-token = { owner = "kyren"; }; - sops.secrets.github-mirror-token = { owner = "kyren"; }; - systemd.services."git-auto-mirror" = { - script = "python $HOME/scripts/gitea.py"; - path = [ - (pkgs.python312.withPackages (pypkgs: [ - pypkgs.matplotlib - pypkgs.pandas - pypkgs.pygithub - ])) - ]; - environment = { - GITEA_TOKEN_FILE = config.sops.secrets.gitea-sync-token.path; - GITHUB_TOKEN_FILE = config.sops.secrets.github-mirror-token.path; - }; - serviceConfig = { Type = "oneshot"; User = "kyren"; }; - }; - -} -- cgit v1.3.1