I have to edit the config.scm file in order to achieve this, correct?
I’m using approach I saw at aurtzy/uix-config repo - having whole flatpak as a service.
That way I install flatpak apps only through guix (home), so I’m doing reconfigure anyway.
You can see usage at my systems/kocour.scm - but I’m just beginning with Guix, so probably not best one to follow with advices ![]()
You need to make sure your XDG_DATA_DIRS env var is set correctly to include $HOME/.local/share/flatpak/exports/share.
There should be a script .guix-home/profile/etc/profile.d/flatpak.sh that does this for you.
Is .guix-home the same as /gnu/store/XXX-flatpak-version?
I’ve got two versions. How do I get rid of the older one?
Do I need to run this script with sh flatpak.sh?
[edit #1]
Answering my first two questions (with help from trev and others on Libera IRC)
~/.guix-home- Since I don’t have to look into
/gnu/store/..this no longer applies.
[edit #2]
I can set this in ~/.bash_profile but I’m not sure if this will help:
export XDG_DATA_DIRS=$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share
Doesn’t this run while opening a terminal, while I want this to be run during display manager startup?
[edit #3]
Alright, I think I’ve got it. From the guix manual and looking up what plain-file and local-file means I added this to /etc/config.scm services:
(simple-service 'flatpak-service etc-profile-d-service-type
(list (local-file "flatpak.sh")))
I have not been able to test this though. I’m receiving an unrelated error during testing that will need a separate thread.
I don’t know if I ever got this working, so I’m going to ask again. Only this time I’m aware that user packages, system packages and home packages exist of which at least the latter two can be configured.
And since I still use guix upgrade more often than guix home reconfigure home-configuration.scm, I prefer my packages to be a user packages and thus removed them from my home-configuration, resulting all of a sudden into the disappearance of flatpak apps from ?PATH?. I currently have flatpak installed as a user package, should that be a system package instead? It’s not like my root user is using it.
$HOME/.local/share/flatpak/exports/share is showing up in XDG_DATA_DIRS
P.S. the simple-service thing in my previous post certainly wouldn’t work.
The simple-service thing won’t really work with a local-file, unless you use a link to a profile path. That’s useful sometimes, but it gets messy.
What does flatpak.sh do? There should be some way to configure your guix-home environment to extend your user’s profile variables to include what flatpak needs.
guix-home will kinda take over your user’s initial profile management:
- packages installed in guix-home configuration will have precendence, assuming that
.*_PATHis ordered correctly (it should be) - binaries/etc for packages installed to the user’s list of packages will be matched if not in the home configuration. (you can install packages to both places… though occasionally you need to be careful)
I never fully configured guix home. I was close (I did it in an ISO), but it was hard to migrate all at once from my old system of ~/.profile, which were based on daviwil’s dotfiles.
Does anyone know how to separate the system upgrade from the home-configuration upgrade?
- I know
home-configurationcan be specified as part of theoperating-systemrecord forguix system reconfigure - if I later were to decouple the
home-configurationfromoperating-systemdo I just remove thathome-configurationfrom the user? I know this could cause problems if i don’t regularly upgrade both (glib compatibility maybe)
extending the home-environment-variables-service-type is a better way to get flatpak set up than sourcing the flatpak.sh script. the main flatpak package could be on the system, the user’s profile or in the user’s home profile.
(simple-service
'my-flatpak-env-service
home-environment-variables-service-type
;; in home-configuration, is there a better way to merge path variables?
`("XDG_DATA_DIRS" . ,(string-join
(list "/home/myuser/.guix-profile/share"
"/home/myuser/.local/share/flatpak/exports/share"
;; there are some more values here...
;; you don't want to lose "/run/current-system/profile/share"
) ":")
))
Are there better utilities for merging those path-like variables? There are for package builds.
aurtzy/guix-config uses build-path-augmentation here, but overall that repository may be quite complicated for someone getting used to Guix/Nix.
Actually, in ~simendsjo/dotfiles: sijo/home/simendsjo-base-home-environment.scm, to extend path-like variables, this user does things like:
(simple-service 'non-guix-application-bin-path
home-environment-variables-service-type
`(("PATH" . ,(PATH (list (home "/bin")
(home "/.local/bin")
"$PATH"))
)))
That should work for XDG_DATA_DIRS without really overwriting anything (i think). I keep a lot of dotfiles cloned & up to date.
Also, there’s this approach, but in the Guix codebase, I can’t tell whether the home-environment-variables-service-type source actually handles that (lambda (config) ...) or whether it’s just equivalent to the backquoted list.
(define-public sijo-kubernetes-service-type
(service-type
(name 'sijo-kubernetes-service)
(extensions
(list (service-extension home-profile-service-type
(lambda (config)
(list kubectl ; kubectl
kubelogin ; azure authentication
krew ; kubectl plugin manager
kubectx ; switch between clusters
kubens ; switch between namespaces
)))
(service-extension home-environment-variables-service-type
(lambda (config)
`(("PATH" . ,(PATH (list (home "/.krew/bin") "$PATH"))))))))
(default-value #f)
(description "kubernetes setup")))
I’m just trying to figure this out for myself as well. I’m on nixos, but i eventually want to move back to guix. i can’t believe i hadn’t encountered this problem.
This is unrelated to my issue since XDG_DATA_DIRS is correct, although I don’t even know how.
But I’ve been having issues setting my path in my home-environment-variables-service-type, I was only able to set that in home-bash-configuration (environment-variables) I think I’ll try solving that.
$ guix home reconfigure ./home-configuration.scm
error: PATH: unbound variable
But alas, I come to another issue. Where does this PATH come from?
this means, something in scheme is referring to PATH as a value, which isn’t defined.
error: PATH: unbound variable
I hadn’t tested simendsjo’s code. I guess PATH is a function loaded elsewhere. home-bash-configuration may be the correct place to set that instead.
export XDG_DATA_DIRS=$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share
if you set it in .bash_profile like this, then it’s being loaded by your profile. There are several places you can do this. It’s just important to be aware of how these path variables are getting set up. If you’re certain about the simple things, it makes troubleshooting easier (although i guess i’m getting some things wrong above, woops)
These aliases help to check the PATH variables. There may be a better way.
# run with `env | pathtr` or `env | covia`
alias pathtr='tr ":" "\n"' # splits .*_PATH variables onto multiple lines
alias covia='sed -e "s/:/\n:\t/g"' # same as `pathtr`, but indents lines
These filter environment variables
# run `env | nenvia` to show all variables that don't end with PATH
alias envia='grep -e '\''^[A-Za-z0-9_]*PATH='\'' | sort | uniq'
alias nenvia='grep -ve '\''^[A-Za-z0-9_]*PATH='\'' | sort | uniq'
These diff environments. So for systemd-based distributions like NixOS, I can run systemctl --user show-environment | diffia and check for how that’s different from what’s in hyprland,
# this diffs .*PATH variables
alias diffia='envia | covia | diff - <(env | envia | covia)'
# difnia will check other environment variables
alias difnia='nenvia | diff - <(env | nenvia)'
On Guix, running this will highlight how the environment was modified.
export t=$(mktemp)
env > $t # save current env to a temp file
guix shell qttools # enter a guix shell
echo $GUIX_ENVIRONMENT # /gnu/store/j7l2znwpcl0npadddydgdd52dr10sl1r-profile
cat $t | diffia
And that shows that PATH has $GUIX_ENVIRONMENT/bin
36a37
> : /gnu/store/drapg7ap0g0n2hilibvrp9snhplrb0zx-glibc-utf8-locales-2.41/lib/locale
94c95,96
< PATH=/home/dc/.local/share/mise/installs/node/latest/bin
---
> PATH=/gnu/store/j7l2znwpcl0npadddydgdd52dr10sl1r-profile/bin
> : /home/dc/.local/share/mise/installs/node/latest/bin
Moving from Arch to Guix to NixOS has been a bit rough for me. Most distributions set this stuff up slightly differently.
That was my setup. Back to that, I suppose.
if you set it in
.bash_profilelike this, then it’s being loaded by your profile. It’s just important to be aware of how these path variables are getting set up.
I can’t set those as environment variables either?
Back to that I suppose as well.
You can set these in multiple places. If you look through the shell scripts that your home-configuration creates, it will make more sense.
For future references..
/path/to/git-projects/pc-home/home-configuration.scm
...
(home-environment
(services
(append (list (service home-bash-service-type
(home-bash-configuration
...
(bash-profile (list (local-file
".config/bash/bash_profile")))
...
/path/to/git-projects/pc-home/.config/bash/bash_profile
export XDG_DATA_DIRS=$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share