Just some stuff I regretted not writing down somewhere.
xfs - delete /home and grow /
luks device automatically take the size of their containers, so opening/closing is enough. The command cryptsetup resize
exist so that you can do a live resize, i.e. we expand the logical volume, resize the luks container and grow the filesystem without unmounting /
or anything else.
xfs_growfs does not take a device but a mountpoint/path i.e.
xfs_growfs /dev/mapper/root # error
xfs_growfs / # ok
another note:
lvextend
and lvresize
seem to do the exact same thing.
nix - bootloader config
In nixos, the old boot entries aren’t deleted despite running nix-garbage-collect
. notice difference between:
$ sudo nix-env --list-generations
$ sudo nix-env -p /nix/var/nix/profiles/system --list-generations
the second one has a correct output (or at least the same as the boot entries). Running nix-garbage-collect
afterwards cleans up everything needed by these systems’ generations.
nix-collect-garbage -d
seems to delete old generations of every profile though.
Just deleting the generations and cleaning the store isn’t enough to cleanup the bootloader entries. Entries and images are still in the /boot
. Turns out that simply rebuilding nixos (nixos-rebuild switch
) will do the job.
So I guess the best course of action is to collect-garbage and then update the system.
nix - installing a font and discovering a bit of nixos
Just putting the font in ~/.locale/share/fonts/
or ~/.nix_profiles/share/fonts/
(and rebuild the cache with fc-cache -f
) is enough.
I kind of wanted to put the font in nixpkgs at first (but I didn’t because of weird licensing stuff I don’t really understand or care enough to try to understand), so I just looked at other fonts derivations:
{ lib, fetchzip }:
fetchzip {
name = "some-font";
url = "https://nice.fonts/some-font.zip";
sha256 = 17mhd50mgs2drl62klicibvg9nszh96pc0cgshfnysmrhy8dm8cn";
postFetch = ''
mkdir -p $out/share/fonts
unzip -j $downloadedFile \*.ttf -d $out/share/fonts/truetype
'';
meta {
description = ..;
homepage = ..;
platforms = ..;
license = ..;
# etc.
};
}
The meta field is just info for the resulting derivation. Since I didn’t really get what exactly (and how) it generates the sha256, I just gave the field some random sha256 (nix will complain about the length otherwise), ran the build, checked the error message for what the actually (vs expected) hash it computed and copied that one in my derivation.
So, the $out
variable corresponds to the ~/.nix-profile/
dir if installed imperatively by the user. But fonts installed by the nixos-rebuild
command, those from the configuration.nix
, did not end up in the system’s profile dir /run/current-system/sw/
. Indeed, when running fc-list, we get /nix/store/<hash>-fontname/share/fonts/truetype/font.ttf
. I guess that in this case the $out
variable is the derivation’s directory in the /nix/store/. So $profile/share/fonts
s aren’t the only font directories fontconfig tracks, instead it tracks every fonts dir in the store we installed! I got curious how this was achieved.
It was pretty easy to trace back once I realized we specify all the fonts we desire in the configuration.nix
as
Just grep for fonts.fonts
in nixpkgs. Got an obvious hit in nixos/modules/config/fonts/fontdir.nix
. Turns out that’s just for the enableFontDir
option :
enableFontDir = mkOption {
description = ''
Whether to create a directory with links to all fonts in
<filename>/run/current-system/sw/share/X11-fonts</filename>.
to achieve this it runs the following command:
find ${toString config.fonts.fonts} \
\( -name fonts.dir -o -name '*.ttf' -o -name '*.otf' \) \
-exec ln -sf -t "$out/share/X11-fonts" '{}' \;
config
is our configuration.nix
passed as parameter. That’s obviously not it, but it’s interesting to see what toString
does:
nix-repl> toString nixpkgs.hello
"/nix/store/3qsyp7mplpmhm14wwnkg8w03bnw75cmn-hello-2.10"
Yes it gives us back the path in the store of the derivation..
the actual thing I was looking for is in nixos/modules/config/fonts/fontconfig.nix
:
supportFontsConf = pkgs.makeFontsConf { ...; fontDirectories = config.fonts.fonts; };
which is a function (defined in the all-packages.nix
) that just wraps around pkgs/development/libraries/fontconfig/make-fonts-conf.nix
I don’t really know enough of fontconfig to really understand what’s happening there though and it doesn’t seem very nix-related anyways.
nixos - session related stuff
So I ran into a problem where $HOME/bin
wasn’t on my PATH anymore. Which normally wouldn’t really be a problem (just fix it in your .bashrc
or .profile
) except that my dmenu_run
script is in there and therefore, it needs to be in the PATH of my window manager (xmonad). Using .xsessionrc
didn’t work unfortunately, but luckily, there’s a clean nixos solution for that: services.xserver.displayManger.sessionCommands
. The shell commands are ran just before the window manager is started. It’s also turns out to be a good place for deactivating my mouse acceleration:
services.xserver.displayManager.sessionCommands = ''
export PATH=$HOME/bin:$PATH
${pkgs.xorg.xset}/bin/xset m 1/1 0
'';
Actually, since I know about this I could probably get rid of some of my scripts in my $HOME/bin
, since I started using that folder more as a hack to get the scripts I wanted in xmonad’s (or related programs) PATH.