I have this simple module, that for some reason doesn’t work. If I remove the conditional (if isDarwin) it works fine. But if I add the if statement back it doesn’t work. I have no idea why, the code seems correct for me & I have other modules with similar structures (without conditionals though) & they are working fine.
My setup is using flakes, nix-darwin & home-manager & I’m very much a beginner so I’m sure I’m doing lots of things wrong. My full setup is here it’s heavily WIP.
{ pkgs, lib, config, ... }:
with config.settings;
let
cfg = config.my.gui;
in {
options = with lib; {
my.gui = {
enable = mkEnableOption ''
Whether to enable gui module
'';
};
};
config = with lib;
mkIf cfg.enable {
users.users.${username} = {
packages = with pkgs;
[
slack
] ++ (if pkgs.stdenv.isDarwin then
[ ]
else [
brave
firefox
obsidian
zoom-us
]);
};
};
}
If I remove the conditional ( if isDarwin ) it works fine
do you mind pasting the error? Not sure if flakes is complaining about impure eval (which it shouldn’t, as your system should have been passed at this point), or something else.
There is no error, that’s the issue & nix build completes fine. But none of these packages gets installed, for example, Slack should be installed because it’s outside of the if/else. But it doesn’t get installed. If I remove the if/else it gets installed.
the Darwin list is empty for now, but I plan to add stuff there. So that’s why I need the if/else.
Ok, it looks like it installs Slack but doesn’t symlink it to ~/Applications because I found Slack.app in the store… I also tested the isDarwin by add [ hello ] there & that was installed properly.
So it seems that the condition is fine, but the symlinking is not working for some reason… I confirmed that by adding one of my own to this list & indeed the symlink was removed from ~/Application
I’m really puzzled by the behaviour of linking Apps. Here is another module, very simple & straight forward & has no conditionals even. Same problem. The mpv.app, gets installed but doesn’t get linked…