From 448053ae5dbecbf33c50d48e0acc131c32c3cc2d Mon Sep 17 00:00:00 2001 From: Cy Pokhrel Date: Sat, 30 Nov 2024 20:24:04 -0500 Subject: [PATCH] use ntfy for backup notifications override anki (successfully this time) install evolution and nix-index use home-manager to configure gtk and qt theme and update a bunch of stuff --- nix/anki.nix | 135 +++++++++++++++++++++++++++++++++++++++ nix/configuration.nix | 32 +++++++--- nix/flake.lock | 27 +++++++- nix/flake.nix | 13 +++- nix/home.nix | 31 +++++++++ nix/secrets/secrets.yaml | 5 +- 6 files changed, 229 insertions(+), 14 deletions(-) create mode 100644 nix/anki.nix create mode 100644 nix/home.nix diff --git a/nix/anki.nix b/nix/anki.nix new file mode 100644 index 0000000..02e4272 --- /dev/null +++ b/nix/anki.nix @@ -0,0 +1,135 @@ +{ + fetchurl, + stdenv, + lib, + buildFHSEnv, + appimageTools, + writeShellScript, + anki, + undmg, + zstd, + cacert, + commandLineArgs ? [ ], +}: + +let + pname = "anki-bin"; + # Update hashes for both Linux and Darwin! + version = "24.11"; + + sources = { + linux = fetchurl { + url = "https://github.com/ankitects/anki/releases/download/${version}/anki-${version}-linux-qt6.tar.zst"; + hash = "sha256-JXn4oxhRODHh6b5hFFj393xMRlaJRVcbMJ5AyXr+jq8="; + }; + + # For some reason anki distributes completely separate dmg-files for the aarch64 version and the x86_64 version + darwin-x86_64 = fetchurl { + url = "https://github.com/ankitects/anki/releases/download/${version}/anki-${version}-mac-intel-qt6.dmg"; + hash = "sha256-UQRdp/GhiRGfsBF+mV6hCKpEQGFv/I9D9KTtc1p776o="; + }; + darwin-aarch64 = fetchurl { + url = "https://github.com/ankitects/anki/releases/download/${version}/anki-${version}-mac-apple-qt6.dmg"; + hash = "sha256-zi9yjJirNxFFD7wGa4++J+mDaE5dYZW+X0UUddGkjTU="; + }; + }; + + unpacked = stdenv.mkDerivation { + inherit pname version; + + nativeBuildInputs = [ zstd ]; + src = sources.linux; + + installPhase = '' + runHook preInstall + + xdg-mime () { + echo Stubbed! + } + export -f xdg-mime + + PREFIX=$out bash install.sh + + runHook postInstall + ''; + }; + + meta = with lib; { + inherit (anki.meta) + license + homepage + description + mainProgram + longDescription + ; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + maintainers = with maintainers; [ mahmoudk1000 ]; + }; + + passthru = { + inherit sources; + }; + + fhsEnvAnki = buildFHSEnv ( + appimageTools.defaultFhsEnvArgs + // { + inherit pname version; + + profile = '' + # anki vendors QT and mixing QT versions usually causes crashes + unset QT_PLUGIN_PATH + # anki uses the system ssl cert, without it plugins do not download/update + export SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt" + ''; + + # Dependencies of anki + targetPkgs = + pkgs: + (with pkgs; [ + xorg.libxkbfile + xcb-util-cursor-HEAD + krb5 + zstd + ]); + + runScript = writeShellScript "anki-wrapper.sh" '' + exec ${unpacked}/bin/anki ${lib.strings.escapeShellArgs commandLineArgs} "$@" + ''; + + extraInstallCommands = '' + ln -s ${pname} $out/bin/anki + + mkdir -p $out/share + cp -R ${unpacked}/share/applications \ + ${unpacked}/share/man \ + ${unpacked}/share/pixmaps \ + $out/share/ + ''; + + inherit meta passthru; + } + ); +in + +if stdenv.hostPlatform.isLinux then + fhsEnvAnki +else + stdenv.mkDerivation { + inherit pname version passthru; + + src = if stdenv.hostPlatform.isAarch64 then sources.darwin-aarch64 else sources.darwin-x86_64; + + nativeBuildInputs = [ undmg ]; + sourceRoot = "."; + + installPhase = '' + mkdir -p $out/Applications/ + cp -a Anki.app $out/Applications/ + ''; + + inherit meta; + } diff --git a/nix/configuration.nix b/nix/configuration.nix index c34243a..ed652d5 100644 --- a/nix/configuration.nix +++ b/nix/configuration.nix @@ -13,6 +13,7 @@ "borg/yt" = { }; "restic/azure-yt" = { }; "azure" = { }; + "ntfy" = { }; }; boot = { @@ -119,13 +120,10 @@ llvmPackages_19.clang-tools ghc hyprpaper + zola + calibre - (anki-bin.overrideAttrs { - src = pkgs.fetchurl { - url = "https://github.com/ankitects/anki/releases/download/24.11rc2/anki-24.11-linux-qt6.tar.zst"; - hash = "sha256-JXn4oxhRODHh6b5hFFj393xMRlaJRVcbMJ5AyXr+jq8="; - }; - }) + (pkgs.callPackage ./anki.nix {}) ]; }; @@ -177,7 +175,7 @@ # security.sudo.wheelNeedsPassword = false; fonts.packages = with pkgs; [ - nerdfonts + nerd-fonts.roboto-mono ]; nixpkgs.config = { allowUnfree = true; @@ -230,6 +228,11 @@ extraCreateArgs = [ "--stats" ]; # warnings are often not that serious failOnWarnings = false; + postHook = '' + ${pkgs.curl}/bin/curl -u $(cat /run/secrets/ntfy) -d "ytnixRsync: backup completed with exit code: $exitStatus + $(journalctl -u borgbackup-job-ytnixRsync.service|tail -n 5)" \ + https://ntfy.cything.io/chunk + ''; }; services.restic.backups.ytazure = { @@ -262,6 +265,11 @@ }; vendorHash = "sha256-TstuI6KgAFEQH90PCZMN6s4dUab2GyPKqOtqMfIV8wA="; }; + backupCleanupCommand = '' + ${pkgs.curl}/bin/curl -u $(cat /run/secrets/ntfy) -d "ytazure: backup completed with exit code: $exitStatus + $(journalctl -u restic-backups-ytazure.service|tail -n 5)" \ + https://ntfy.cything.io/chunk + ''; }; services.btrbk.instances.local = { @@ -337,6 +345,14 @@ }; services.usbmuxd.enable = true; - programs.nix-ld.enable = true; + programs.evolution.enable = true; + + # this is true by default and mutually exclusive with + # programs.nix-index + programs.command-not-found.enable = false; + programs.nix-index = { + enable = true; + enableZshIntegration = true; + }; } diff --git a/nix/flake.lock b/nix/flake.lock index 160d333..d6fce1b 100644 --- a/nix/flake.lock +++ b/nix/flake.lock @@ -1,12 +1,32 @@ { "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1732884235, + "narHash": "sha256-r8j6R3nrvwbT1aUp4EPQ1KC7gm0pu9VcV1aNaB+XG6Q=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "819f682269f4e002884702b87e445c82840c68f2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1732521221, - "narHash": "sha256-2ThgXBUXAE1oFsVATK1ZX9IjPcS4nKFOAjhPNKuiMn0=", + "lastModified": 1732837521, + "narHash": "sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4633a7c72337ea8fd23a4f2ba3972865e3ec685d", + "rev": "970e93b9f82e2a0f3675757eb0bfc73297cc6370", "type": "github" }, "original": { @@ -17,6 +37,7 @@ }, "root": { "inputs": { + "home-manager": "home-manager", "nixpkgs": "nixpkgs", "sops-nix": "sops-nix" } diff --git a/nix/flake.nix b/nix/flake.nix index f01f7b7..913b643 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -7,9 +7,13 @@ url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, sops-nix, ... }@inputs: + outputs = { self, nixpkgs, sops-nix, home-manager, ... }@inputs: let lib = nixpkgs.lib; in { @@ -19,6 +23,13 @@ modules = [ ./configuration.nix sops-nix.nixosModules.sops + home-manager.nixosModules.home-manager { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.yt = import ./home.nix; + }; + } ]; }; }; diff --git a/nix/home.nix b/nix/home.nix new file mode 100644 index 0000000..32c5dc2 --- /dev/null +++ b/nix/home.nix @@ -0,0 +1,31 @@ +{ config, pkgs, ... }: + +{ + home.username = "yt"; + home.homeDirectory = "/home/yt"; + home.stateVersion = "24.05"; + programs.home-manager.enable = true; + + qt = { + enable = true; + platformTheme.name = "gtk"; + style.name = "adwaita-dark"; + style.package = pkgs.adwaita-qt; + }; + + gtk = { + enable = true; + cursorTheme = { + package = pkgs.bibata-cursors; + name = "Bibata-Modern"; + }; + theme = { + package = pkgs.adw-gtk3; + name = "adw-gtk3-dark"; + }; + iconTheme = { + package = pkgs.adwaita-icon-theme; + name = "Adwaita"; + }; + }; +} diff --git a/nix/secrets/secrets.yaml b/nix/secrets/secrets.yaml index b606ea7..a1cc4b2 100644 --- a/nix/secrets/secrets.yaml +++ b/nix/secrets/secrets.yaml @@ -3,6 +3,7 @@ borg: restic: azure-yt: ENC[AES256_GCM,data:s8TJ5cNVW2Jr7kyul8mrBGwdLoTlNTb2MfpZgPU=,iv:sC0DbgFbFl6vvLqwOFDwRa3nabrIWxOTuz7GXn17IHk=,tag:2MYprYgNhh1aFlzuyw5eGQ==,type:str] azure: ENC[AES256_GCM,data:UdHmasRElCFC66dxnnGTOw6vgOzrOIMiSLsczK0Qew2WBdZUKVnRTfSCxQrB7P8k+j3N2CDt5Y4GXvf9GVFrWCMOInOqYXcyycGXsdli2DbqpXTa3f13ykvc/aoKyw3YuFQdrNci3Kae9PYZ4v5f7fH8n4WgOKuYj3mO9k7WHxM1JBzYRRZP41Jghnb9SqVhl9UXVPI5ONBd6JI/FiezSMZPYC2FxNgQ7zHUQJ7qQ6aJTgRljslJK9I=,iv:bRoYEA1hbEXRG7PoU7Dfba9uRu3cAqfeuvSIfavZZ8M=,tag:cHXUe/njZNoG6EuHYYz0Yg==,type:str] +ntfy: ENC[AES256_GCM,data:ZfTVhdzA1+L3B+g7tw==,iv:1dXDqYi5/zBQ9iphzjn/GHGDcl90J1NYHvHQpTsVPlg=,tag:RfB1/Zz9ITJQV89cuk9OcQ==,type:str] sops: kms: [] gcp_kms: [] @@ -18,8 +19,8 @@ sops: a1MwYjB0Tm03bzJnWTdoZ01KbXBPUkUKUr6hOsdZDJK6bFyEnBf4Vkms8EJsIvZY ML481g9d9Vlm5x7X74nUcWemFSzttSdWEM3Y/IOHpXDbvC/Tbw+z7Q== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-11-24T08:24:07Z" - mac: ENC[AES256_GCM,data:W9K3+AERYBzRU0gvy50MbRULXGNyM6iujxdonSNbkoyoO6IBoGkMF+509jvoxrVFjEdiy7OZnj86O8XwAQDH3MLYSxpaUiJyQ8W3oQLdeJSk+cWVmBGSO5nXSjMGjU0jzKs2SH8SZKJXyOdDd3tmVTxTLk9u43fAi3AB4Iq/c8Q=,iv:5ETuAuMNpbxNYJLSLQ/J7A4Ov+laTkfNtNy8f5HSi0Y=,tag:1Dnnx5jv6v9ok7T59FX26w==,type:str] + lastmodified: "2024-12-01T00:51:59Z" + mac: ENC[AES256_GCM,data:TYyfVAAxiScRb/KAwqaglr5OjYAfb6uPb3Tdwum1rN09NLzmr8T4W3PramKCgGdTemtjl5YYpBT2lRnKfsNMpzLwg3JHsLV/6JvzCMAHuVPzHHG4SfbAlEz1uLH1/UopxW1w2RAMKK8do9+aXviL/nmXT6gbHgIVCI07U3006Lw=,iv:gyYePlF0MBSU6yhLieV/q8Gw/LbSaZWD7ghAaTLWQmk=,tag:P1L0FaTCmxeFYM6tdzhJBA==,type:str] pgp: [] unencrypted_suffix: _unencrypted version: 3.9.1