Until now I have used profile sync daemon on every linux distro. Brave browser is not natively supported, so to make it work you have to add a file called brave to /usr/share/psd/browsers. Since Nixos is systemless and this directory is not existing, what is the declaratively aproach to create this file?
What I’ve tried thusfar: creating the file using the rules object in systemd.tempfiles, using environment.etc, yet still unsuccesful.
profile-sync-daemon, as packaged in nixpkgs, will look inside its own store path for those files. The nix store is read-only, so the only way to add the file would be to override the derivation build (i.e. with .overrideAttrs). I would add it in postInstall.
Thanks, this is my configuration, since I use flakes:
My ./overlays/psd-brave.nix looks like this:
final: prev: {
profile-sync-daemon =
prev.profile-sync-daemon.overrideAttrs (old: {
postInstall = (old.postInstall or "") + ''
mkdir -p $out/share/psd/browsers
cat > $out/share/psd/browsers/brave <<'EOF'
DIRArr[0]="$XDG_CONFIG_HOME/BraveSoftware/Brave-Browser"
PSNAME="brave"
EOF
'';
});
}
And my flake.nix:
{
description = "flake";
inputs = {
nixpkgs.url = "nixpkgs/nixos-25.11";
};
outputs = { self, nixpkgs, ... }:
let
# ----- SYSTEM SETTING ----- #
systemSettings = {
system = "x86_64-linux";
hostname = "nixos";
};
lib = nixpkgs.lib;
overlays = [
(import ./overlays/psd-brave.nix)
];
pkgs = import nixpkgs {
system = systemSettings.system;
config.allowUnfree = true;
inherit overlays;
};
in {
...
}
Yet, still it did create the brave file when I check ls /run/current-system/sw/share/psd/browsers/ unfortunately. What am I doing wrong?
You skipped how your nixosSystem call works, so I can’t confirm whether the pkgs value you’re configuring in your flake.nix actually gets used for anything. I suspect it doesn’t, so configuring it won’t change anything, but you really shouldn’t be defining a pkgs value in flake.nix at all, and definitely shouldn’t be overriding the nixpkgs instantiation process built into nixos without a very good reason.
Most likely what you need to do is configure the overlay through the nixpkgs.overlays nixos option.
I’m relatively new to Nixos and especially to using overlays. I am using the pkgs value to add the config.allowUnfree atribute to my nixpkgs and this is as far as I know the only way to achieve that, but if you know a better solution i’d be happy to adapt my code to it. Here is my full flake for reference:
{
description = "flake";
inputs = {
# nixos nixpkgs github repository
nixpkgs.url = "nixpkgs/nixos-25.11";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
home-manager = {
# home-manager github repository
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-snapd.url = "github:nix-community/nix-snapd";
nix-snapd.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, nix-snapd, ... }:
let
# ----- SYSTEM SETTING ----- #
systemSettings = {
system = "x86_64-linux";
hostname = "nixos";
};
# ----- USER SETTINGS ----- #
userSettings = {
username = "ejan";
};
lib = nixpkgs.lib;
overlays = [
(import ./overlays/psd-brave.nix)
];
pkgs = import nixpkgs {
system = systemSettings.system;
config.allowUnfree = true;
inherit overlays;
};
pkgs-unstable = import nixpkgs-unstable {
system = systemSettings.system;
config.allowUnfree = true;
};
in {
nixosConfigurations.nixos = lib.nixosSystem {
inherit pkgs;
modules = [
./configuration.nix
nix-snapd.nixosModules.default
{ services.snap.enable = true; }
];
specialArgs = {
inherit systemSettings;
inherit userSettings;
inherit pkgs-unstable;
};
};
homeConfigurations.${userSettings.username} = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
./home.nix
];
extraSpecialArgs = {
inherit userSettings;
inherit pkgs-unstable;
};
};
};
}
Ok, so you are passing pkgs to nixosSystem. This has never been a recommended thing to do, but some “templates” out there do it anyway… for no real reason. It’s a bit frustrating how many newbies end up doing this and shooting themselves in the foot somehow.
However, non-recommended though it is, this should have worked… how are you trying to use psd? Through the nixos module? The home-manager module? A more custom setup?
Though it probably isn’t the fix here, you should know the normal and expected thing to do is to not pass pkgs to nixosSystem, and set the nixpkgs.config and nixpkgs.overlays options in your configuration.nix to configure the nixpkgs instantiation the nixos does internally.
Home-manager does require a pkgs argument, but it does… weird shenanigans to apply the nixpkgs.config and nixpkgs.overlays options on top of what it’s given. I’m not sure how well those shenanigans work in all cases. The normally expected thing to do with home-manager is to set pkgs = nixpkgs.legacyPackages.${system};, and then do all configuration through the nixpkgs.* options just like with nixos. pkgs is essentially a funny way to set both “what nixpkgs should I use” and system simultaneously, rather than a way to actually set what the pkgs value will be inside home-manager. Home-manager is weird like that sometimes.
This might be the reason your setup isn’t working if you’re trying to use psd through the home-manager module.
Tkanks for your thoughful suggestions. I have installed psd in my environment.systemPackages and updated my flake with these modules:
nixosConfigurations.nixos = lib.nixosSystem {
modules = [
./configuration.nix
nix-snapd.nixosModules.default
{
services.snap.enable = true;
nixpkgs.config.allowUnfree = true;
nixpkgs.overlays = overlays;
}
];
specialArgs = {
inherit systemSettings;
inherit userSettings;
inherit pkgs-unstable;
};
};
I have also updated my ./overlays/psd-brave.nix:
final: prev: {
profile-sync-daemon = prev.profile-sync-daemon.overrideAttrs (old: {
postInstall = (old.postInstall or "") + ''
mkdir -p $out/share/psd/browsers
cat > $out/share/psd/browsers/brave <<'EOF'
DIRArr[0]="$XDG_CONFIG_HOME/BraveSoftware/Brave-Browser"
PSNAME="brave"
EOF
'';
postFixup = (old.postFixup or "") + ''
sed -i "s|SHAREDIR=.*|SHAREDIR=\"$out/share/psd\"|" $out/bin/profile-sync-daemon
'';
});
}
This now actually creates the brave file in the nix store to add brave browser support to psd on nixos. The only one thing is I cannot get the systemd psd.service started even though I added services.psd.enable = true; to my nixos configuration and systemctl --user start psd.service doesn’t work.
“doesn’t work” is extremely unspecific. What happens instead of what should happen?
Sorry I was in a hurry.
To be more specific when I run systemctl --user start psd.service I get:
Failed to start psd.service: Unit psd.service not found.
And psd preview gives me this output:
Profile-sync-daemon v6.50
systemd service: inactive
resync-timer: active
sync on sleep: disabled
use overlayfs: disabled
Psd will manage the following per /home/ejan/.config/psd/.psd.conf:
browser/psname: brave/brave
owner/group id: ejan/100
sync target: /home/ejan/.config/BraveSoftware/Brave-Browser
tmpfs dir: /run/user/1000/psd/ejan-brave
profile size: 335M
recovery dirs: 2 <- delete with the c option
dir path/size: /home/ejan/.config/BraveSoftware/Brave-Browser-backup-crashrecovery-20260222_204208 (328M)
dir path/size: /home/ejan/.config/BraveSoftware/Brave-Browser-backup-crashrecovery-20260222_161231 (328M)
browser/psname: chromium/chromium
owner/group id: ejan/100
sync target: /home/ejan/.config/chromium
tmpfs dir: /run/user/1000/psd/ejan-chromium
profile size: 111M
recovery dirs: 5 <- delete with the c option
Could it be that I have to install profile-syn-daemon in the home manager environment? That poses another question: The unfreePackagesoption is not possible when I set pkgs = nixpkgs.legacyPackages.${system}; and I rely on it for some packages. Should I perhaps go for a more modular setup for home manager?
My bad, I had the psd service enabled on the system level. I moved it to the homemanager rebuild both configurations and now the service is up and running. Thanks @tejing for pointing me in the right direction and I’m glad everything now works as expected.