Okay, I am really sorry, but I don’t understand. Don’t get me wrong, I spend a lot of time reading documentation and tutorials, but I just don’t get it. What is the difference between standalone HM and HM as a module? How do I implement one and the other? What does it mean that “services.flatpak.enable” is a NixOS option? I am running NixOS. I thought that I set this option in /etc/nixos/configuration.nix (see below).
For reference this is my flake.nix:
{
description = "Nixos config flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nix-flatpak.url = "github:gmodena/nix-flatpak/";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nix-flatpak, home-manager, ... }@inputs:
let
system = "x86_64-linux";
pkgs = "nixpkgs.legacyPackages.${system}";
in
{
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
modules = [
nix-flatpak.nixosModules.nix-flatpak
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs.flake-inputs = inputs;
}
./configuration.nix
];
};
};
}
This is my /etc/nixos/configuration.nix (I deleted those, which I think are irrelevant):
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
networking.hostName = "dell-3";
services.flatpak = {
enable = true;
packages = [
"im.riot.Riot"
"com.brave.Browser"
];
};
# users:
users.users.jeansib = {
isNormalUser = true;
description = "Jean Sibelius";
extraGroups = [ "networkmanager" "wheel" ];
packages = with pkgs; [
kdePackages.kate
];
};
users.users.rozliczenia = {
isNormalUser = true;
description = "rozliczenia";
extraGroups = [ "networkmanager" ];
packages = with pkgs; [
kdePackages.kate
];
};
users.users.jacekrozycki = {
isNormalUser = true;
description = "Jacek Różycki";
extraGroups = [ "networkmanager" ];
packages = with pkgs; [
kdePackages.kate
pkgs.tor-browser
];
};
system.autoUpgrade.enable = true;
environment.systemPackages = with pkgs; [
pkgs.htop
pkgs.clamav
pkgs.tlp
pkgs.home-manager
];
system.stateVersion = "24.11"; # Did you read the comment?
}
I tested multiple times rebuilding nixos and installing flatpak this way works:
[root@dell-3:~]# nixos-rebuild switch --flake /etc/nixos#default
building the system configuration...
stopping the following units: accounts-daemon.service, avahi-daemon.service, avahi-daemon.socket, cups-browsed.service, cups.service, cups.socket, nscd.service, systemd-timesyncd.service
activating the configuration...
removing group ‘avahi’
removing user ‘avahi’
setting up /etc...
reloading user units for jeansib...
restarting sysinit-reactivation.target
reloading the following units: dbus.service, firewall.service
restarting the following units: polkit.service
starting the following units: accounts-daemon.service, cups.socket, nscd.service, systemd-timesyncd.service
the following new units were started: run-credentials-systemd\x2dtmpfiles\x2dresetup.service.mount, sysinit-reactivation.target, systemd-localed.service, systemd-tmpfiles-resetup.service
[root@dell-3:~]#
This is my home-manager config:
{config, pkgs, nix-flatpak, ...}:
{
nixpkgs.config.allowUnfree = true;
home = {
stateVersion = "24.11";
username = "jeansib";
homeDirectory = "/home/jeansib";
packages = [
pkgs.vscodium
pkgs.syncthing
pkgs.libreoffice
pkgs.vlc
pkgs.discord
pkgs.rpi-imager
];
};
services.flatpak = {
enable = true;
packages = [
"im.riot.Riot"
"com.brave.Browser"
];
};
systemd.user.services = {
syncthing = {
Unit = {
Description = "Start syncthing.";
};
Service = {
Type = "oneshot";
ExecStart = ''${pkgs.syncthing}/bin/syncthing'';
};
Install = {
WantedBy = [ "default.target" ];
};
};
But I get this error when trying to switch HM:
[jeansib@dell-3:~]$ home-manager switch -b backup
error:
… while evaluating the attribute 'activationPackage'
at /nix/store/5b0mw0h1cwwhvf32z5kjym00dd5saydj-home-manager-source/modules/default.nix:49:7:
48|
49| activationPackage = module.config.home.activationPackage;
| ^
50|
… while evaluating a branch condition
at /nix/store/8fwsiv0hd7nw1brkvka0jf1frk3m7qkr-source/lib/lists.nix:125:9:
124| fold' = n:
125| if n == len
| ^
126| then nul
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: The option `services.flatpak' does not exist. Definition values:
- In `/home/jeansib/.config/home-manager/home.nix':
{
enable = true;
packages = [
"im.riot.Riot"
"com.brave.Browser"
...
[jeansib@dell-3:~]$
What am I doing wrong?