{"title":{},"link":[{"@attributes":{"rel":"self","type":"application\/atom+xml","href":"https:\/\/totikom.github.io\/atom.xml"}},{"@attributes":{"rel":"alternate","type":"text\/html","href":"https:\/\/totikom.github.io\/"}}],"generator":"Zola","updated":"2025-04-06T00:00:00+00:00","id":"https:\/\/totikom.github.io\/atom.xml","entry":[{"title":"Update PGP subkeys","published":"2025-04-06T00:00:00+00:00","updated":"2025-04-06T00:00:00+00:00","author":{"name":"\n            \n              Unknown\n            \n          "},"link":{"@attributes":{"rel":"alternate","type":"text\/html","href":"https:\/\/totikom.github.io\/blog\/maintenance\/update-subkeys\/"}},"id":"https:\/\/totikom.github.io\/blog\/maintenance\/update-subkeys\/","content":"<p>I've generated new signing PGP subkey <code>278846A1C91B3184<\/code>, it will be used in all new commits and other stuff.\nPrevious subkey <code>596EA70DEDA4AFEC<\/code> will no longer be used.\nExpirity date on this key is changed, so that old commits will not be flagged as expired.<\/p>\n"},{"title":"Backups made easy: btrfs + snapper + snapborg","published":"2025-03-29T00:00:00+00:00","updated":"2025-03-29T00:00:00+00:00","author":{"name":"\n            \n              Unknown\n            \n          "},"link":{"@attributes":{"rel":"alternate","type":"text\/html","href":"https:\/\/totikom.github.io\/blog\/backups\/"}},"id":"https:\/\/totikom.github.io\/blog\/backups\/","content":"<p>Almost half a year ago I've switched from Manjaro to ArchLinux. One of the triggers for that switch was an urge to try CoW file system, mainly <a href=\"https:\/\/wiki.archlinux.org\/title\/Btrfs\">btrfs<\/a>.<\/p>\n<h1 id=\"system-installation-and-subvolume-layout\">System installation and subvolume layout<\/h1>\n<p>Basically, I've followed this <a href=\"https:\/\/walian.co.uk\/arch-install-with-secure-boot-btrfs-tpm2-luks-encryption-unified-kernel-images.html\">tutorial<\/a>:<\/p>\n<ul>\n<li>Created 2GB FAT partition for EFI<\/li>\n<li>Encrypted the rest of my disk with <code>cryptsetup<\/code><\/li>\n<li>Formatted it to <code>btrfs<\/code><\/li>\n<li>Created a set of subvolumes, mainly:\n<ul>\n<li><code>@<\/code> for rootfs<\/li>\n<li><code>@home<\/code> for home folders<\/li>\n<li><code>@home_unbacked<\/code> user files, which won't be backed up (more about it later)<\/li>\n<li><code>@var<\/code> for <code>\/var<\/code><\/li>\n<li><code>@var_log<\/code> for logs<\/li>\n<li><code>@var_pkgs<\/code> for <code>pacman<\/code> cache<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>This massive number of subvolumes is needed to allow fine-grained backups without wasting space for unneeded data.<\/p>\n<p>For instance,  you most likely won't need a backup of <code>pacman<\/code> cache, as you can download old versions of the packages form official archives, however you most likely need a backup of your <code>\/bin\/<\/code>,<code>\/lib\/<\/code>, <code>\/usr\/<\/code> and <code>\/etc\/<\/code> folders, because they contain files, essential for your system operation.<\/p>\n<p>The separation of <code>\/<\/code> and <code>\/home\/<\/code> backups is necessary, because they could have different retention policies.<\/p>\n<p><code>@home_unbacked<\/code> subvolume is mounted to <code>\/home\/.unbacked_files\/<\/code> directory, where each user have its own subdirectory.\nThey can symlink to this folder those files, which they don't need to back up.\nFor instance, my <code>~\/Videos\/<\/code> , <code>~\/Music\/<\/code> and <code>~\/.cache<\/code> folders are symlinked to <code>.unbacked_files<\/code>, so they will not waste space on the backup drive.<\/p>\n<h1 id=\"snapper\">snapper<\/h1>\n<p>Of course, you can do snapshots manually with <code>btrfs subvolume snapshot &lt;subvolume&gt; &lt;destination path&gt;<\/code>, be it is very verbose.<\/p>\n<p><code>snapper<\/code> is a small program for automating this task.\nBasically, it manages 2 things:<\/p>\n<ul>\n<li>Automatic snapshot creation: time-based and as a pacman hook<\/li>\n<li>Automatic removal of old snapshot based on different retention policies<\/li>\n<\/ul>\n<p>My  <code>snapper<\/code> config looks like this:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#65737e;\"># subvolume to snapshot\n<\/span><span style=\"color:#bf616a;\">SUBVOLUME<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">\/<\/span><span>&quot;\n<\/span><span>\n<\/span><span style=\"color:#65737e;\"># filesystem type\n<\/span><span style=\"color:#bf616a;\">FSTYPE<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">btrfs<\/span><span>&quot;\n<\/span><span>\n<\/span><span style=\"color:#65737e;\"># fraction or absolute size of the filesystems space the snapshots may use\n<\/span><span style=\"color:#bf616a;\">SPACE_LIMIT<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">0.5<\/span><span>&quot;\n<\/span><span>\n<\/span><span style=\"color:#65737e;\"># fraction or absolute size of the filesystems space that should be free\n<\/span><span style=\"color:#bf616a;\">FREE_LIMIT<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">0.2<\/span><span>&quot;\n<\/span><span>\n<\/span><span style=\"color:#65737e;\"># create hourly snapshots\n<\/span><span style=\"color:#bf616a;\">TIMELINE_CREATE<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">yes<\/span><span>&quot;\n<\/span><span>\n<\/span><span style=\"color:#65737e;\"># cleanup hourly snapshots after some time\n<\/span><span style=\"color:#bf616a;\">TIMELINE_CLEANUP<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">yes<\/span><span>&quot;\n<\/span><span>\n<\/span><span style=\"color:#65737e;\"># limits for timeline cleanup\n<\/span><span style=\"color:#bf616a;\">TIMELINE_MIN_AGE<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">1800<\/span><span>&quot;\n<\/span><span style=\"color:#bf616a;\">TIMELINE_LIMIT_HOURLY<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">1<\/span><span>&quot;\n<\/span><span style=\"color:#bf616a;\">TIMELINE_LIMIT_DAILY<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">7<\/span><span>&quot;\n<\/span><span style=\"color:#bf616a;\">TIMELINE_LIMIT_WEEKLY<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">8<\/span><span>&quot;\n<\/span><span style=\"color:#bf616a;\">TIMELINE_LIMIT_MONTHLY<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">4<\/span><span>&quot;\n<\/span><span style=\"color:#bf616a;\">TIMELINE_LIMIT_YEARLY<\/span><span>=&quot;<\/span><span style=\"color:#a3be8c;\">0<\/span><span>&quot;\n<\/span><\/code><\/pre>\n<p>With this config you'll have a hourly snapshots and a sane retention policy.<\/p>\n<p>However, <strong>snapshots are not backups<\/strong>.\nThey'll save you from accidental file deletion or system misconfiguration, but not from disk failure.<\/p>\n<p>To truly have a backup, you'll need a separate drive, which stores you snapshots.<\/p>\n<p>Luckily, <code>btrfs<\/code> allows you to send subvolumes (or snapshots) to different devices.<\/p>\n<p>With <code>btrfs send<\/code> you can copy the entire subvolume to <code>stdout<\/code> and receive it with <code>btrfs receive<\/code> on the backup drive.<\/p>\n<p>So, with another (ideally, offline) <code>btrfs<\/code> disk your snapshots will be backed up and deduplicated thanks to copy-on-write semantics.<\/p>\n<p>However, this approach has several downsides:<\/p>\n<ol>\n<li>Backup drive <strong>must<\/strong> be formatted as <code>btrfs<\/code><\/li>\n<li>Snapshots have to be moved manually<\/li>\n<li>Storing backups of several subvolumes will be a mess<\/li>\n<li>You'll have to manually remove old snapshots<\/li>\n<\/ol>\n<h1 id=\"borg\">borg<\/h1>\n<p>I'm using <a href=\"https:\/\/borgbackup.readthedocs.io\/en\/stable\/\">borg<\/a> as my main backup utility for several years already.\nIt has all the backing up features I have ever needed:<\/p>\n<ul>\n<li>block-level deduplication<\/li>\n<li>backup compression<\/li>\n<li>does not depend on the file system: <code>borg<\/code> archive is just a folder with files, no hardlinks, symlinks of other special features<\/li>\n<li>has rich retention policy settings<\/li>\n<li>possibility to mount backups as FUSE file systems<\/li>\n<\/ul>\n<p>Before I've moved to <code>btrfs<\/code>, I've used <code>borg<\/code> to backup my entire system drive like this:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#65737e;\">#!\/bin\/bash\n<\/span><span style=\"color:#bf616a;\">TARGET<\/span><span>=<\/span><span style=\"color:#a3be8c;\">\/path\/to\/borg\/archive\n<\/span><span style=\"color:#bf616a;\">BACKUPS<\/span><span>= <\/span><span style=\"color:#bf616a;\">dirs<\/span><span> to be backed up\n<\/span><span style=\"color:#bf616a;\">BORG_PASSPHRASE<\/span><span>=&lt;passphrase&gt;\n<\/span><span style=\"color:#bf616a;\">borg<\/span><span> create<\/span><span style=\"color:#bf616a;\"> --stats --progress <\/span><span>\\\n<\/span><span>\t$<\/span><span style=\"color:#bf616a;\">TARGET<\/span><span>::{now} \\\n<\/span><span>\t$<\/span><span style=\"color:#bf616a;\">BACKUPS <\/span><span>\\\n<\/span><span style=\"color:#bf616a;\">\t--exclude-from<\/span><span> \/path\/to\/exclusions\/file\n<\/span><\/code><\/pre>\n<p>And it was very convenient: I've added this script to <code>cron<\/code> and it did everything automatically.<\/p>\n<p>Occasionally, I've run <code>borg prune -v --list --stats $PRUNE_OPTS $TARGET<\/code> to delete old backups.\nIn this command <code>PRUNE_OPTS<\/code> is a variable, which contained retention policies.\nIn my case they were:<\/p>\n<ul>\n<li><code>-d 1<\/code> keep a single backup for the last day<\/li>\n<li><code>-w 8<\/code> keep a single backup for each of the last 8 weeks<\/li>\n<li><code>-m 6<\/code> keep a single backup for each of the last 6 months<\/li>\n<li><code>-y 5<\/code> keep a single backup for each of the last 5 years<\/li>\n<\/ul>\n<p>For general file systems it is already a very good solution, but with <code>btrfs<\/code> we can do better:<\/p>\n<h1 id=\"snapborg\">snapborg<\/h1>\n<p>Actually, <code>borg<\/code> can backup not only directories, but also the entire block devices and even <code>stdin<\/code><sup class=\"footnote-reference\" id=\"fr-1-1\"><a href=\"#fn-1\">[1]<\/a><\/sup>.<\/p>\n<p>This means that at least we can pipe <code>btrfs send<\/code> to <code>borg<\/code>, but this way we will not be able to mount subvolumes.<\/p>\n<p>Luckily, we can instruct  <code>borg<\/code>  to backup snapshot volumes discarding path to subvolumes, so from the <code>borg<\/code>'s point of view, snapshots are different states of a single file system instead of different subfolders.<\/p>\n<p>And this is already implemented in <a href=\"https:\/\/github.com\/enzingerm\/snapborg\">snapborg<\/a>!<\/p>\n<p>More over, it is implemented in a fail-safe way: before starting back up <code>snapborg<\/code> disables retention policies on snapshots to be backed up, so they will not be removed during backup process.\nAfter backing everything up it will return retention policies back to the previous values.<\/p>\n<p>My <code>snapborg<\/code> config looks like this (it is slightly edited example config <code>snapborg<\/code> repo):<\/p>\n<pre data-lang=\"yaml\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-yaml \"><code class=\"language-yaml\" data-lang=\"yaml\"><span style=\"color:#65737e;\"># snapborg sample configuration file. Default values are used for the sample\n<\/span><span style=\"color:#65737e;\"># configuration, thus can be omitted or changed\n<\/span><span>\n<\/span><span>\n<\/span><span style=\"color:#65737e;\"># List of mappings of snapper configs to their borg repos\n<\/span><span style=\"color:#bf616a;\">configs<\/span><span>:\n<\/span><span>    <\/span><span style=\"color:#65737e;\"># MANDATORY: name of the snapper config\n<\/span><span>  - <\/span><span style=\"color:#bf616a;\">name<\/span><span>: <\/span><span style=\"color:#a3be8c;\">root\n<\/span><span>    <\/span><span style=\"color:#65737e;\"># MANDATORY: borg repo target, e. g. backupuser@backuphost:reponame\n<\/span><span>    <\/span><span style=\"color:#bf616a;\">repo<\/span><span>: <\/span><span style=\"color:#a3be8c;\">\/path\/to\/borg\/repo\n<\/span><span>    <\/span><span style=\"color:#65737e;\"># if this is set to true, borg does not neccessarily fail when a backup fails\n<\/span><span>    <\/span><span style=\"color:#bf616a;\">fault_tolerant_mode<\/span><span>: <\/span><span style=\"color:#d08770;\">false\n<\/span><span>    <\/span><span style=\"color:#65737e;\"># snapborg fails when the most recent snapshot transferred successfully is\n<\/span><span>    <\/span><span style=\"color:#65737e;\"># older than the time period given here. Set to &#39;0d&#39; to disable this behaviour\n<\/span><span>    <\/span><span style=\"color:#bf616a;\">last_backup_max_age<\/span><span>: <\/span><span style=\"color:#a3be8c;\">0d\n<\/span><span>    <\/span><span style=\"color:#65737e;\"># archive creation\/storage options\n<\/span><span>    <\/span><span style=\"color:#bf616a;\">storage<\/span><span>:\n<\/span><span>      <\/span><span style=\"color:#65737e;\"># use either none or repokey encryption, defaults to none\n<\/span><span>      <\/span><span style=\"color:#bf616a;\">encryption<\/span><span>: <\/span><span style=\"color:#a3be8c;\">repokey\n<\/span><span>      <\/span><span style=\"color:#65737e;\"># MANDATORY when using repokey: literal key passphrase or path to file\n<\/span><span>      <\/span><span style=\"color:#65737e;\"># containing the key passphrase. Ignored when using none encryption\n<\/span><span>      <\/span><span style=\"color:#bf616a;\">encryption_passphrase<\/span><span>: <\/span><span style=\"color:#a3be8c;\">&lt;my borg passphrase&gt;\n<\/span><span>      <\/span><span style=\"color:#65737e;\"># compression configuration, see borg manual\n<\/span><span>      <\/span><span style=\"color:#bf616a;\">compression<\/span><span>: <\/span><span style=\"color:#a3be8c;\">auto,zstd,4\n<\/span><span>\n<\/span><span>    <\/span><span style=\"color:#65737e;\"># define retention settings for borg independently from snapper\n<\/span><span>    <\/span><span style=\"color:#bf616a;\">retention<\/span><span>:\n<\/span><span>      <\/span><span style=\"color:#bf616a;\">keep_last<\/span><span>: <\/span><span style=\"color:#d08770;\">1\n<\/span><span>      <\/span><span style=\"color:#bf616a;\">keep_hourly<\/span><span>: <\/span><span style=\"color:#d08770;\">0\n<\/span><span>      <\/span><span style=\"color:#bf616a;\">keep_daily<\/span><span>: <\/span><span style=\"color:#d08770;\">1\n<\/span><span>      <\/span><span style=\"color:#bf616a;\">keep_weekly<\/span><span>: <\/span><span style=\"color:#d08770;\">8\n<\/span><span>      <\/span><span style=\"color:#bf616a;\">keep_monthly<\/span><span>: <\/span><span style=\"color:#d08770;\">6\n<\/span><span>      <\/span><span style=\"color:#bf616a;\">keep_yearly<\/span><span>: <\/span><span style=\"color:#d08770;\">5\n<\/span><span>    <\/span><span style=\"color:#65737e;\"># exclude patterns (see borg help patterns)\n<\/span><span>    <\/span><span style=\"color:#bf616a;\">exclude_patterns<\/span><span>: []\n<\/span><\/code><\/pre>\n<p>Whey you run <code>snapborg backup<\/code>, it will get a list of local snapshots, merge it with the list of backups from <code>borg<\/code> archive and determine, which snapshots actually  need to be backed up (i.e. will not be immediately deleted by retention policy).\nIt will disable retention policy for this snapshots and back up them to <code>borg<\/code>.<\/p>\n<p>When the snapshots are backed up to <code>borg<\/code> archive, <code>snapborg<\/code> will run <code>borg prune<\/code> with the retention policy from the config, removing backups, which are no longer needed.<\/p>\n<h1 id=\"final-workflow\">Final workflow<\/h1>\n<p>With <code>btrfs<\/code>, <code>snapper<\/code> and <code>snapborg<\/code> I have a very easy to use backup system:<\/p>\n<ul>\n<li><code>snapper<\/code> automatically<sup class=\"footnote-reference\" id=\"fr-2-1\"><a href=\"#fn-2\">[2]<\/a><\/sup> create <code>btrfs<\/code> snapshots and take care of removing the old ones<\/li>\n<li>occasionally I connect my backup hard drive to the laptop and run <code>snapborg backup<\/code>, so that the snapshots are backed up.<\/li>\n<\/ul>\n<p>... and that's it!\nThat's all the things, which I need to do, to maintain my backup chores.<\/p>\n<p>Thanks to snapshots, I do not need to worry about the moment, when I need to back them up.\nIf I update some file, the previous version will still be in the snapshots, so it will still be backed up, even if the changes were made <em>before<\/em> actual backup.<\/p>\n<p>For me, it is a killer-feature and I am very proud, that I've came up with this setup.<\/p>\n<hr \/>\n<hr><ol class=\"footnotes-list\">\n<li id=\"fn-1\">\n<p>you can pipe some data to it and it will be stored as <code>stdin<\/code> file in the <code>borg<\/code> archive <a href=\"#fr-1-1\">\u21a9<\/a><\/p>\n<\/li>\n<li id=\"fn-2\">\n<p>via <code>systemd<\/code>  service <a href=\"#fr-2-1\">\u21a9<\/a><\/p>\n<\/li>\n<\/ol>\n"},{"title":"Managing multi-device music library via beets and Syncthing","published":"2025-03-06T00:00:00+00:00","updated":"2025-03-06T00:00:00+00:00","author":{"name":"\n            \n              Unknown\n            \n          "},"link":{"@attributes":{"rel":"alternate","type":"text\/html","href":"https:\/\/totikom.github.io\/blog\/beets-syncthing\/"}},"id":"https:\/\/totikom.github.io\/blog\/beets-syncthing\/","content":"<p>I'm one of those people, who don't use streaming services and store all music on my devices.<\/p>\n<p>At first, I was just downloading it and occasionally copied it from one device to another.\nHowever, this approach does not scale well.\nMusic folders on my devices had quickly became a mess: irregular names, album folders mixed with artist folders, different timestamps on different devices.<\/p>\n<p>At some point I've found myself downloading the same album three times: first two on different devices, because I've forgot to copy from one to another, and the third one on the phone with this album already available!\nJust because of unintuitive folder name I was unable to locate it.<\/p>\n<h1 id=\"beets\">beets<\/h1>\n<p>To solve it on PC I've started using <a href=\"https:\/\/beets.io\/\">beets<\/a>.\n<code>beets<\/code> is a nice music management software, which allows you (among lots of otsystema) to move your music to neatly organized folder and correct songs metadata with <a href=\"https:\/\/musicbrainz.org\/\">Musicbrainz<\/a> database.<\/p>\n<p>It took me several days to import my whole PC collection to <code>beets<\/code> DB, but, luckly, most of the process was automatic<sup class=\"footnote-reference\" id=\"fr-1-1\"><a href=\"#fn-1\">[1]<\/a><\/sup>.\nAll I had to do was just:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#bf616a;\">beet<\/span><span> import<\/span><span style=\"color:#bf616a;\"> -q <\/span><span style=\"color:#b48ead;\">[<\/span><span>path to music to be imported<\/span><span style=\"color:#b48ead;\">]\n<\/span><\/code><\/pre>\n<p>Where <code>-q<\/code> flag means \"skip mismatches and continue without user interaction\".<\/p>\n<p>After that I've runned <code>beets<\/code> once again, but without <code>-q<\/code>  and manually confirmed all uncertainties.<\/p>\n<p>OK, the biggest part of my music collection got systematized.\nHowever, it created another problem: during the time collections on the PC and on the phone inevitabily became out of sync.\nThe divergence wasn't supposed to be significant, but I couldn't just delete all music from the phone and reupload systematized collection from PC.<\/p>\n<p>So, I had to manually replace parts of my collection on the phone adding out of sync albums back to the PC.<\/p>\n<p>I guess, it took me a week or longer and it was VERY tiresome.<\/p>\n<p>Now, when I get new music, I immediately pass it through <code>beets<\/code>, so my collection remains systematized.<\/p>\n<p>Seems like all the problems are finally solved?\nEhhh, not exactly.<\/p>\n<p>Over time my listening habits have changed and now I'm listening music almost exclusively from my phone.<\/p>\n<p>More over, I'm <em>getting<\/em> music on my phone, so the above \"workflow\" transforms to:<\/p>\n<ol>\n<li>Get new music on the phone<\/li>\n<li>Eventually copy it to the PC<\/li>\n<li>Add the new music to <code>beets<\/code> library<\/li>\n<li>Copy library entries back to the phone<\/li>\n<\/ol>\n<p>Not very convenient, right?\nThat has led to me procrastinating music sync for weeks, which complicated everything, because all music players store tracks in playlists by referencing paths, so moving tracks around cause playlists to break.<\/p>\n<p>And I had to plug my phone via USB and wait for all the operations to finish!<\/p>\n<h1 id=\"syncthing-to-the-rescue\">Syncthing to the rescue!<\/h1>\n<p>I knew about <a href=\"https:\/\/syncthing.net\/\">syncthing<\/a> for some time, but hadn't found a use for it until resently.<\/p>\n<p><code>Syncthing<\/code> is not a cloud, but rather <em>device-to-device<\/em> synchronization program, which may be not the best variant, if you don't have a continuously operating machine, which will serve as \"cloud storage\", but for keeping files in sync between devices it is a perfect fit.<\/p>\n<p>After setting up <code>syncthing<\/code> on both the PC and the phone, I got (almost) perfect setup for music collection storage and listening:<\/p>\n<ul>\n<li>The collection is synchronized between devices without manual actions<\/li>\n<li>No need to connect anything<\/li>\n<li>I can get music on any device<\/li>\n<li>I can add music to <code>beets<\/code> library at any time I'm near PC: the changes will be synchronized automatically<\/li>\n<\/ul>\n<h1 id=\"final-setup\">Final setup<\/h1>\n<ol>\n<li><code>syncthing<\/code> is running on both PC and phone<\/li>\n<li><code>beets<\/code> is used on the PC to keep collection organized<\/li>\n<li>Any device could be used for downloading music<\/li>\n<\/ol>\n<p>This simple workflow had allowed me to greatly simplify my music collection management and usage.\nLooking back, this workflow looks like pretty obvious, but I hope that it still can help people, who maintains their music library by their own.<\/p>\n<hr \/>\n<hr><ol class=\"footnotes-list\">\n<li id=\"fn-1\">\n<p>If <code>beets<\/code> finds a matching album, it imports music automatically, but if match is not close enough, it will ask for user confirmation. <a href=\"#fr-1-1\">\u21a9<\/a><\/p>\n<\/li>\n<\/ol>\n"},{"title":"Open lecture about history of computing machinery","published":"2024-06-23T00:00:00+00:00","updated":"2024-06-23T00:00:00+00:00","author":{"name":"\n            \n              Unknown\n            \n          "},"link":{"@attributes":{"rel":"alternate","type":"text\/html","href":"https:\/\/totikom.github.io\/blog\/talks\/computer-history\/"}},"id":"https:\/\/totikom.github.io\/blog\/talks\/computer-history\/","content":"<p>Two weeks ago I gave a talk about history of computing machinery in <a href=\"https:\/\/yandex.eu\/maps\/org\/locus_solus\/1692971085\/\">Locus Solus<\/a> book shop.\n<a href=\"\/slides\/2024-06-08-computer-history.pdf\">slides<\/a> (in Russian).<\/p>\n<p>BTW, this presentation is written in <a href=\"https:\/\/typst.app\/\">typst<\/a>, you can check the code in this <a href=\"https:\/\/github.com\/totikom\/slides\/tree\/main\/2024-06-08-computer-history\">repo<\/a> (my other talks are stored there).<\/p>\n"},{"title":"Open lecture about blockchain","published":"2024-05-26T00:00:00+00:00","updated":"2024-05-26T00:00:00+00:00","author":{"name":"\n            \n              Unknown\n            \n          "},"link":{"@attributes":{"rel":"alternate","type":"text\/html","href":"https:\/\/totikom.github.io\/blog\/talks\/turing-blockchain\/"}},"id":"https:\/\/totikom.github.io\/blog\/talks\/turing-blockchain\/","content":"<p>On the 1st of May in collaboration with \"Turing\" school I gave a lecture about blockhcain internals.\n<a href=\"\/slides\/2024-05-01-turing-blockchain.pdf\">slides<\/a> and <a href=\"https:\/\/youtu.be\/8OB97iBm31I?si=Wv_4aLTUeiXQy0v0\">video<\/a> (in Russian).<\/p>\n<p>BTW, this presentation is written in <a href=\"https:\/\/typst.app\/\">typst<\/a>, you can check the code in this <a href=\"https:\/\/github.com\/totikom\/slides\/tree\/main\/2024-05-01-turing-blockchain\">repo<\/a> (my other talks will likely be stored there).<\/p>\n"},{"title":"I've started using keyoxide!","published":"2024-05-05T00:00:00+00:00","updated":"2024-05-05T00:00:00+00:00","author":{"name":"\n            \n              Unknown\n            \n          "},"link":{"@attributes":{"rel":"alternate","type":"text\/html","href":"https:\/\/totikom.github.io\/blog\/maintenance\/adding-keyoxide-key\/"}},"id":"https:\/\/totikom.github.io\/blog\/maintenance\/adding-keyoxide-key\/","content":"<p>-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA512<\/p>\n<p>Hi, it's totikom again!\nI want to experiment with Keyoxide, but I don't want to mess with my main pgp key, so I've chosen to give ASP a chance.\nBy signing this message I comfirm that <a href=\"https:\/\/keyoxide.org\/aspe:keyoxide.org:N2JI63C76RTIUDK54WA7COKDLU\">aspe:keyoxide.org:N2JI63C76RTIUDK54WA7COKDLU<\/a> belongs to me.\n-----BEGIN PGP SIGNATURE-----<\/p>\n<p>iQIzBAEBCgAdFiEEy6TRKOobT2dUcgeGWW6nDe2kr+wFAmY3nIMACgkQWW6nDe2k\nr+zRVA\/+LTPs1TWiBzp+IF1WG1cb94XFY9+oYClZHNFc3HUPBSv3prhd7J8A4YZD\n5fkdlaDIByx1lG+y02cN8TP2knt2DTm6JifGBuw\/P1gm8dQluyu3VlBmSHSXoV9X\nkUSqBz34aBsVjNuhOliqS0Ooz3tQkEIy1hCB+ktZhyd3JmoieIBHiX9NlsSLktbW\nNQiXM4C4rZFhYLSsy7F7p8JlpSbB3J9avDx04nNL9xDxUunNPnY8WniBQo88VP5h\nbiCiwYphOIbuuqMiDXT91tag5YqLcZXKFEFDBySUcT\/IqVmrnc0tiLcIqvOT5m8L\nKH5wbW4pAuT+dBTcIJKA7gTMv8OHbk3cM8ml7G1n3madOsSFC4\/7cNDHiT3HE78z\nzsuJvrF\/tRVK81MN3pnDlZap4e4KOkOrVTHJxAOSUfC1ugvEf+8Hl3wmHaxVN9bf\naUniT9ISkh34CBpJF94GQnch8r0wBkr\/EaK7dJjWnjLuwtSDQ7IB034z1vbYQNT2\ny7MPdlHVduHBKHt4y7e0Sp4cVvpgyeZpjkrY+p00uUDh92QkkGuWkv1\/u7VbpbxX\nK5xvrqa1IHQO0MivJsVcACDrBdJt2tNTu77b8p5CholOYeN87sxFlbpbuKuFGZe4\ncDS1BMigbnYUwYc45yeq8euDr+0F6EehcLXD3DjFT0zhoTl5NWg=\n=RAUE\n-----END PGP SIGNATURE-----<\/p>\n<p>You can also check out original <a href=\"\/2024-05-05-adding_keyoxide_key.txt\">message<\/a><\/p>\n"},{"title":"Installing nix the hard way","published":"2024-04-17T00:00:00+00:00","updated":"2024-04-17T00:00:00+00:00","author":{"name":"\n            \n              Unknown\n            \n          "},"link":{"@attributes":{"rel":"alternate","type":"text\/html","href":"https:\/\/totikom.github.io\/blog\/nix-install\/"}},"id":"https:\/\/totikom.github.io\/blog\/nix-install\/","content":"<h1 id=\"why-bother-with-all-that-staff\">Why bother with all that staff?<\/h1>\n<p>People talk a lot about Nix and how it helps to build reproducible environments.\nNix community is so focused on reproducibility, that using <code>nix-env<\/code> is considered a <a href=\"https:\/\/stop-using-nix-env.privatevoid.net\/\">bad<\/a> practice.<\/p>\n<p>However, reproducibility is not the only positive feature of <code>nix<\/code>.\nAnother important feature is <a href=\"https:\/\/nixos.org\/manual\/nix\/stable\/installation\/multi-user.html\">multi-user mode<\/a>.\nThis may not sound very useful for individuals, but I think, that for big companies it is a dealbreaker.<\/p>\n<p>Just think about it!\nFor IT companies it is a common situation when several developers work on a single remote machine.\nFor stability, and other Important Reasons\u2122 such machines rarely have updated software.<\/p>\n<p>Either for compatibility with some production code, or because of security policies, this servers are not just outdated, but the updates are intentionally disabled.<\/p>\n<p>They may even be disconnected from the internet, allowing access only to the company's internal network.<\/p>\n<p>Even if updates were possible, they would be very risky: updating one package may require updating its dependencies and therefore other packages which depend on them.<\/p>\n<blockquote>\n<p>Partial updates are not supported.<\/p>\n<p>\u00a9 ArchWiki<\/p>\n<\/blockquote>\n<p>Of course, package manager will resolve such conflicts and just updates everything.<\/p>\n<p>...probably breaking someone else's environment.\nSo, updates are often restricted.<\/p>\n<h1 id=\"installation\">Installation<\/h1>\n<p>A few days ago I've explained this to the management and today I was finally given access to proxy, which will allow me to download things from the internet.<\/p>\n<p>First of all, I had to download the installer, as stated in the official <a href=\"https:\/\/nixos.org\/manual\/nix\/stable\/installation\/#multi-user\">guides<\/a>:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#bf616a;\">bash <\/span><span>&lt;(<\/span><span style=\"color:#bf616a;\">curl -L<\/span><span> https:\/\/nixos.org\/nix\/install)<\/span><span style=\"color:#bf616a;\"> --daemon\n<\/span><\/code><\/pre>\n<p>Of course, it didn't work without configuring the proxy, so actually I had to do:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#b48ead;\">export <\/span><span style=\"color:#bf616a;\">HTTP_PROXY<\/span><span>=<\/span><span style=\"color:#a3be8c;\">http:\/\/<\/span><span>&lt;username&gt;:&lt;password&gt;@proxy.addr:port\n<\/span><span style=\"color:#b48ead;\">export <\/span><span style=\"color:#bf616a;\">HTTPS_PROXY<\/span><span>=<\/span><span style=\"color:#a3be8c;\">http:\/\/<\/span><span>&lt;username&gt;:&lt;password&gt;@proxy.addr:port\n<\/span><span style=\"color:#bf616a;\">bash <\/span><span>&lt;(<\/span><span style=\"color:#bf616a;\">curl -L<\/span><span> https:\/\/nixos.org\/nix\/install)<\/span><span style=\"color:#bf616a;\"> --daemon\n<\/span><\/code><\/pre>\n<p>And...\nIt still hasn't worked!\n<code>curl<\/code> failed with a cryptic error saying that <code>&lt;my username&gt;:<\/code> (yes, with colon) is not a valid port number.\nWTF!?<\/p>\n<p>My password has special characters.\nMaybe they were not property escaped?<\/p>\n<p>I've tried, but without success.\nAfter a bit of digging I've found that (it looks very obvious now) <code>HTTP_PROXY<\/code> variable is parsed as URL and therefore all special characters have to be <a href=\"https:\/\/en.wikipedia.org\/wiki\/Percent-encoding\">percent-encoded<\/a>.<\/p>\n<p>OK... I've redefined proxy variables and installation script was finally downloaded.\nThe script started working and have downloaded the tarball.\nI've entered <code>sudo<\/code> password, it successfully created users and copied files from the package to <code>\/nix<\/code> directory.\nEverything was fine until it runned <code>nix-channel --update nixpkgs<\/code>.\nNothing happened for a while, when a connection timeout warning appeared.<\/p>\n<p>That looked suspiciously like a proxy failure.\nI've added <code>--no-channel-add<\/code> flag to the install script, so that it will skip this step, uninstalled everything <sup class=\"footnote-reference\" id=\"fr-1-1\"><a href=\"#fn-1\">[1]<\/a><\/sup> as explained in the <a href=\"https:\/\/nixos.org\/manual\/nix\/stable\/installation\/uninstall#linux\">docs<\/a> and started from the begining.<\/p>\n<p>The installation seemed to succeed this time, so I've started a new shell and did:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#bf616a;\">nix-channel --add<\/span><span> https:\/\/nixos.org\/channels\/nixpkgs-unstable nixpkgs\n<\/span><\/code><\/pre>\n<p>But it failed because of insufficient permissions.\nOf course!\nI forgot to add my user to the right group.<\/p>\n<p>According to the <a href=\"https:\/\/nixos.org\/manual\/nix\/stable\/installation\/multi-user#restricting-access\">manual<\/a>, only users who have write permission to <code>\/nix\/var\/nix\/daemon-socket<\/code> are allowed to work in multi-user mode.\nI've already had <code>users<\/code> group, so I did just:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#bf616a;\">sudo<\/span><span> chgrp users \/nix\/var\/nix\/daemon-socket\n<\/span><span style=\"color:#bf616a;\">sudo<\/span><span> chmod ug=rwx,o= \/nix\/var\/nix\/daemon-socket\n<\/span><\/code><\/pre>\n<p>Now my user had enough permissions and I was able to run <code>nix-channel<\/code>:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#bf616a;\">nix-channel --add<\/span><span> https:\/\/nixos.org\/channels\/nixpkgs-unstable nixpkgs\n<\/span><span style=\"color:#bf616a;\">nix-channel --update<\/span><span> nixpkgs\n<\/span><\/code><\/pre>\n<p>As previously happend in the istall script, <code>--update <\/code> command hanged.\nI've started searching, how people deal with proxies in Nix.\nAmong others, I've found <a href=\"https:\/\/github.com\/NixOS\/nix\/pull\/2946\/files\">this<\/a> PR, which explicitly add support for proxies, but, as far as I can tell, only for <code>nix-daemon<\/code>.<\/p>\n<p>I've added <code>HTTP_PROXY<\/code> and <code>HTTPS_PROXY<\/code> vars and tried again.\nThis time I've got a different error: <code>nix-channel<\/code> was complaining about bad SSL cert.<\/p>\n<h1 id=\"here-comes-the-funny-part\">Here comes the funny part...<\/h1>\n<p>Well, our machines are not only behind proxy, they are behind MITM-proxy.<\/p>\n<p><code>curl<\/code> and other installed software works fine, because they use system-wide CA bundles, but Nix comes with its own certificates.<\/p>\n<p>After some googling I've found <code>NIX_SSL_CERT_FILE<\/code> variable and tried to set it.\nIt worked!\nThe channel was successully updated and with a feel of acomplishment I've issued <code>nix-shell -p vim<\/code> to try it out.<\/p>\n<p>The command was silent for almost a minute, then I saw a familiar timeout error.\nBut I've configured the proxy vars!\nThey were definetly passed to the systemd override, the installer has clearly shown it (I still had the installer output in the unclosed term).<\/p>\n<p>In a fit of suspiciousness I've opened override file.\nAt first glance, everything seemed fine, proxy variables were set, but the password field in the URLs looked a bit strange.\nI've taken a closer look and found that nix installer has reencoded my percent-encoded characters and messed them up!\nI've also remembered the certificate thing, so I've also add <code>NIX_SSL_CERT_FILE<\/code> variable to the override.<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#bf616a;\">sudo<\/span><span> systemctl daemon-reload\n<\/span><span style=\"color:#bf616a;\">sudo<\/span><span> systemctl restart nix-daemon.service\n<\/span><\/code><\/pre>\n<p>And finaly <code>nix-env -i vim<\/code><sup class=\"footnote-reference\" id=\"fr-2-1\"><a href=\"#fn-2\">[2]<\/a><\/sup> worked!\nInitial enviroment installation was a bit slow, but it worked!\nIt took me a whole working day to do this <em>simple<\/em> install...<\/p>\n<h1 id=\"tl-dr\">TL;DR:<\/h1>\n<p>If you need to install <code>nix<\/code>  in multi-user mode behind MITM-proxy, do the following:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#b48ead;\">export <\/span><span style=\"color:#bf616a;\">HTTP_PROXY<\/span><span>=<\/span><span style=\"color:#a3be8c;\">http:\/\/<\/span><span>&lt;username&gt;:&lt;password&gt;@proxy.addr:port\n<\/span><span style=\"color:#b48ead;\">export <\/span><span style=\"color:#bf616a;\">HTTPS_PROXY<\/span><span>=<\/span><span style=\"color:#a3be8c;\">http:\/\/<\/span><span>&lt;username&gt;:&lt;password&gt;@proxy.addr:port\n<\/span><span style=\"color:#bf616a;\">bash <\/span><span>&lt;(<\/span><span style=\"color:#bf616a;\">curl -L<\/span><span> https:\/\/nixos.org\/nix\/install)<\/span><span style=\"color:#bf616a;\"> --daemon\n<\/span><\/code><\/pre>\n<p>If your username or pasword has special characters, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Percent-encoding\">percent-encode<\/a> them.<\/p>\n<p>Open <code>\/etc\/systemd\/system\/nix-daemon.service.d\/override.conf<\/code> and check that variables <code>HTTPS_PROXY<\/code>, <code>HTTPS_PROXY<\/code> are not messed up.\nAdd variable <code>NIX_SSL_CERT_FILE<\/code> to that file and run:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#bf616a;\">sudo<\/span><span> systemctl daemon-reload\n<\/span><span style=\"color:#bf616a;\">sudo<\/span><span> systemctl restart nix-daemon.service\n<\/span><\/code><\/pre>\n<p>Then add <code>nix-socket<\/code> to the right group:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#bf616a;\">sudo<\/span><span> chgrp nix-users \/nix\/var\/nix\/daemon-socket\n<\/span><span style=\"color:#bf616a;\">sudo<\/span><span> chmod ug=rwx,o= \/nix\/var\/nix\/daemon-socket\n<\/span><\/code><\/pre>\n<p>In a new shell set <code>HTTPS_PROXY<\/code>, <code>HTTPS_PROXY<\/code> and<code>NIX_SSL_CERT_FILE<\/code> variables<sup class=\"footnote-reference\" id=\"fr-3-1\"><a href=\"#fn-3\">[3]<\/a><\/sup> and run:<\/p>\n<pre data-lang=\"bash\" style=\"background-color:#2b303b;color:#c0c5ce;\" class=\"language-bash \"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#bf616a;\">nix-channel --add<\/span><span> https:\/\/nixos.org\/channels\/nixpkgs-unstable nixpkgs\n<\/span><span style=\"color:#bf616a;\">nix-channel --update<\/span><span> nixpkgs\n<\/span><\/code><\/pre>\n<p>That's it!\n<code>nix<\/code> is installed on your system.<\/p>\n<hr \/>\n<hr><ol class=\"footnotes-list\">\n<li id=\"fn-1\">\n<p>without that the script will complain about existing installation. <a href=\"#fr-1-1\">\u21a9<\/a><\/p>\n<\/li>\n<li id=\"fn-2\">\n<p>again, I know that using <code>nix-env<\/code> is discouraged, but for my particular setup it is more suitable. <a href=\"#fr-2-1\">\u21a9<\/a><\/p>\n<\/li>\n<li id=\"fn-3\">\n<p>you need to set this variables only for operations with <code>nix-channel<\/code>. <code>nix-env<\/code> and <code>nix-shell<\/code> works without them. <a href=\"#fr-3-1\">\u21a9<\/a><\/p>\n<\/li>\n<\/ol>\n"},{"title":"Site ownership proof","published":"2024-04-07T00:00:00+00:00","updated":"2024-04-07T00:00:00+00:00","author":{"name":"\n            \n              Unknown\n            \n          "},"link":{"@attributes":{"rel":"alternate","type":"text\/html","href":"https:\/\/totikom.github.io\/blog\/maintenance\/initial-signature\/"}},"id":"https:\/\/totikom.github.io\/blog\/maintenance\/initial-signature\/","content":"<p>-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA512<\/p>\n<p>Hi. This is totikom and by signing this message, I confirm that <a href=\"https:\/\/totikom.github.io\/\">this<\/a> site belongs to me.\n-----BEGIN PGP SIGNATURE-----<\/p>\n<p>iQIzBAEBCgAdFiEEy6TRKOobT2dUcgeGWW6nDe2kr+wFAmYSp6gACgkQWW6nDe2k\nr+wruw\/\/W96N22LAYDKsmdtUacU\/BbjFoKHPExuuUfYlBMru7wacyyf0FRhKBg9M\nroeW+Xruaoq\/ZoiBLARvYzdOFm1TnymCvrhO6uXhf7Ag9wpUpdAqoy5IDphjF5eQ\nu\/h+BrQs9TvkowDf202Fnmw1TBg1BcI\/WMZk5Itn4TPLtzdplGkvVMR\/j5DOckNQ\nUJ+MchY1xZvXhGd8stIvM718SHM6ExuRJHGIiAPzwTfsUIIenn1zFXZ9NeHwFMoP\nqx\/smmiWMnhTn9WJyyeMGSPgMZUw+y1KgNDLua33+k44vz4Ts6ZJpMBJ6o9YvpWB\nx1dQZTRMy8T1Z16GFv2gDgy4PAKl526O4MArFLv\/11stUo8HUNtk70e3lJdkAPt0\nrOBtrtDu2DjPnKPakNyR552dmLBniTBccjx+OQFh89PKV723TsFBr1AuvX3RRzMU\nl7OTH7Kt5iftZCJDGc8tRfLLvwCv75lmrOopccc\/qwhjyqbhN2vecHrZADUTRCLu\ncZ+A2fIep4faPFDnFFwz5kgjz9goVOLRx\/l\/RMJLsibWzZvN6SQ1DJMHWf3N2row\nQ3qo+eXoKmsKIr8QO0ccakpYR1dbH+DyRYNUhdwbISKcUNZ4OmlA1pZprDmxdHXe\nLVNepBYKHZTgKF5kxNtrJlfWQfBmSEuU6+fgCjmLttXme1zdPA8=\n=EmDk\n-----END PGP SIGNATURE-----<\/p>\n<p>You can also check out original <a href=\"\/2024-04-07-initial_signature.txt\">message<\/a><\/p>\n"}]}