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
This commit is contained in:
Cy Pokhrel 2024-11-30 20:24:04 -05:00
parent c3f9664a82
commit 448053ae5d
6 changed files with 229 additions and 14 deletions

135
nix/anki.nix Normal file
View file

@ -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;
}

View file

@ -13,6 +13,7 @@
"borg/yt" = { }; "borg/yt" = { };
"restic/azure-yt" = { }; "restic/azure-yt" = { };
"azure" = { }; "azure" = { };
"ntfy" = { };
}; };
boot = { boot = {
@ -119,13 +120,10 @@
llvmPackages_19.clang-tools llvmPackages_19.clang-tools
ghc ghc
hyprpaper hyprpaper
zola
calibre
(anki-bin.overrideAttrs { (pkgs.callPackage ./anki.nix {})
src = pkgs.fetchurl {
url = "https://github.com/ankitects/anki/releases/download/24.11rc2/anki-24.11-linux-qt6.tar.zst";
hash = "sha256-JXn4oxhRODHh6b5hFFj393xMRlaJRVcbMJ5AyXr+jq8=";
};
})
]; ];
}; };
@ -177,7 +175,7 @@
# security.sudo.wheelNeedsPassword = false; # security.sudo.wheelNeedsPassword = false;
fonts.packages = with pkgs; [ fonts.packages = with pkgs; [
nerdfonts nerd-fonts.roboto-mono
]; ];
nixpkgs.config = { nixpkgs.config = {
allowUnfree = true; allowUnfree = true;
@ -230,6 +228,11 @@
extraCreateArgs = [ "--stats" ]; extraCreateArgs = [ "--stats" ];
# warnings are often not that serious # warnings are often not that serious
failOnWarnings = false; 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 = { services.restic.backups.ytazure = {
@ -262,6 +265,11 @@
}; };
vendorHash = "sha256-TstuI6KgAFEQH90PCZMN6s4dUab2GyPKqOtqMfIV8wA="; 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 = { services.btrbk.instances.local = {
@ -337,6 +345,14 @@
}; };
services.usbmuxd.enable = true; services.usbmuxd.enable = true;
programs.nix-ld.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;
};
} }

27
nix/flake.lock generated
View file

@ -1,12 +1,32 @@
{ {
"nodes": { "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1732521221, "lastModified": 1732837521,
"narHash": "sha256-2ThgXBUXAE1oFsVATK1ZX9IjPcS4nKFOAjhPNKuiMn0=", "narHash": "sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "4633a7c72337ea8fd23a4f2ba3972865e3ec685d", "rev": "970e93b9f82e2a0f3675757eb0bfc73297cc6370",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -17,6 +37,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"sops-nix": "sops-nix" "sops-nix": "sops-nix"
} }

View file

@ -7,9 +7,13 @@
url = "github:Mic92/sops-nix"; url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs"; 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 let
lib = nixpkgs.lib; lib = nixpkgs.lib;
in { in {
@ -19,6 +23,13 @@
modules = [ modules = [
./configuration.nix ./configuration.nix
sops-nix.nixosModules.sops sops-nix.nixosModules.sops
home-manager.nixosModules.home-manager {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.yt = import ./home.nix;
};
}
]; ];
}; };
}; };

31
nix/home.nix Normal file
View file

@ -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";
};
};
}

View file

@ -3,6 +3,7 @@ borg:
restic: restic:
azure-yt: ENC[AES256_GCM,data:s8TJ5cNVW2Jr7kyul8mrBGwdLoTlNTb2MfpZgPU=,iv:sC0DbgFbFl6vvLqwOFDwRa3nabrIWxOTuz7GXn17IHk=,tag:2MYprYgNhh1aFlzuyw5eGQ==,type:str] 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] 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: sops:
kms: [] kms: []
gcp_kms: [] gcp_kms: []
@ -18,8 +19,8 @@ sops:
a1MwYjB0Tm03bzJnWTdoZ01KbXBPUkUKUr6hOsdZDJK6bFyEnBf4Vkms8EJsIvZY a1MwYjB0Tm03bzJnWTdoZ01KbXBPUkUKUr6hOsdZDJK6bFyEnBf4Vkms8EJsIvZY
ML481g9d9Vlm5x7X74nUcWemFSzttSdWEM3Y/IOHpXDbvC/Tbw+z7Q== ML481g9d9Vlm5x7X74nUcWemFSzttSdWEM3Y/IOHpXDbvC/Tbw+z7Q==
-----END AGE ENCRYPTED FILE----- -----END AGE ENCRYPTED FILE-----
lastmodified: "2024-11-24T08:24:07Z" lastmodified: "2024-12-01T00:51:59Z"
mac: ENC[AES256_GCM,data:W9K3+AERYBzRU0gvy50MbRULXGNyM6iujxdonSNbkoyoO6IBoGkMF+509jvoxrVFjEdiy7OZnj86O8XwAQDH3MLYSxpaUiJyQ8W3oQLdeJSk+cWVmBGSO5nXSjMGjU0jzKs2SH8SZKJXyOdDd3tmVTxTLk9u43fAi3AB4Iq/c8Q=,iv:5ETuAuMNpbxNYJLSLQ/J7A4Ov+laTkfNtNy8f5HSi0Y=,tag:1Dnnx5jv6v9ok7T59FX26w==,type:str] mac: ENC[AES256_GCM,data:TYyfVAAxiScRb/KAwqaglr5OjYAfb6uPb3Tdwum1rN09NLzmr8T4W3PramKCgGdTemtjl5YYpBT2lRnKfsNMpzLwg3JHsLV/6JvzCMAHuVPzHHG4SfbAlEz1uLH1/UopxW1w2RAMKK8do9+aXviL/nmXT6gbHgIVCI07U3006Lw=,iv:gyYePlF0MBSU6yhLieV/q8Gw/LbSaZWD7ghAaTLWQmk=,tag:P1L0FaTCmxeFYM6tdzhJBA==,type:str]
pgp: [] pgp: []
unencrypted_suffix: _unencrypted unencrypted_suffix: _unencrypted
version: 3.9.1 version: 3.9.1