Getting started with Home Manager and Flakes

There are certain customizations I make to every fresh install of an OS, such as disabling history and changing some keyboard shortcuts and theme in vlc and LibreOffice, this sounds like something Home Manager should handle well if I understood correctly what it does, the problem is that I have no idea how to get started with it, can it be use to set up such things?

I would also like to try some advanced features available through Flakes, for example some applications are not packaged in the Nix repos, so I would like to install them through Flatpak declaratively, I found nix-flatpak and declarative-flatpak, but I have no idea how to use them. I need some help.

If apps are writing to some file in your home dir to achieve this, then yes, hm could probably do this.

Two caveats:

  • HM will manage the file, preventing apps from changing said files or at least clobbering imperative changes during activation
  • The files should be in some easily generatable text format

If that’s applicable, HM away.

Home manager is great for changing various settings in applications. On my setup I made a git repository with all of my dotfiles then linked them to their correct places.

Here is an example from my home-manager setup

  home.file = {
    # # Building this configuration will create a copy of 'dotfiles/screenrc' in
    # # the Nix store. Activating the configuration will then make '~/.screenrc' a
    # # symlink to the Nix store copy.
    # ".screenrc".source = dotfiles/screenrc;
    
    ".config/alacritty.toml".source = ../../alacritty.toml;
    ".config/nvim/init.lua".source = ../../nvim/init.lua;
    ".tmux.conf".source = ../../tmux/tmux.conf;

    ".tmux/plugins/tpm".source = pkgs.fetchFromGitHub {
        owner = "tmux-plugins";
        repo = "tpm";
        rev = "master";
        sha256 = "01ribl326n6n0qcq68a8pllbrz6mgw55kxhf9mjdc5vw01zjcvw5";
    };
  };

If you would like to see more of my dotfiles you can find them here GitHub - joseph-scott-campbell/config-files: Configuration files for my linux system

If keeping dot-files in a VCS is the only goal I’d pick a tool that does only that. General-purpose dotfiles utilities - dotfiles.github.io seems like a good place to start looking.

Can it be used to make some files immutable like the chattr +i file command?

The dotfiles that are symlinked from the nix store do not have the immutable attribute set. However, /nix/store should be usually mounted as a read-only file system, so for that purpose the outcome might be similar, depending on your requirements.

I meant to ask if Home Manager can be used to make dotfiles immutable upon rebuild